Linq UNION: not implemented?

27 views
Skip to first unread message

Giulio Petrucci

unread,
Jun 21, 2011, 12:14:24 PM6/21/11
to nhu...@googlegroups.com
Hi there,

I'm working with NH 3.0.0.4 and I need to perform a UNION, anyway it
seems to be not implemented. Could you link me where I can see if it
has been implemented in any more recent release?

Thanks,
Giulio

--

Ramon Smits

unread,
Jun 21, 2011, 2:19:59 PM6/21/11
to nhu...@googlegroups.com

I don't know what kind of query you want to create but you can ofcourse to multiple future queries and executes all of them in one roundtrip. Can you provide more details of the query you want to make?


--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.




--
Ramon

Darren Kopp

unread,
Jun 21, 2011, 3:31:15 PM6/21/11
to nhu...@googlegroups.com
Future queries only work if you don't want to filter the output of the union result (especially when the results could be large) as well as you can't do paging on the results either.

Giulio Petrucci

unread,
Jun 22, 2011, 3:48:19 AM6/22/11
to nhu...@googlegroups.com
Hi everybody,

first of all thanks to the guys who replied me.
I'll describe a little more my problem so maybw someone can give me an
hint helping me to reach "the idea" I'm lacking.

class Bar {
Foo Foo { get; set; }
}

abstract class Foo { }
class A : Foo { }
class B : Foo { }
class C : Foo { }

Given some criteria from the application user I need to:
1. select all the A matching the criteria
2. select all the B matching the criteria
3. select all the C matching the criteria
4. perform a UNION on them
5. select all the Bar whose .Foo is in the selection coming from 4 via a JOIN

Could you suggest me any way to do such stuff using LINQ?

Thanks in advance,
Giulio

--

cremor

unread,
Jun 22, 2011, 5:18:24 AM6/22/11
to nhusers
Can't you just use the following?

var result = session.Query<Bar>().Where(x => x.Foo.Something ==
"something").ToList();

Giulio Petrucci

unread,
Jun 22, 2011, 5:47:27 AM6/22/11
to nhu...@googlegroups.com
On Wed, Jun 22, 2011 at 11:18 AM, cremor <cre...@gmx.net> wrote:
> Can't you just use the following?
>
> var result = session.Query<Bar>().Where(x => x.Foo.Something ==
> "something").ToList();

uhm... maybe I should have written something more. My bad. :-(
Let's say my hierarchy is more like this:

abstract class Foo {
string Something { ... }
}
class A : Foo {
string Label { ... }
}
class B : Foo {
string Widget { ... }
}
class C : Foo { }

the user sets a list of strings and I have to check if Foo.Something,
A.Label, B.Widget CONTAINS any of those strings, so I have to
specialize the query clause to subtypes.

Thanks,
Giulio

--

cremor

unread,
Jun 22, 2011, 8:58:47 AM6/22/11
to nhusers
Ah, ok. I had a similar requirement some time ago and I tried to solve
it by using the "is" operator and then casting (example: .Where(x =>
x.Foo is A && ((A)x).Label == "label"), but that resulted in the
following Jira issue:
http://216.121.112.228/browse/NH-2693

Maybe you can use that when it is fixed.

On Jun 22, 11:47 am, Giulio Petrucci <giulio.petru...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages