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
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
- // Main problem is calling of these record to get correct data prior to the records when doing a sql query to the db. Yet no records logic cater for if there are not any(year, week)
- 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
Rijwan AnsariPosted Apr 29, 2021, 3:54 PM
Guest UserPosted Apr 29, 2021, 3:42 PM
Rijwan AnsariPosted Apr 29, 2021, 3:09 PM