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
474.5k
How to extract data correctly using linq sql in asp.net mvc 5?
Apr 26 2021 4:43 PM
SELECT
TOP
(1000) [WeekId]
,[WeekNum]
,[
Year
]
,[CreatedDate]
,[CreatedBy]
,[ModifiedDate]
,[ModifiedBy]
,[InActive]
FROM
[ProductionManagement].[Schedule].[Week]
where
WeekNum = 53
order
by
Year
Hi team
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.
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
; }
}
Reply
Answers (
12
)
How to export file to excel in linq sql using asp.net mvc
internal connection fatal error in c#