Jul 30, 2015

How to merge result IQueryable together?

If I get two result IQueryable from different linq Query and I want to merge them together and return one as result, how to to this? For example, if:

int[] i1 = new int[] { 1, 2, 3 };
int[] i2 = new int[] { 3, 4 };
//returns 5 values
var i3 = i1.AsQueryable().Concat(i2.AsQueryable());
//returns 4 values
var i4 = i1.AsQueryable().Union(i2.AsQueryable());
Union will only give you the DISTINCT values, Concat will give you the UNION ALL.


No comments:

Post a Comment