It's simpler than you think...

var result = this.session.CreateCriteria<Foo>
.AddOrder(Order.Asc("TheComponent.FirstProperty"))
.List<Foo>();

    Diego


On Fri, Aug 6, 2010 at 10:21, Francois Ward <[email protected]> wrote:

> This is probably a silly question, but I can't find the answer
> anywhere, so I hope you can forgive me :)
>
> I'm trying to do something pretty simplistic: a criteria query that
> sorts on one of the properties of a component. Simple enough, right?
>
> //pseudo code, so i may make a mistake
> var result = this.session.CreateCriteria<Foo>
> .CreateAlias("SomeProperty.MyComponent", "bar")
> .AddOrder(Order.Asc("bar.FirstProperty"))
> .List<Foo>();
>
> Exception: "could not resolve property: FirstProperty of:
> Foo.SomeProperty
>
>
> Well, of course, i'm trying to sort on
> Foo.SomeProperty.MyComponent.FirstProperty, not
> Foo.SomeProperty.FirstProperty, thus the alias!
>
> The component works fine in every other ways, including projections,
> so I think my mapping is correct, and i can sort on the component if i
> sort directly on the component (the SQL generated is then an Order By
> clause with all of its properties, but i only want one).
>
> Is aliasing the component the wrong way of doing this? I'm sure i'm
> missing something obvious :)
>
> Thanks!
>
> -Francois Ward
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
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.

Reply via email to