sql - How to tell if a property of an EntityObject is a primary key or foreign key? -
suppose have class generated entity framework called student
.
student
has following properties:
id int, name, string age, int teacherid int
suppose further id
refers primary key in sql identifies student student
object refers , teacherid
foreign key tells student's teacher is.
suppose want write function takes any entityobject
(such one) parameter , returns information properties primary keys , foreign keys.
how can this?
if not appropriate, how can entity framework tell me properties primary , foreign keys?
for now, let's not take consideration composite key fields.
looking on code autogenerated, can see primitive properties in generated class have several attributes, , among these edmscalarpropertyattribute
has boolean entitykeyproperty
seems indicate whether or not property key.
how read values of attributes described in article here: http://msdn.microsoft.com/en-us/library/71s1zwct.aspx
i'll bet can find consistent pattern how foreign keys handled well!
Comments
Post a Comment