Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 views
in Technique[技术] by (71.8m points)

linq - How to merge result IQueryable<T> 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:

var q1 = (IQueryable<Person>).....;
var q2 = (IQueryable<Person>).....;

how to merge q1 and q2 together and get result like

var q = (IQueryable<Person>)q1.Union(q2);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have it, q1.Union(q2). The Union is in the System.Linq namespace with Queryable.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...