asp.net mvc - Entity Framework - Simple Inject use Interfaces as Models -
i'm trying implement context this
idbset<iroom> rooms { get; set; } however ef doesn't support interfaces.
i've following service may create iroom/room:
public virtual void createsamples() { room room = new room(); room.encrypted = true; room.token = guid.newguid(); room.name = "teste-" + room.token.tostring(); room.notracking = true; room.private = true; room.userid = this.membership.currentuser; room.createdby = room.modifiedby = this.membership.currentuser; this.context.rooms.add(room); this.context.savechanges(); } this "ef interface model" came because want replace
room room = new room();
with
iroom room = objectfactory.create<iroom>();
ps: behind scenes objectfactory.create<> calls injector container , gets object using getinstance<>
the problem here context accepts room not iroom since declaration is:
idbset<room> rooms { get; set; }
if isn't clear this.context.rooms idbset<room>
is possible achieve want?
i'm thinking creating unitofwork receives interface , goes injector container , tries correspondent type. thinking right?
Comments
Post a Comment