I need some help and i have a problem the problem, the issue i have my excel data its duplicating a year, week column. e.g if data is available for 2021 its counting on week 2 as 2021 2, 2, 3. How do i fix this issue and must check if there is no data available for a specific year and week.
Can u share the query for Models entity as well, just like u gave for week and production days? I can chk whats to join on
Also, u can try this: break your steps into 2.
Step 1 : use the linq to get data in the list by joining the three entities. Your data shouls look something like this:
{
2021, 36, model1,etc
2021, 35, model2,etc
2021, 35, model3,etc
2021, 34, model4,etc
2021, 33, model4
}
Etc.
Step 2: now iterate thru the above list and get to arrange the items in your extractionView. I.e.
Foreach (item in aboveList)
{
Yr = item.year;
Wk = item.week;
Dt = item.etc field;
Switch (item.model)
Case model1: model1= item.model or count;
Case model2: model2= item.model or count;
So on
}
Hi, i see you are using three entities - productuonDays, Weeks and Models. But you havn't joined the Models entity with the other two. Also, are you looking a output like this ?
Yr : week : model1 : model2 : model3
2021 : 34 :. Y. :. :
2021 : 33 :. :. Y. :. Y
2021.: 32.:. Y. :. Y. :.
2021 : 31 :. Y. : Y. :. Y?
The first linq query i can seem to understand, but the problem now im using model to interact with my database record. Therefore if i am using into must now decide which record, to allow defaultIfEmpty() method.
Start with the linq object of weeks and put other details in the left join .
i.e. if there is no data for a (year + week) combination, then it should return you empty row.
from c in categories
join p in products on c equals p.Category into ps
from p in ps.DefaultIfEmpty()
The DefaultIfEmpty() makes it Left outer join.
Re create your query using the above tip. It should probably fix the first issue. Incase not, then to get the distinct (year+week) combination, you can use the groupBy clause. Below is an example.
var distinctYrWeekSet = totalRecordSet.GroupBy(item => new { item.Year, item.Week }).Select(group => group.First()).ToList();
Debarshi ChakrabortyPosted Apr 28, 2021, 5:59 PM
Guest UserPosted Apr 28, 2021, 5:01 PM
Debarshi ChakrabortyPosted Apr 28, 2021, 4:16 PM
Guest UserPosted Apr 28, 2021, 2:01 PM
Guest UserPosted Apr 28, 2021, 1:49 PM
Debarshi ChakrabortyPosted Apr 28, 2021, 1:38 PM
Guest UserPosted Apr 28, 2021, 1:19 PM
Debarshi ChakrabortyPosted Apr 28, 2021, 1:13 PM
Guest UserPosted Apr 28, 2021, 12:01 PM
Rijwan AnsariPosted Apr 27, 2021, 8:41 AM
Guest UserPosted Apr 26, 2021, 7:46 PM
Debarshi ChakrabortyPosted Apr 26, 2021, 7:37 PM