Uploaded image for project: 'NHibernate [Moved to GitHub]'
  1. NH-2419

Linq Provider Problem with group by with an order by clause

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: 3.0.0.Beta2
    • Fix versions: 3.3.0.CR1
    • Components: Linq Provider
    • Labels:
      None
    • Sprint:

      Description

      if you try to send a linq query like one below:

      from c in db.Customers
      group c by c.Address.Country into g
      orderby g.Key
      select new

      { p0 = g.Key, p1 = g.Count() };

      NHibernate translates it into something like:

      .Select(.OrderBy(.GroupBy(NHibernate.Linq.NhQueryable`1NHibernate.Test.Linq.Entities.Customer,
      Quote(
      (94885238-9adb-46cf-86c8-667f0a9297ec, )
      =>
      (94885238-9adb-46cf-86c8-667f0a9297ec.Address.Country)
      )
      , )
      ,
      Quote(
      (ed56f08a-e224-4114-b57a-281a72749241, )
      =>
      (ed56f08a-e224-4114-b57a-281a72749241.Key)
      ),
      ),
      Quote(
      (8ef19692-2ffe-4693-9bcc-f36df5ae4afb, )
      =>
      (new C2`2()8ef19692-2ffe-4693-9bcc-f36df5ae4afb.Key.Count(8ef19692-2ffe-4693-9bcc-f36df5ae4afb, ))), )

      and throws and error that the .Key property can not be found on the entity.

      A test method to reproduce the issue can be :

      Test
      public void GroupByThenOrderBy()
      {
      var query = from c in db.Customers
      group c by c.Address.Country into g
      orderby g.Key
      select new { p0 = g.Key, p1 = g.Count() }

      ;

      var ids = query.ToList();
      Assert.NotNull(ids);
      if (ids.Count > 1)

      { Assert.Greater(ids[0].p0, ids[1].p0); }

      }
      inside the NHibernate.Test.Linq.OrderByTests

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jf3l1x Jose Felix
            • Votes:
              3 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Who's Looking?