KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am accessing a remote data source and found that a group join causes an IQueryable query to be transformed into an IEnumerable, question: will this affect performance? I want to offload as much of the query to the database as possible, and not execute anything in memory... var allusers = repo.All<User>().Where(x => x.IsActive); var _eprofile = repo.All<Profile>() .Where(x => x.IsProfileActive) .Join(allusers, x => x.UserID, y => y.UserID, (x, y) => new { eProfile = x, profile = y }) .GroupJoin(_abilities, x => x.eProfile.ID, y => y.ID, (x, y) => new QuoteDTO { UserID = x.profile.Login, Email = x.profile.Email, Tel = x.profile.Tel, Mobile = x.eProfile.Mobile, CompanyID = x.profile.CompanyID, Ability = y.Select(c => new AbilityDTO { Name= c.Name }) }); The line: .GroupJoin( _abilities , x => x.eProfile.ID, y => y.ID, (x, y) => new QuoteDTO _abilities is an IQueryable, I get the ability of a user, a collection of objects the second part (x,y) - here y gets transformed into an IEnumerable... var cLists = List<int>(); //this collection is populated from the client code, lets say it //contains 1,3,55 for arguments sake... var _abilities= repo.All<UserAbility>() .Where(x => x.Status == Status.Active.ToString()) .Where(x => cLists.Contains(x.CompetencyID)); NOTE: the reason I use var is so that I can transform into an object of my liking, I was using a lot of anonymous types before the DTO objects were inserted...
Tags (comma-separated)
Save Edits
Cancel