But is that all? In your previous example you hade multiple
expressions in listOfIQueryablePerson.
If that's not the case, a predicate builder may be unnecessary.

You can't use  PredicateBuilder.True<Class>() and predicate.Or, since if
you do the expression will always evaluate to true. Use  PredicateBuilder.
*False*<Class>();

/G

2016-03-01 15:34 GMT+01:00 <[email protected]>:

> Thank you Gunnar. That's a good idea. There is only one thing which does
> not work yet. The two (or more) IQueryable are not combined via "OR" but
> via "AND"
>
> Now:
>
> SELECT *
> FROM bla as b
> WHERE b.Value = 20
>        and (1 /* @p3 */ = 1
>              or b.Id in (SELECT ....)
>
>
> But it should:
>
> SELECT *
> FROM bla as b
> WHERE b.Value = 20
>        OR (1 /* @p3 */ = 1
>              or b.Id in (SELECT ....)
>
>
> This condition is created by PredicateBuilder.True<Class>()
> 1 /* @p3 */ = 1
>
>
> Code:
> var predicate = PredicateBuilder.True<Class>();
> predicate = predicate.Or(p => object.ExtendQuery().Select(x =>
> x.Id).Contains(p.Id));
> var combinedIQueryable = allUserNotes.Where(predicate);
>
>
>
>
> Am Montag, 29. Februar 2016 15:29:41 UTC+1 schrieb Gunnar Liljas:
>>
>> 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 <[email protected]>:
>>
>>> 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 <[email protected]>:
>>>>
>>>>> 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 [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> 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 [email protected].
> To post to this group, send email to [email protected].
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to