Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var query = from p in db.Payments
- where p.Status == false
- && DateTime.Compare(DateTime.Now, p.NextPaymentDate.Value) == 1
- group p by p.CompanyID into op
- select op.OrderByDescending(nd => nd.NextPaymentDate.Value).FirstOrDefault();
- var query = from p in db.Payments
- where p.Status == false
- group p by p.CompanyID into op
- select new {
- CompanyID = op.Key,
- NextPaymentDate = op.Max(x => x.NextPaymentDate),
- Status = false
- };
- I need to do the same. But in Datacontext. And i need to join three tables.
- var year = dContext.Reviews.Max(a => a.Year);
- var awardsList = dContext.Awards
- .Join(dContext.Reviews, a => a.ReviewId, r => r.Id, (a, r) => new { a, r })
- .Join(dContext.CompanyInfoes, cr => cr.r.CompanyInfoId, ci => ci.Id, (cr, ci) => new { cr.a, cr.r, ci })
- .Where(pcu => !(pcu.r.IsDeleted.HasValue && pcu.r.IsDeleted.Value)).Select(p => new AwardsAndComplianceModel()
- {
- YearOfReview = year,
- CompanyName = p.ci.Name,
- ReportStatus = p.r.Status,
- Id = p.ci.Id,
- CompanyProfileId = p.ci.Id,
- AwardsComplianceTitle = p.a.Title,
- AwardedBy = p.a.AwardedBy,
- Date = p.a.Date,
- Country = p.a.Country,
- Remarks = p.a.Remarks`enter code here`
- }).ToList();
- After this i have to check not null condition for each record also
Add Comment
Please, Sign In to add comment