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

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -