MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

IsDirty Without Child Relationship #650

Open CrossSlide opened 5 years ago

CrossSlide commented 5 years ago

I have a BO with two child properties where I set RelationshipTypes.Child. I have a third CSLA object as a property that does not set the child relationship. However, if this non-child property IsDirty then my BO shows IsDirty = true but IsSelfDirty = false even though I set it with the LoadProperty().

Is this expected behavior? It was very hard to track down the cause of the IsDirty. I didn’t think it would do this because it is not a child object. Anyway to prevent this behavior?

Version and Platform CSLA version: 6.3 OS: Windows Platform: WPF

Chicagoan2016 commented 5 years ago

@CrossSlide , The third Csla Object that you mentioned, is it a 'using' relationship or an intergraph reference?

CrossSlide commented 5 years ago

Not sure what 'using" is or means. It's just a normal CSLA property in the class that I set when needed. Thanks

Chicagoan2016 commented 5 years ago

@CrossSlide , I would recommend reading p-35, 36 in 'Creating Business objects' book. Rocky has excellent recommendations on when /how to use 'using' vs Intergraph reference.

CrossSlide commented 5 years ago

Will do! Thanks

CrossSlide commented 5 years ago

Ok, yeah it's one of those things you read in the beginning and tell yourself to keep in mind but then don't think about when the situation comes up for the first time.

Thanks @Chicagoan2016 !

ajj7060 commented 5 years ago

To answer your original question, if you don't want this third Bo to make your main BO dirty, you should be able to override the IsDirty on the root BO, and compose the dirty state yourself; eg.

public override bool IsDirty => IsSelfDirty || Child1.IsDirty || Child2.IsDirty;

Then your graph will ignore the dirty state of Child3.

CrossSlide commented 5 years ago

Thanks @ajj7060, that's a technique I'll keep in mind.