c# - How to use stored procedure in EF by using uow pattern? -
i have interface name iunitofwork
in datalayer
:
public interface iunitofwork { idbset<tentity> set<tentity>() tentity : class; int savechanges(); ilist<tentity> sqlqueries<tentity>( string _sql ) tentity : class; }
and context
:
public class context : dbcontext, iunitofwork { public dbset<slider> myslider { get; set; } public new idbset<tentity> set<tentity>() tentity : class { return base.set<tentity>(); } public ilist<tentity> sqlqueries<tentity>( string _sql ) tentity : class { return base.database.sqlquery<tentity>(_sql).tolist(); // use 'tolist()' here or not?? } }
and in service
have:
public interface islider { ilist<domainmodel.slider> slidergetall(); }
and :
public class slider:islider { iunitofwork _uow; idbset<domainmodel.slider> _slider; ilist<domainmodel.slider> _slider2; public slider( iunitofwork uow ) { _uow=uow; _slider = _uow.set<domainmodel.slider>(); } public ilist<domainmodel.slider> slidergetall() { var slide=_uow.sqlqueries<domainmodel.slider>("slidergetall"); return slide; } }
it's working in way, want know way use stored procedure
?
note: used structure map di.
Comments
Post a Comment