i have 2 tables in database:
create table [items]( [item_id] [int] identity(1,1) not null, [item_name] [varchar](50) not null, [group_id] [int] not null ) create table [itemgroup]( [group_id] [int] identity(1,1) not null, [group_name] [varchar](50) null )
and here mapping classes these entities:
public class itemmap : classmap<item> { public itemmap() { table("items"); id(x => x.id).column("item_id"); map(x => x.name).column("item_name"); references(x => x.itemgroup).column("group_id").fetch.join(); } } public class itemgroupmap : classmap<itemgroup> { public itemgroupmap() { table("itemgroup"); id(x => x.id).column("group_id"); map(x => x.name).column("group_name"); } }
how can items database ordered group name?
in case i'm using fluent nhibernate v1.2.0.712.
you need add join criteria.
var criteria = session.createcriteria<item>() .createalias("itemgroup", "group") .addorder(order.asc("group.name"));
Comments
Post a Comment