How can I do a Union all in Entity Framework LINQ To Entities?

不羁岁月 提交于 2019-12-01 02:07:28

Here is the answer you are looking for. Use the Concat keyword.

From the example:

var query = (from x in db.Table1 select new {A = x.A, B = x.B})
    .Concat( from y in db.Table2 select new {A = y.A, B = y.B} );

I believe Concat is what you're looking for.

var allResults = resultSet1.Concat(resultSet2);

Obviously, both result sets must use the same type. And I believe there my be other requirements about how the result sets are constructed in the first place, but I don't know all the details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!