Last post Sep 09, 2015 06:45 AM by adriang133
Sep 08, 2015 05:34 AM|adriang133|LINK
I'm trying to get the field (or fields) that is the foreign key for a known type in a MetaTable.
I can get the MetaForeignKeyColumn objects that are of that specific type
var fksOfType = table.Columns.OfType<MetaForeignKeyColumn>().Where(column => column.ParentTable.EntityType == typeof(myType)).Select(column => column.Name);
If my current table has a FK called productId referencing the table Product, then the model creates a MetaForeignKeyColumn "Products" based on that FK. Now I can get the MetaForeignKeyColumn above but I can't find a way to get the actual field
name in the current table that is the fk(productId in this case) to the type Product.
I can get all the MetaColumns that are Foreign Keys
var fkCols = table.Columns.Where(column => column.IsForeignKeyComponent);
and this contains productId but I can't find a way to link it to the type that it is referencing.
Is it possible to link the MetaForeignKeyColumn and it's related MetaColumn ?
Sep 08, 2015 07:57 AM|sjnaughton|LINK
Once you have the MetaForeignKeyColumn or MetaChildrenColumn they have specific properties that you can reference to get those
Hope this helps
Sep 09, 2015 06:45 AM|adriang133|LINK
Yes, that was what I was looking for. I can't believe I missed it.