0
votes

I am executing a breeze query when page loads which gives me an entity say 'Entity_A'. This entity has a collection of another entity say 'Entity_B'.

On the same page, I am creating a new entity of type 'Entity_B' and saving it.

Now, when I get back to 'Entity_A' and try to access the collection of 'Entity_B', the newly saved entity is not present in that collection.

I wanted to ask if there is a way to refresh 'Entity_A' without executing breeze query again ?

1
You will need to show your entity relationships. If this is a complexType (not collection of complex types) then you are probably overwriting the entity. Else we don't know what may be causing the error.PW Kad

1 Answers

1
votes

Providing that you have your relationships set up correctly in metadata, and you have attached your instance of 'Entity_B' to the appropriate collection on 'Entity_A' then this should happen automatically.

So, for example, imagine you have the entity types 'Customer' and 'Order' ( corresponding to your 'Entity_A' type and your 'Entity_B' type. Presumably you would also have an 'orders' property on the 'Customer' type and probably a 'customer' property on the 'order' type.

If so then either of the followings two statements would update the 'orders' collection on your 'Customer' instance. ( Note: this is using the angular/backing store syntax - if you are using knockout or backbone the phrasing will be slightly different).

  newOrder.customer = existingCustomer;

or

  existingCustomer.orders.push(newOrder);