Created
May 17, 2023 14:19
-
-
Save hasokeric/bab707f843b2cf811afbdf16281d24f4 to your computer and use it in GitHub Desktop.
Messing Around with JOINs ResourceCal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var resourceGroupRows = Db.ResourceGroup.Where(x => x.Company == Session.CompanyID | |
&& x.Inactive == false | |
&& | |
).ToList(); | |
var resourceCalRows = Db.ResourceCal.Where(x => x.Company == Session.CompanyID | |
&& x.SpecialDay >= DateTime.Today | |
).Join(Db.ResourceGroup, | |
rc => new { rc.Company, rc.ResourceGrpID, Inactive = false }, | |
rg => new { rg.Company, rg.ResourceGrpID, rg.Inactive }, | |
(rc, rg) => rg | |
).ToList(); | |
var resourceCalRows = Db.ResourceGroup | |
.Where(rg => Db.ResourceCal.Any(rc => rc.Company == Session.CompanyID | |
&& rc.SpecialDay >= DateTime.Today | |
&& rc.ResourceGrpID == rg.ResourceGrpID | |
&& rc.Company == rg.Company | |
&& rg.Inactive == false)) | |
.ToList(); | |
var resourceCalRows = Db.ResourceCal | |
.Where(rc => rc.Company == Session.CompanyID && rc.SpecialDay >= DateTime.Today) | |
.Join( | |
Db.ResourceGroup.Where(rg => rg.Inactive == false), | |
rc => new { rc.Company, rc.ResourceGrpID }, | |
rg => new { rg.Company, rg.ResourceGrpID }, | |
(rc, rg) => rc | |
) | |
.ToList(); | |
var resourceCalRows = Db.ResourceCal | |
.Where(rc => rc.Company == Session.CompanyID && rc.SpecialDay >= DateTime.Today) | |
.Join( | |
Db.ResourceGroup, | |
rc => new { rc.Company, rc.ResourceGrpID }, | |
rg => new { rg.Company, rg.ResourceGrpID }, | |
(rc, rg) => new { ResourceCal = rc, ResourceGroup = rg } | |
) | |
.Where(joined => joined.ResourceGroup.Inactive == false) | |
.Select(joined => joined.ResourceCal) | |
.ToList(); | |
var resourceCalRows = Db.ResourceCal | |
.Where(rc => rc.Company == Session.CompanyID | |
&& rc.SpecialDay >= DateTime.Today | |
&& Db.ResourceGroup.Any(rg => rg.Company == rc.Company | |
&& rg.ResourceGrpID == rc.ResourceGrpID | |
&& rg.Inactive == false)) | |
.ToList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment