how to rotate around each record in linq and show that in view
- by Sadegh
Hi, I have four tables in my database and i want to join that's and return record's and show that into searchController!
My query is this:
public IQueryable PerformSearch(string query)
{
if (!string.IsNullOrEmpty(query))
{
var results = from tbl1 in context.Table1
join tbl2 in context.Table2 on tbl1.Id equals tbl2.Id
join tbl3 in context.Table3 on tbl2.Id equals tbl3.Id
join tbl4 in context.Table4 on tbl3.Id equals tbl4.Id
where tbl1.col2.Contains(query)
orderby tbl1.Count descending
select new
{
col1 = tbl1.Col1,
col1 = tbl1.Col1,
col1 = tbl1.Col1,
.
.
.
};
return results.AsQueryable();
}
else return null;
}
And this method called in SearchController as below:
public class SearchController : System.Web.Mvc.Controller
{
public System.Web.Mvc.ActionResult Search(System.String query)
{
var search = new Search();
ViewData["result"] = search.PerformSearch(query);
return View("Search");
}
}
I don't know how i can rotate around each record (plus vs intellisense feature) returned by PeformSeach method and show that in view! Also is this a good way?
thanks in advance