c# - join two repository pattern with getwithinclude method -
i learning unitofwork, repository pattern , in genericrepository file have method , not sure how use in real example.
/// <summary> /// include multiple /// </summary> /// <param name="predicate"></param> /// <param name="include"></param> /// <returns></returns> public iqueryable<tentity> getwithinclude(system.linq.expressions.expression<func<tentity, bool>> predicate, params string[] include) { iqueryable<tentity> query = this.dbset; query = include.aggregate(query, (current, inc) => current.include(inc)); return query.where(predicate); } for example if have 2 repositories rep1,rep2 foreignkey relationship join 2 repositories , output list, know how details single repository.
public ienumerable<crentity> getallcr() { var mapper = createmapper(); var crall = _unitofwork.rep1.getall().tolist(); //var joinfd = _unitofwork.rep1.getwithinclude(); ---how add rep2 using getwithinclude if (crall.any()) { var crmodel = mapper.map<list<changerequest>, list<crentity>>(crall); return crmodel; } return null; }
Comments
Post a Comment