Try this:

session.Query<MyClass>().SelectMany(x => x.Elements).ToList();

RP

On Friday, May 16, 2014 12:56:53 PM UTC+1, John Smith wrote:
>
> Nhibernate generate broken SQL for following query:
> var data = session.Query<MyClass>()
> .Select(x => new { x.Elements })
> .ToList();
>
> mappings:
> public class Element
> {
> public string Value { get; set; }
>
> public Element()
> {
> }
> }
>
> public class MyClass
> {
> public virtual int Id { get; set; }
> public virtual ICollection<Element> Elements { get; set; }
>
> public MyClass()
> {
> }
> }
>
> public class MyClassMap : ClassMap<MyClass>
> {
> public MyClassMap()
> {
> Table("MyClass");
> Not.LazyLoad();
> Id(x => x.Id);
>
> HasMany(x => x.Elements).AsBag()
> .Table("MyClassElements")
> .KeyColumn("MyClassId")
> .ForeignKeyConstraintName("FK_MyClassElements")
> .Component(c =>
> {
> c.Map(x => x.Value);
> });
> }
> }
> (Complete solution attached)
>
> Does anyone know workaround?
>
>
>

-- 
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 http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to