我遇到了一个必须使用 Union all 的场景,我如何在 LINQ to entity 中实现它?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.