Click here to Skip to main content
15,885,043 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
HI team

I need some help, i have a problem. I want to filter records on my excel sheets as data. Now i dont know how sessions works to export data as excel. Below is my logic i have attempted to join tables using linq. Some how the data itself on excel is not filtering correct values. e.g if i search by YEAR(2021) and Week(53) on query get record this. On the excel itself its not corresponding to my query and need help to it via session.

What I have tried:

public IList GetExtractionViewModels()  
{  
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.ProductionDate 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(w.WeekNum < 53)  
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.ProductionDate,  
Week = w.WeekNum,  
VW270 = mt.Name,  
VW270PA = m.Name,  
VW250 = mx.Name,  
VW2502PA = mv.Name  
}).ToList();  
return scheduleList;  
}  


// model    
public class ExtractionViewModel    
{    
    public string Year { get; set; }   
    public int Week { get; set; }  
    [DataType(DataType.Date)]    
    public DateTime Day { get; set; }  
    public string VW250 { get; set; }  
    public string VW270 { get; set; }   
    public string VW2502PA { get; set; }    
    public int VW270PA { get; set; }    
} 


// Sql for Model  
SELECT TOP (1000) [ModelId]  
      ,[Name]  
      ,[Code]  
      ,[CreatedDate]  
      ,[CreatedBy]  
      ,[ModifiedDate]  
      ,[ModifiedBy]  
      ,[InActive]  
  FROM [ProductionManagement].[Schedule].[Model]  
  where Name = 'VW240'  
  order by InActive 


//Week table  
  
SELECT TOP (1000) [WeekId]  
      ,[WeekNum]  
      ,[Year]  
      ,[CreatedDate]  
      ,[CreatedBy]  
      ,[ModifiedDate]  
      ,[ModifiedBy]  
      ,[InActive]  
  FROM [ProductionManagement].[Schedule].[Week]  
  
// ProductionDate  
SELECT TOP (1000) [ProductionDayId]  
      ,[WeekId]  
      ,[ProductionDate]  
      ,[DayOfWeek]  
      ,[CreatedDate]  
      ,[CreatedBy]  
      ,[ModifiedDate]  
      ,[ModifiedBy]  
      ,[InActive]  
  FROM [ProductionManagement].[Schedule].[ProductionDay]  
Posted
Comments
Richard Deeming 29-Apr-21 10:20am    
There's nothing in the code you've shown which attempts to use a "session". Update your question to provide a clear and complete description of the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900