c# - How do I get an arbitrary entity stored in the context with Entity Framework? -


i using entity framework. need arbitrary entity context can use reflection @ properties. don't need specific entity, arbitrary 1 do. call should this:

entity oldentity = (entity)_context.set(newentity.gettype()). 

and method should go after last . don't see work (find best bet can't use since don't know id's of of entities).

edit:

i forgot mention newentity passing in generated codedom class, newentity same entities in context, may have different properties, why have example "old" entity compare properties. clarify this, imagine have stored person entity properties:

  • first name
  • last name

then want add new property, let's age. way i'm doing generating new person entity class codedom age additional property. have updated entity class on disk, can create new entity field, sql table isn't updated.

you don't need actual instance of class @ properties.

you can use typeof(...) typeof(entity).getproperties()


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -