使用this question的接受答案我已经能够使用ICriteria和投影连接两个字段。我最终得到了
return session.CreateCriteria<Contact>()
.CreateAlias("USState","USState", NHibernate.SqlCommand.JoinType.LeftOuterJoin)
.SetProjection(Projections.ProjectionList()
.Add(Projections.Property<Contact>(x=>x.Id), "Id")
.Add(Projections.SqlFunction("concat",
NHibernateUtil.String,
Projections.Property<Contact>(x=>x.BasicInfo.FirstName),
Projections.Constant(' '),
Projections.Property<Contact>(x=>x.BasicInfo.LastName)),"Name")
.Add(Projections.Property<Contact>(x=>x.BasicInfo.City),"City")
.Add(Projections.Property<Contact>(x=>x.USState.Name) ,"State"))
.Add(Restrictions.Where<Contact>(x => x.Pack == false))
.AddOrder(new Order(Projections.Property<Contact>(x => x.BasicInfo.FirstName), true))
.AddOrder(new Order(Projections.Property<Contact>(x => x.BasicInfo.LastName), true))
.SetResultTransformer(NHibernate.Transform.Transformers.AliasToBean<ContactsViewModel>())
.List<ContactsViewModel>();
这是将预期的查询发送到服务器并且正在运行。
我的问题是除了使用SqlFunction使用ICriteria和投影进行连接之外还有其他方法。