联合查询是否可新增类型转换
#1792
Replies: 1 comment 2 replies
-
看下嵌套查询文档 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
需求: 综合分页查询多个表(不是联表查询或子查询),表的字段不完全一致,需要做类型映射
实体 RowItem 最后查询后返回的对象
public class RowItem{
public string Zl {set;set}
}
实体 ZRZ 要查询的表1 ,其中字段 Lzzl 需要映射到 RowItem的Zl上
public class ZRZ{
public string Lzzl{set;set}
}
实体 H 要查询的表2
public class H{
public string zl {set;set}
}
对应的sql语句
select Zl from(
select Lzzl zl from ZRZ where Lzzl like '%1%'
union all
select zl from Hwhere zl like '%1%'
) b
期望C# 代码可以实现类似的类型转换
fsql.Select()
.UnionAll(
fsql.Select().Where(a => a.Lzzl.Contains(condition.Zl)).AsType(a =>
{
Zl = a.Lzzl
}),
fsql.Select().Where(a => a.Zl.Contains(condition.Zl)).AsType()
)
.Page(1,20);
Beta Was this translation helpful? Give feedback.
All reactions