Reputation:
I'm making two queries:
Dim worker = (From p in db.workers where p.dateAdded > today
select new with{.name = p.name, .desc = p.description})
Dim client = (From p in db.clients where p.dateAdded > today
select new with{.name = p.name, .desc = p.description})
How can I merge those two queries to have only one I can use as DataSource
.
Upvotes: 0
Views: 794
Reputation: 1867
Can you specify what exactly you want to do?
1. Merge the results in one set - if yes, you can use huMpty duMpty's proposal
2. If you want to do something similar to DataSet with two DataTables with Linq query I'm not sure if this is achievable.
Hope this helps!
Upvotes: 0
Reputation:
Use Union
which provides your expected result.
Have look at Return the Set Union of Two Sequences (LINQ to SQL)
Upvotes: 0
Reputation: 14470
Try something like this
Dim Merged = (From p in db.workers where p.dateAdded > today
select new with{.name = p.name, .desc = p.description})
.Union
(From p in db.clients where p.dateAdded > today
select new with{.name = p.name, .desc = p.description})
Upvotes: 2
Reputation: 20745
Use Distinct
if want to get distinct result.
var merged = worker.Concat(client).Distinct();
or
var mergedList = worker.Union(client).ToList();
Upvotes: 1