8,497
社区成员
发帖
与我相关
我的任务
分享
var q = ( from a in db.civ select a.Field).Union( from b in db.civCustom select b.Field);
代码仅供参考,没有实际编译运行
//先创建一个映射类
public class QueryEntity
{
public string id{get;set;}
public string others{get;set;}
}
//然后使用union或union all
string strSql = "select id,others from civ union all select id,others from civcustom";
//查询
using(DbContext db = new DbContext())
{
var source = db.ExecuteStoreQuery<QueryEntity>(strSql);
gridview.DataSource = source;
gridview.DataBind();
}