c# - Reference Any Attribute with Entity Framework -
i trying set attributes in table @ once using entity framework, dbset, in asp.net mvc4. repository not know attributes, sure controller & view passing correct attributes (separation of concerns goodness). how reference generic attribute of table dbset?
here example:
myrepository.cs:
public class myrepository { private efmycontext context = new efmycontext(); public iqueryable<entity> tables { { return context.tables; } } public void saveentity(entity entity) { table savedrow = context.tables.find(entity.id); foreach(attribute in attribute attributes) { // how call these attributes? // update attributes } } }
mycontroller.cs:
public class mycontroller : controller { private efmyrepository repo; public viewresult save(entity entity) { repo.saveentity(entity); return view(); } }
if want update of attributes using information have in entity
instance, recommend injecting them using http://valueinjecter.codeplex.com/ .
in code, call
savedrow.injectfrom(entity);
and match attributes same name , type , update them accordingly.
Comments
Post a Comment