如何动态指定关联表的别名?
#1458
-
.InnerJoin((t, t1) => t.TaskId == t1.TaskId && t1.PropertyCode == pDetail.PropertyCode && t1.PropertyValue == pDetail.PropertyValue.ToString());如何动态指定t1的别名?因为这段join代码在一个foreach中 |
Beta Was this translation helpful? Give feedback.
Answered by
2881099
Mar 14, 2023
Replies: 2 comments 1 reply
-
仅供参考
|
Beta Was this translation helpful? Give feedback.
1 reply
-
动态 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 }); |
Beta Was this translation helpful? Give feedback.
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
动态 Join,使用导航属性会方便一些。
有导航属性,返回的依然是 ISelect<T>,排序、ToList 都比较方便,如下:
没有导航属性,返回的是 ISelect<T> 或者 ISelect<T, T1>