随笔分类 -  NHibernate

hql实现select new Type(column) from table
摘要:string query1 = "select MAX(g.Stars) ,new AuthorDTO(MAX(cast(g.GroupName as string))//不知道为什么不能加在聚合函数里面,也不能加到Groupfrom Group g join g.authors auths group by g.GroupName";下面方式可以:string query1 = "select g.Stars,new AuthorDTO(cast(g.GroupName as string)//需要在Group.hbm.xml里面添加<import cla 阅读全文
posted @ 2012-12-28 17:41 HonestPeople 阅读(307) 评论(0) 推荐(0)
nhibernate的不支持
摘要:linq的不支持: IQueryable<Model.MessageBoard> iq = new ManagerBase<Model.MessageBoard, Model.MessageBoard>().Query();IQueryable<Model.Author> iq2 = new ManagerBase<Model.Author, Model.Author>().Query();IQueryable<Model.Order> iq2 = new ManagerBase<Model.Order, Model.Order 阅读全文
posted @ 2012-12-28 17:26 HonestPeople 阅读(196) 评论(1) 推荐(0)
操作数数据类型 ntext 对于 max 运算符无效
摘要:string HQL = "SELECT t.Mb_id ,t.FromID ,MAX(case when t.FromID!=0 then A.RealName else t.Realname end),MAX(t.MBMessage as string) from Author A left join A.MessageBoards t where t.Mb_id<:Mb_id group by t.Mb_id,t.FromID";上面红色部分MBMessage在数据库中对应的字段的类型为ntext,会报标题所指的错误,按下面的代码修改后正常。string HQL 阅读全文
posted @ 2012-12-27 10:07 HonestPeople 阅读(617) 评论(0) 推荐(0)
nhibernate to linq
摘要:nhibernate在使用过程中遇到问题,不断解决后的一些零碎知识:一、Express: Express声明一个变量后,此变量可以保存一个lamda表达式,Express exp=(o=>o.fieldname),这样可以动态组合要查询的字段。上代码: Expression<Func<Gx.Model.Author, bool>> where1, where2; if (CityId != 0) { // strCity = " and other_City=" + CityId; wher... 阅读全文
posted @ 2012-12-17 10:32 HonestPeople 阅读(284) 评论(1) 推荐(0)