I would like to add data properties for child nodes that have been predefined in nav properties of my metadata that I am created by hand as my model. These new data properties will be used to establish the relationship between the parent and child node.
How to do it:
Basically what I want to do is create the new data property of a node that is deemed the child node with the id of the parent node. I am thinking this would be done under the visitNode code within my jsonResultsAdapter code.
Question:
Once the new child data property has been added will this established the relationship between the parent and child nodes. Can I then create breeze queries against this?
Has anyone done this before and if so please share.
Thanks anyone for your feedback, this will be greatly appreciated!
You can have your JsonResultsAdapter create a property that did not exist in the incoming feed, but Breeze will need to have metadata for this property already specified. i.e you need to update the Breeze EntityType metadata ( see Breeze docs) to contain any properties that you plan to add dynamically in your JsonRe*emphasized text*sultsAdapter.
You will NOT be able to create queries against such properties, however, because Breeze has no idea how to compose such queries.
Related
For example, there are two Entities, Parent and Child. There are 1..n Child Entities for any Parent Entities. Is there a way to set up a Service in SEGW so that when calling a Navigation Property from Parent to Child, the Data Provider Class of Child is called with a table of Parent keys so subsequently all child entities for each parent can be selected? This is for nesting a list into a detail screen in SAP Mobile Developement Kit.
In the meantime, we have built this functionality around the get_expanded_entity method. There is however another issue that I will open another question for.
Generally the $expand operator of oData has to be used. the oData entity should have a ddic structure that can be used to fill an internal table which is then passed to function copy_data_to_ref inside get_expanded_entityset method. This will return a nested odata result
I am trying to use the "sandbox editor" approach with exportEntities and importEntities as detailed in the Cool Breezes section (and in many SO posts).
I have a main/parent entity which has one or more child entities. I have an HTML view (using Aurelia but that doesn't matter) that displays the 4 properties from the parent entity and then 3 or 4 properties from each of the child entities. In this example the parent has just one child entity.
The view uses a new entityManager and the parent/child entities have been imported from the 'master' entityManager in the usual export/import way. So far so good.
I edit one of the properties on the child entity and save it. I pass the saveResult to a copy of the updateMasterWithSaveResult. Everything works fine up to the line masterEm.importEntities(exported);
imports[] contains just one updated child entity - correct.
deletes[] is empty - correct.
exported contains the updated child entity info - correct.
masterEm contains the original parent and the original (non-updated) child - correct.
The problem
After it has called masterEm.importEntities(exported), masterEm now contains the original parent BUT the child property array now has 2 elements in it and both of them are the same, updated, child element. They are identical - same key, same everything.
Analysis
After much tracing I've narrowed this down to _linkRelatedEntities in a50_entityManager.js. At the bottom of this function it handles the foreign keys of the child and calls parent.getProperty(invNp.name).push(entity) or parent.getProperty(invNp.name)._push(entity) but
doesn't appear to check if the child is already connected. So in this case the child entity is
already in the array but gets added a second time.
Question: Is this the expected outcome? And, if so, am I missing something or is there a 'proper' way around it so that I end up with only one child element?
My temporary solution is to run a de-duplication on the child array after running importEntities but that seems hacky to say the least.
Recently, I am trying to refine my code. I found that all my entities has attributes named identifier and owner, so I want to create a entity to be their parent which contains identifier and owner.
Following is the result, all object inherit from a parent named SRModel, which has identifier and owner attributes.
However, after I delete all these redundant properties, the persistent store is not able to auto migration.
How can I solve the problem? Do I have to do migration by myself?
Are there any simple way to do so?
According to Apple's Core Data Model Versioning and Data Migration Programming Guide, you can't do that automatically.
You cannot, however, merge entity hierarchies; if two existing entities do not share a common parent in the source, they cannot share a common parent in the destination
Note Andy Riordan's point about inheritance. And don't just take his word for it; look at the generated .SQLite files yourself under the old and new models. Adding a parent entity with only two common attributes will just make your entities, and backing tables, larger, with no performance benefit. If you really want to note the two common elements, use a Protocol to call them out.
Background Info
So I am using Breezejs and Knockout with EF5 and the Breeze MVC api controller on the backend. One of my tables in my data base is an association table, 3 columns - an id and two foreign keys(we'll call them fkey1 and fkey2 with table1 and table2). In my application, I need to add a record to this association table. Breeze knows about the relationships that this table has.
Situation
Breeze js makes a new record for me, then I find out the records I need to associate with it. Do I need to add in the id of the table1 entity into the fkey1 observable and the table2 entity id into the fkey2 observable AND add the whole entities into their respective relationship properties AND add push this new entity object into the table1 and table2 entities association property? Or does adding the id's into the new object automatically add those objects into the relationship properties (maybe those objects are subscribed to the fkey1 and fkey2 properties? - this is what I'm guessing happens in the background of breeze, a shot in the dark though I have no idea).
Creating new entities with Breeze is super easy and I love it, but I'm a little confused when it comes to creating new entities that have a lot of relationships.
Let me if you need a better description of my situation, it's kind of a tough thing to explain. Thanks!
Providing that you set the "foreign key" properties appropriately when creating and attaching entities, Breeze will automatically update all of the associated relationships, i.e. navigation properties on this and any related entities. You should never need to manually perform any fixup.
Similarly, if you do the reverse and assign an entity to a scalar navigation property then Breeze will automatically update the foreign key(s). For a collection navigation property, if you push a value into the collection then Breeze will automatically update the foreign key of the entity being pushed.
Hope this helps, but maybe I'm missing the question...
I want to have a relation between views in EF. I am following this post to modify it in the xml file.
http://smehrozalam.wordpress.com/2009/08/12/entity-framework-creating-a-model-using-views-instead-of-tables/.
I am getting error,
Custom tool error: Multiplicity is not valid in Role 'VIEW' in relationship 'FK_'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be 1.
I am not really sure if I am going the right path.
The main goal of doing this is to use this entity over oData, and have links to the Ids in the view. I am not using the tables directly, because the table has Ids and I want the names to be sent back to the client. The relationship should give the child details.
If there is any other way to achieve this, please help!!
Thanks in Advance