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.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");
- }