Quantcast
Viewing all articles
Browse latest Browse all 764

Single Child Object MarkAsDeleted returns New Object

I've been reading on Child Object on this forum and I didn't see an exact match for my issue, here it is

I have a 1:1 relationship object 

In Object1 I have this

private static readonly PropertyInfo<IObject2> Object2Property = RegisterProperty<IObject2Property>(p => p.Object2Property, RelationshipTypes.Child);

public IObject2 Object2
{
   get { return GetProperty(Object2Property ); }
   set { SetProperty(Object2Property , value); }
}

The issue here is that Object2 can be set to Null when another field is set to 0 using a business Rule like 

 if (this.OnOrderQty > 0)
 {
     var newObject2 = new Object2();
     newObject2.Property1 = this.OnOrderQty;

      context.AddOutValue(Object2Property, newObject2);
 }
 else
 {
     if (Object2 != null)
     {
         object2.MarkAsDeleted();
         context.AddOutValue(Object2Property, object2);
     }
 }

 

The problem I'm having is

If I leave the code this way when I save Object1 and Object2 is MarkAsDelete, it does delete the Object2 (Calls the Delete function of Object2) but It when it returns to the UI (WinRT) Object2 is still there and the isNew is set to true

What I would like is the object to be deleted and set to Null so Object1.Object2 would return null not a new Object2 with the same properties that the one i Just deleted.

 

Am I doing something wrong here?

 


Viewing all articles
Browse latest Browse all 764

Trending Articles