Jason Barile
Jason Barile

Reputation: 946

How to specify a lazy-loaded collection should be sorted in NHibernate?

Is there a way to specify an order-by clause in my config XML to instruct nHibernate to lazy-load a collection property sorted by a particular property of the collection members?

Upvotes: 2

Views: 257

Answers (1)

Jamie Ide
Jamie Ide

Reputation: 49271

Use the order-by attribute in the collection mapping. The syntax is

order-by="column_name asc|desc" 

Note that you specify the column name and not the property name.

Upvotes: 2

Related Questions