I want to get two table combine data using linq c# lambda expression and get fix number of column get in the list. I have try this code but I don't know how to write query in linq lambda expression.
this is my method:
public ActionResult GetUserList(string searchRequest)
{
List<User> userList = new List<User>();
if (searchRequest != null)
{
if (searchRequest == "All")
{
// here i want to write select query but how i don't know
userList = db.user.ToList();
}
else if (searchRequest == "Flight")
{
userList = db.user
.Where(t => t.type_id == (int)ServiceTypeEnum.Flight)
.ToList();
}
}
return Json(new { data = userList });
}
any one have the idea about this query then please let me know how can do.
db.user.Select(x=> new {x.Col1,x.Col2}).ToList();