Hi Team
I have a method that does linq in sql to retrieve data and currently it does. But the issue my records on excel when downloaded are duplicating and no logic if there is no records. When i ran query on the db records, year and weekNum i dont get but my mvc application is duplicating this and need some help.
- public IList<ExtractionViewModel> GetExtractionViewModels()
- {
- int Count;
- var db = new ProductionManagementEntities();
- var scheduleList = (from p in db.ProductionDays
- from m in db.Models
- from mx in db.Models
- from mt in db.Models
- from mv in db.Models
- from wk in db.Models
- join w in db.Weeks on p.WeekId equals w.WeekId
- orderby w.Year descending , m.Name descending, p.CreatedDate descending, w.WeekNum descending, mt.Name descending, mx.Name descending, mv.Name descending
-
-
- where (mx.InActive == true)
- where (mt.InActive == false)
- where(m.InActive == false)
- where(mv.InActive == false)
- where (mt.Name == "VW270")
- where(mx.Name == "VW250")
- where(m.Name == "VW270PA")
- where(mv.Name == "VW250/2PA")
- select new ExtractionViewModel
- {
- Year = w.Year,
- Day = p.CreatedDate,
- Week = w.WeekNum,
- VW270 = mt.Name,
- VW270PA = m.Name,
- VW250 = mx.Name,
- VW2502PA = mv.Name,
- }).ToList();
- return scheduleList;
- }
- SELECT TOP (1000) [WeekId]
- ,[WeekNum]
- ,[Year]
- ,[CreatedDate]
- ,[CreatedBy]
- ,[ModifiedDate]
- ,[ModifiedBy]
- ,[InActive]
- FROM [ProductionManagement].[Schedule].[Week]
- where WeekNum = 53
- order by YEAR
-
- SELECT TOP (1000) [ProductionDayId]
- ,[WeekId]
- ,[ProductionDate]
- ,[DayOfWeek]
- ,[CreatedDate]
- ,[CreatedBy]
- ,[ModifiedDate]
- ,[ModifiedBy]
- ,[InActive]
- FROM [ProductionManagement].[Schedule].[ProductionDay]
- Order by ProductionDate