Hello there! I have the following model:
class A
{
public virtual int Id { get; set; }
public virtual ICollection<B> B { get; set; }
public virtual IEnumerable<C> C { get; }
}
class B
{
public virtual int Id { get; set; }
public virtual A A { get; set; }
public virtual ICollection<C> C { get; set; }
}
class C
{
public virtual int Id { get; set; }
public virtual B B { get; set; }
}
B and C are pretty standard one-to-many relation, nothing complex there.
Same thing between B and A.
The thing is, I want to select all C in A, something like this:
SELECT c.* FROM B b
LEFT JOIN C c ON c.B = b.Id
WHERE b.A = 1;
In LINQ it would be a normal SelectMany:
var c = a.B.SelectMany(x => x.C);
Is it possible to map in NHibernate HBM so it does something like that? I don't
want a distinct relation between
A and C, but still there are use cases when you want all C that belongs to B
that belongs to a given C.
This can of course be done with a LINQ/HQL/SQL/Criteria API query, but I would
like it mapped to A instead.
Any suggestions/solutions?
Med vänliga hälsningar,
Kim Johansson
Industritorget Sweden AB
Söndrumsvägen 29
302 39 Halmstad
tel: 035 - 260 32 00
fax: 035 - 12 24 83
epost: [email protected]<mailto:[email protected]>
webb: http://www.industritorget.se
[cid:[email protected]]<http://www.industritorget.se/>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.
<<inline: image001.jpg>>
