I have applied linq to sql in my project and it's taking a lot of time so I made a search to make it speedy and i have searched and took a reference from here
And my .cs code is
public static Func<DataClassesDataContext, int, IQueryable<editor_j_inf>>
editordetail1 = CompiledQuery.Compile((DataClassesDataContext db, int a) =>
from p1 in db.editor_j_infs
where p1.ed_journal_id == a
orderby p1.editor_id descending
select p1); //Its my precompile process
public void editordetail()
{
DataClassesDataContext db = new DataClassesDataContext();
var rr = editordetail1(db,Convert.ToInt32(Server.HtmlEncode(Request.Cookies["j_id"].Value)));
}
and its working fine but what should i do if i wanna pass 2 or 3 values in compiled queries suppose my select queries is
public void editordetail()
{
DataClassesDataContext db = new DataClassesDataContext();
var rr = from p in db.tbl_desc_indexes
where p.ed_journal_id == 1 && p.j_id==2 && p.j_id1==3
select p
}
How should i make compiled queries for this ??
That being said, have you profiled your database queries? Maybe you need to improve your indexes? Or maybe you need to redesign the application, such that it needs to do less queries?