Template, determining the navigation property Id
Posted: Sun 20 Nov 2016 15:57
To begin with, I would like to place another vote for you to add documentation of the classes available in templates. Since template debugging is not supported, and intellisense doesn't work for me at all in Entity Developer templates (Visual Studio 2015 Enterprise), I have no way to know how to do something without contacting you.
My request. Given the following code:
I want to know how to resolve the part in '???'. In a nav property, how do I get the name of the key property that links the collection item to the collection owner?
For example, if I have an entity A with a collection named B of type C, and I have the model set to add the foreign key properties to C, what property or function do I use in the NavProperty to get the name of that foreign key property, which will be something like AId?
This is a C# Entity Framework 6 POCO model, using dotConnect SQLite
My request. Given the following code:
Code: Select all
var navProperties = cls.RelationProperties
.Where(rp => rp.Generate)
.OfType<EntityRelationProperty>().ToList();
bool isCollection = navProperty.Multiplicity == Multiplicity.Many;
if (isCollection) {
string typeName = navProperty.RelationClass.Name;
string propertyName = navProperty.Name;
string keyPropertyInCollectionItemBackToParent = navProperty.???
}
For example, if I have an entity A with a collection named B of type C, and I have the model set to add the foreign key properties to C, what property or function do I use in the NavProperty to get the name of that foreign key property, which will be something like AId?
This is a C# Entity Framework 6 POCO model, using dotConnect SQLite