TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
2.1k
467.3k
Formatting of excel data to correspond to your table records
Apr 28 2021 1:11 PM
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
// 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
Reply
Answers (
3
)
Web Api login Email or Phone number at a time
Convert Picture slide from HTML & Javascript to a ASP version