Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team

I have a problem, my data on excel is duplicating data. While on the front end it does not. For example if i search by year 2020 and week 52 . Front end shows no record. But my excel keeps duplicating any year and record closer to that year.

What I have tried:

ASP.NET
<pre>   public IList<ExtractionViewModel> GetExtractionViewModels()
        {
            
             var db = new ProductionManagementEntities();

            var scheduleList = (from p in db.ProductionDays
                                from m 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 
                                where(m.InActive == true)

                                select new ExtractionViewModel
                                {

                                    Year = w.Year,
                                    Day = p.ProductionDate, 
                                    Week = w.WeekNum,
                                    VW250 = m.Name,
                                    VW270 = m.Name,
                                    VW2502PA = m.Name,
                                    VW270PA = m.Name


                                }).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 VW250 { get; set; }

      public string VW270 { get; set; }

      public string VW2502PA { get; set; }

      public string VW270PA { get; set; }
  }


// SQL tables for both ProductionDays and Weeks
SELECT TOP (1000) [ProductionDayId]
      ,[WeekId]
      ,[ProductionDate]
      ,[DayOfWeek]
      ,[CreatedDate]
      ,[CreatedBy]
      ,[ModifiedDate]
      ,[ModifiedBy]
      ,[InActive]
  FROM [ProductionManagement].[Schedule].[ProductionDay]
  Order by ProductionDate


SELECT TOP (1000) [WeekId]
      ,[WeekNum]
      ,[Year]
      ,[CreatedDate]
      ,[CreatedBy]
      ,[ModifiedDate]
      ,[ModifiedBy]
      ,[InActive]
  FROM [ProductionManagement].[Schedule].[Week]
Posted
Updated 28-Apr-21 2:20am
v2
Comments
Richard Deeming 27-Apr-21 3:53am    
You're missing a join condition between ProductionDays and Models, so you'll get the cross-product of both tables.

Beyond that, we have no access to your database, so we cannot help you with this problem. You need to debug your code to work out the difference between your front-end query and your Excel query.
Gcobani Mkontwana 2021 28-Apr-21 8:21am    
Richard i have attached here on the topic queries for both tables

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