Breeze (1.4.5) unidirectional one-to-many: navigation collection not populated - breeze

I have a model where I have a two entities, a "Parent" and a "Child".
The relationship should be obvious but goes: Parent has zero or more Child entities.
The Parent has a navigation property called "Children" with a collection of Child entities.
The Child does NOT have a navigation property back to the parent. It only has a foreign key leading back to the parent.
When I load these models into my EntityManager, the "Children" navigation property collection is only ever populated with 1 child, even though the given Parent entity in fact have several.
I have tried adding a "Parent" navigation property to the "Child" entity, and if I do this, the "Children" navigation property on the "Parent" entity is populated correctly with all Child entities when loaded in the EntityManager.
The problem is that this is not an option.
If it helps, I am not using the "Knockout" models, but rather the "backingStore" library for Angular model binding.
I have seen the question on the following link, which describes a rather similar issue (although, supposedly fixed and for a much older version of Breeze): Child entities not populated without inverse property

Related

iOS: Property of managed objects relationship has changed, but managed object doesn't notice

I wasn't able to find anything on this except the fetched results controller problems, which I already solved as well.
But here I have this problem:
My view controller (let's call it MyVC_A) has a property PointOfInterest *poi. This entitiy PointOfInterest has a relationship to the entity Category, called "belongsToCategory" and is n-1. So a PointOfInterest only belongs to one category. So if you select one table cell in MyVC_A which represents one PointOfInterest, you get the next view controller showing all available categories. If you change now the selection of the category and pop this view controller back, the belongsToCategory attribute in MyVC_A hasn't changed, even when I put all the label and image code into the viewWillAppear method.
So I know the property has changed and has been correctly saved in the context, but no changes are displayed. I kinda know why, but what can I do against it? How can I "refresh" my PointOfInterest object in MyVC_A to display the changes?
You need to call performFetch: on your fetched results controller and then reloadData on your tableview.

When would a Collection Navigation Property not be initialized?

I'm using EF 6.1, Database First. I have Lazy Loading disabled.
If I load an entity without Eager loading its Collection Navigation Properties, would I ever have to worry that these navigation properties were not properly initialized? Should I be able to use entity.collectionnavigationproperty.Add(new entity) without worrying about initializing the collection navigation property first?
I'm not sure how it works for models created without DataBase First, but it seems that all my entities with Collection Navigation Properties are initialized in the constructor with HashSet<>. That's why I have not encountered issues with nulls or having .Add fail.

Can I access the parent view's Model from a child partial view?

Can I access the parent view's Model from a child partial view? I get conflicting information when I look this up.
If so, can anyone point me at an example?
And if so, would it help to make the child model object a property of the parent model?
No.If you are talking about strongly binding the views with ViewModels then you can only access the model which you pass to your partial view.But if you want something to be available in partial view or any other view you can use ViewData dictionary.
Other thing you can always do and should do is to make your view model in such a way so that it caters to your parent view as well as your all child views .So to answer your last question yes you can make child model object a property of your parent model.
Another point here is that make sure you keep your domain model separate from View model which you are going to bind to Views and not make UI related changes to your domain model for just the sake of binding it to view.

Child attribute changes from different view controller are not reflecting in parent attribute in other View Controller - ios

I have an attribute which has a relationship with a sub attribute which has a property as follows :
to Many
Cascade Delete Rule
When I navigate to different View Controller, Say B, I am deleting records of the subAttribute and inserting once again with some fresh new records.
And again when I come back to View Controller A and try to insert some Data on the above sub Attribute , it says
"Dangling reference to .null object".
Need some help on what am I doing wrong here.
Thanks.

Table Per Hierarchy based on fields in the Navigation Property

I have an entity which has a navigation property. I would like to define derived entities from the base entity using a field in the navigation property as the discriminator. Is this possible. I could not find a way to do this in the designer.
No it is not possible with navigation property. It should be possible to map two tables in 1:1 relation into single entity. You can try to combine it with table per hiearchy mapping. I'm interested if it works but i don't have chance to try it now.

Resources