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
470.7k
How to join three tables using join in entity framework?
Apr 21 2021 9:56 PM
How to join three tables in entity framework, i have two different models. My logic is as follows i am bit stuck.
public
class
ExtractionViewModel
{
public
DateTime Year {
get
;
set
; }
public
int
Week {
get
;
set
; }
public
DateTime Day {
get
;
set
; }
public
string
Model {
get
;
set
; }
}
public
partial
class
WeekDetail: IEntity
{
public
System.Guid WeekId {
get
;
set
; }
public
int
WeekNum {
get
;
set
; }
public
string
Year {
get
;
set
; }
public
Nullable<
int
> ScheduleTotal {
get
;
set
; }
public
System.DateTime CreatedDate {
get
;
set
; }
public
string
CreatedBy {
get
;
set
; }
public
System.DateTime ModifiedDate {
get
;
set
; }
public
string
ModifiedBy {
get
;
set
; }
public
bool
InActive {
get
;
set
; }
public
IList<ExtractionViewModel> GetExtractionViewModels()
{
ProductionManagementEntities db =
new
ProductionManagementEntities();
var scheduleList = (from s
in
db.Schedules
join w
in
db.WeekDetails on
select
new
ExtractionViewModel
{
Year = s.ModifiedDate,
Week = s.
}).ToList();
return
scheduleList;
}
public
ActionResult ExportToExcel()
{
var v =
new
GridView();
// v.DataSource = this.GetExtractionViewModels();
v.DataBind();
Response.ClearContent();
Response.Buffer =
true
;
Response.AddHeader(
"content-disposition"
,
"attachment; filename=ExtractionRecords.xls"
);
Response.ContentType =
"application/ms-excel"
;
Response.Charset =
""
;
StringWriter objStringWriter =
new
StringWriter();
HtmlTextWriter htmlTextWriter =
new
HtmlTextWriter(objStringWriter);
v.RenderControl(htmlTextWriter);
Response.Output.Write(objStringWriter.ToString());
Response.Flush();
Response.End();
return
View(
"List"
);
}
Reply
Answers (
2
)
Best Architecture for asp.net MVC and webapi
Edit in razor pages. pagemodel and methods etc. by using ado, crud, RP