c# - How get primary keys & values in EntityFramework? -
i use following code primary keys of entity in ef :
objectcontext objectcontext = ((iobjectcontextadapter)_datacontext).objectcontext; objectset<tentity> set = objectcontext.createobjectset<tentity>(); ilist<string> pkeys = set.entityset.elementtype .keymembers .select(k => k.name).tolist();
but problem here above code retun name of primary keys need values too
eg : id,123
so must use reflection purpose
obj[i] = entity.gettype().getproperty(pkeys[i]).getvalue(entity, null);
is there way do not use reflection values? (more speed)
Comments
Post a Comment