Gcobani54
Member
- Joined
- Apr 26, 2021
- Messages
- 7
- Programming Experience
- 3-5
Hi Team
I need some help in joining three entities using linq, i have one join but the problem i have i am getting a repetion of years, weekNum and day colums with data being incorrect.
I need some help in joining three entities using linq, i have one join but the problem i have i am getting a repetion of years, weekNum and day colums with data being incorrect.
Using Linq to join 3 entities:
public IList<ExtractionViewModel> GetExtractionViewModels(string year, int week)
{
ProductionManagementEntities db = new ProductionManagementEntities();
var scheduleList = (from p in db.ProductionDays
join w in db.Weeks
// join m in db.Models somewhere here to prevent duplicate records
on p.WeekId equals w.WeekId
orderby w.Year ascending
orderby w.WeekNum ascending
where (w.WeekNum == 5)
select new ExtractionViewModel
{
Day = p.ProductionDate,
Week = w.WeekNum,
// Model = m.Name,
Year = w.Year
}).ToList();
return scheduleList;
}
public class ExtractionViewModel
{
public string Year { get; set; }
public int Week { get; set; }
[DataType(DataType.Date)]
public DateTime Day { get; set; }
// public string VW240 { get; set; }
public string VW250 { get; set; }
public string VW270 { get; set; }
public string VW2502PA { get; set; }
public string VW270PA { get; set; }
}