You could use a PredicateBuilder (LinqKit) var predicate=PredicateBuilder.False<Person>();
foreach(var subquery in listOfIQueryablePerson) { predicate = predicate.Or(p=>subquery.Contains(p.id)) } var combinedIQueryable = allPersons.Where(predicate); 2016-02-29 9:32 GMT+01:00 <jmeru...@gmail.com>: > Hi Oskar, > thanks for your response. Sorry, I forgot one thing to mention. > In the part of code where I need to combine the IQueryable I have got some > external objects in a list which provide methods which return the > IQueryable to combine. > So I have s.th. like this: > > foreach(var subquery in listOfIQueryablePerson) > { > combinedIQueryable = from p allPersons > where subquery.Contains(p.id) > || combinedIQueryable.Contains(p.id); > } > > The code above fits my requirements but it is not very nice and hasn't a > good performance. Is there any other solution for that? > > Thanks > > > > > Am Freitag, 26. Februar 2016 12:39:38 UTC+1 schrieb Oskar Berggren: >> >> var q1 = from p in Person >> where whatever >> select p.id; >> >> >> var q2 = from p in Person >> where whatever >> select p.id; >> >> >> var qC = from p in Person >> where q1.Contains(p.id) || q2.Contains(p.id) >> select p; >> >> q1 and q2 will be used as subqueries when the SQL is formed. >> >> /Oskar >> >> >> >> 2016-02-26 10:25 GMT+00:00 <jmer...@gmail.com>: >> >>> Hi all, >>> is there a possibility to combine several IQueryable without execute the >>> query? >>> >>> Pseudocode: >>> >>> var q1 = (IQueryable<Person>).....;var q2 = (IQueryable<Person>).....; >>> >>> >>> var q = q1.Union(q2); >>> >>> >>> or >>> >>> SELECT * >>> FROM Table1 >>> WHERE id IN >>> (Result ids of IQueryable1) >>> OR >>> (Result ids of IQueryable2) >>> >>> I achieved a solution by using Disjunction of Queryover. As result I >>> need an IQueryable without the query has been executed. So a solution can >>> also be if it is possible to convert IQueryover to IQueryable. >>> >>> Thanks in advance >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "nhusers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to nhusers+u...@googlegroups.com. >>> To post to this group, send email to nhu...@googlegroups.com. >>> Visit this group at https://groups.google.com/group/nhusers. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to nhusers+unsubscr...@googlegroups.com. > To post to this group, send email to nhusers@googlegroups.com. > Visit this group at https://groups.google.com/group/nhusers. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+unsubscr...@googlegroups.com. To post to this group, send email to nhusers@googlegroups.com. Visit this group at https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.