I need to convert static query of complex model binding to the dynamic LINQ query in controller action to get data from database through EF
This is my Model
- public class DepartmentViewModel
- {
- public int DepartmentId { get; set; }
- public string Name {get; set;}
- public List
stdList { get; set; } - public DepartmentViewModel()
- {
- stdList = new List
(); - }
- }
- public class StdListModel
- {
- public int ID { get; set; }
- public string Name { get; set; }
- }
- public ActionResult Index()
- {
- List
list = new List (); - DepartmentViewModel dept = new DepartmentViewModel();
- dept.DepartmentId = 1;
- dept.Name = "Department 1";
- dept.stdList.Add(new StdListModel() { ID = 1, Name = "Some Name" });
- dept.stdList.Add(new StdListModel() { ID = 2, Name = "Another Name" });
- list.Add(dept);
- return View(list);
- }
Ashutosh GuptaPosted Dec 10, 2019, 3:37 AM
ribha shakoorPosted Dec 10, 2019, 3:32 AM
Jenith ThakkarPosted Nov 13, 2019, 12:37 AM