Skip to content

如何动态指定关联表的别名? #1458

Answered by 2881099
Mason-3 asked this question in Q&A
Discussion options

You must be logged in to vote

动态 Join,使用导航属性会方便一些。

有导航属性,返回的依然是 ISelect<T>,排序、ToList 都比较方便,如下:

class T
{
    public T1 t1 { get; set; }
}

fsql.Select<T>()
   .InnerJoin(a => a.t1.TaskId == a.TaskId && ...)
   .OrderBy(a => a.t1.code)
  .ToList(a => new { item = a, t2 = a.t1);

没有导航属性,返回的是 ISelect<T> 或者 ISelect<T, T1>

fsql.Select<T>()
    .InnerJoin<T1>((a, t1) => ...)
    .OrderBy(a => ...) //此时取 t1 较麻烦

fsql.Select<T, T1>() //泛型数量的固定,不如上面的方便
    .InnerJoin((a, t1) => ...)
    .ToList((a, t1) => new { item = a, t1 = t1 });

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Mason-3
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Mason-3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants