代码之家  ›  专栏  ›  技术社区  ›  x__dos

nhibernate:使用分组时返回list<entitytype>not list<object[]>

  •  1
  • x__dos  · 技术社区  · 15 年前

    当使用带分组的nhibrante条件api或hql时,query返回实体属性数组的列表 List<Object[]> 分组的位置。如果我只需要归还某些财产,我该怎么办?如果可能,最好使用NHIBERane API。

    2 回复  |  直到 15 年前
        1
  •  2
  •   Syd    15 年前

    你试过使用 变压器 班级?

    参见第节 16.1.5

        2
  •  1
  •   rebelliard    15 年前

    HQL ,你只是 SELECT 所需的属性:

    var query = Session.CreateQuery("select p.Id, p.Price from Products p where p.Status = 'A'")
                       .List().Cast<object[]>();
    

    它和 无纤维酸钠 :

    var query = from p in Session.Linq<Product>()
                where p.Status == "A"
                select new
                {
                    p.Id, p.Price
                };