c# - EntityFramework Domain Model Interface usage -
so have domain model:
public abstract class primarykey { public guid id {get;set;} } public class myentity : primarykey { public string stringproperty {get;set;} public myentity2 myentity2 {get;set;} } public class myentity2 : primarykey { public string stringproperty {get;set;} } i want give them interfaces can utilize them services injected. can't reference domain model in service core project because in sentiment backward.
so figured this:
public interface iprimarykey { guid id {get;set;} } public interface imyentity : iprimarykey { string stringproperty {get;set;} imyentity2 myentity2 {get;set;} } public interface imyentity2 : iprimarykey { string stringproperty {get;set;} } so have concrete classes , interfaces. how interfaces impact concrete classes, certainly referencing imyentity mean in concrete class have define id property, want abstract class save time.
below far got:
public class myentity : imyentity { public guid id {get;set;} public string stringproperty {get;set;} public imyentity myentity2 {get;set;} } how using abstract class work? still work? or there programming method have implement?
i thought maybe work:
public class myentity : primarykey, imyentity { // etc, no id field time } how work in repository, utilize interface generics:
public interface irepository { task<list<t>> allasync<t>(); task<t> findasync<t>(expression<func<t, bool>>[] params); } public class repository : irepository { public task<list<t>> allasync<t>() { homecoming _dbcontext.set<t>().tolistasync(); } // etc } would have impact?
i'm doing because want abstract out service core , domain model new project , utilize project between asp.net front end end , wcf service. service need utilize 1 entity @ moment maybe increased @ later date.
i point out, in domain entity, if reference interface doesn't created in database column.
so don't think can done, , keith payne said, on complicates it.
c# asp.net-mvc entity-framework wcf
No comments:
Post a Comment