I am using MVC4 with Entity Framework 5 for a project. We have a master table named MAIN_TABLE
and have few child tables (ie: CHILD_TABLE1
, CHILD_TABLE2
, etc..)
We are facing a problem of the speed of LINQ query execution because of few filter option in these different Child Tables.
I have to write a query for filtering data from the Model using EF5. Right now we are coded based on the single filter at a time. i.e. We are checking with each filtered columns and firing the query. But its too slow. Is there any another option?
string[] strValue = filter_Values;
foreach (SelectedData selectedData in objSelectedDataCollection.DataCollection)
{
switch (selectedData.ColumnName) // This is the column name in the GridView defined
{
case "Outlook":
indlist = from jd in indlist
where jd.IND_APP_PASS_STATUS.Any(
ob => strValue.Contains(ob.Outlook))
orderby jd.Indman_ID
select jd;
break;
case "RS_TP":
indlist = from jd in indlist
where jd.IND_APP_PASS_STATUS.Any(
ob => strValue.Contains(ob.RS_TP))
orderby jd.Indman_ID
select jd;
break;
case "Code":
indlist = (from jd in indlist from jk in jd.IND_APP_PASS_STATUS where strValue.Contains(jk.Code) select jd).ToList();
break;
}
}