sorry english. junior developer. have 1 question in asp.net mvc 4 entity framework.
public class clientcontext:dbcontext { public dbset<client> clients { get; set; } } clients stored in table "clients". iam have 1 table "goodclients".and under different terms need insert client in 1 of tables. can using clientcontext? need?
i recommend add boolean marker client class - isgoodclient can work client table this:
var goodclient = clientcontextinstance.clients.where(e=>e.isgoodclient); var badclients = clientcontextinstance.clients.where(e=>!e.isgoodclient); to convert client 'goodclient' 'badclient' can this:
var goodclient = clientcontext.clients.first(e=>e.isgoodclient && e.id == 1); goodclient.isgoodclient = false; clientcontextinstance.savechanges(); so dont need make new table storing goodclients
edit
other way add goodclients dbset context:
public class clientcontext:dbcontext { public dbset<client> clients { get; set; } public dbset<goodclient> goodclients { get; set; } } but horrible idea, because store same data in different tables.
Comments
Post a Comment