编译查询的.cs代码是
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
如果我想在此编译器查询中的2个表之间进行内连接,我该怎么办
假设1个表名是editor_j_inf而另一个是editor_j_inf1。如何在这2个表之间进行内部联接
我试过把
public static Func<DataClassesDataContext, string, int, int, IQueryable<A>>
getjournal2 = CompiledQuery.Compile((DataClassesDataContext db, string a, int b, int c) =>
from p in db.editor_j_infs
join p1 in db.editor_regs on p.editor_id equals p1.editor_id
where p.j_email == a && p1.confirm1 == b && p1.denied == c
orderby p.ed_journal_id descending
select new A{Title= p.j_title,EditorId= p.editor_id,EditorId1=p.ed_journal_id });
Public class A
{
public string Title {get;set;}
public int EditorId {get;set;}
public int EditorId1 { get; set;}
}
public void getjournals()
{
string email="abc@gmail.com";
var rr1 = getjournal2(db, email,1,0).ToList();
var rrlist = rr1.ToList();
if (rrlist.Count() != 0)
{
DataList1.DataSource = rr1;
DataList1.DataBind();
}
}
现在如何使用datalist进行绑定?
答案 0 :(得分:0)
试试这个: -
from p1 in db.editor_j_inf
join p2 in db.editor_j_inf1
on new { p1.ed_journal_id , p1.column2}
equals new { p2.ed_journal_id , p2.column2}
select p1.column1 + " " + p1.column2;
答案 1 :(得分:0)
您需要使返回类型和实际返回对应。如果您需要string
make Func<DataClassesDataContext, int, IQueryable<string>>
并使用
完成查询 select new {p.j_title}
甚至是select p.j_title
。如果您需要editor_j_inf
,请按原样保留函数声明,并使用select p