TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sam King
NA
50
11.5k
Understand repository functions
Jul 26 2017 1:57 AM
Hello Folks,
I am learning UnitofWork ,Repository pattern and in the genericrepository.cs file i have a method like this and i am not sure how to use that 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 we have two repositories rep1,rep2 with a foreignkey relationship will this join two repositories and output it to a list
public IEnumerable<CREntity> GetAllCR()
{
var mapper = CreateMapper();
var CRAll = _unitOfWork.Rep1.GetAll().ToList();
//var joinFD = _unitOfWork.Rep1.GetWithInclude(); ---how to add Rep2 using getwithinclude
if (CRAll.Any())
{
var CRModel = mapper.Map<List<ChangeRequest>, List<CREntity>>(CRAll);
return CRModel;
}
return null;
}
Reply
Answers (
0
)
MVC validation to select unique value from drop down list c#
calling another exe from my c#code