如何两个数据源组合成一个? [英] how to combine two data source into one?
本文介绍了如何两个数据源组合成一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个表,和1对象记录, 我想要从两个表中的数据为1的GridView,(两个表具有相同的字段),我不能加入,因为我需要显示所有的行
这是我的code:
VAR的查询=从所有DB.Movies
其中,all.IsActive
选择新MoviesObject
{
PHOTOID = all.PhotoId,
标题= all.Title,
说明= all.ShortDescription
};
VAR querytwo =所有在DB.movieslisttwo
其中,all.IsActive
选择新MoviesObject
{
PHOTOID = all.PhotoId,
标题= all.Title,
说明= all.ShortDescription
;
返回query.ToList();
解决方案
返回query.Concat(query2).ToList();
另外,您也可以致电 .Union()
跳过重复。
i have records in two tables, and 1 object, i want to retrieve data from both tables into 1 gridview, (both tables have same fields) i can not have joins because i need to show all rows
here is my code:
var query = from all in DB.Movies
where all.IsActive
select new MoviesObject
{
PhotoId = all.PhotoId,
Title = all.Title,
Description = all.ShortDescription
};
var querytwo = from all in DB.movieslisttwo
where all.IsActive
select new MoviesObject
{
PhotoId = all.PhotoId,
Title = all.Title,
Description = all.ShortDescription
;
return query.ToList();
解决方案
return query.Concat(query2).ToList();
Alternatively, you can call .Union()
to skip duplicates.
这篇关于如何两个数据源组合成一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文