I need to do two/three independent queries and load into the same viewmodel and pass it to the view.
here is what I am doing, but it doesnt even compile, please take a look and let me know what I am doing wrong.. Thanks
UserViewModel class has 2 parameters, title, option
e.g.
UserViewModel user= new UserViewModel ();
var model = (from a in db.Table1
where string.Equals(a.username, "bob")
select user
{ user.Title = a.Title,
user.option = 1
});
Second query
model = (from b in db.Table2
where string.Equals(b.username, "bob")
select user
{
user.Title= b.Title,
user.option= 2
});
var list = model.ToList();
return View("List",list);
This is simple queries and I know I can now put them into 1 query, but in the future It will be completely independent and I need to know how to do two/three queries and put them into one viewmodel. thanks
1 Answer