none
Error translating Linq expression to URI: The method 'GroupBy' is not supported. RRS feed

  • Question

  • Here the code that causes the error:

    var mycon = (from ConcViews in DbContext.ConcViews
                                     where
                                       ConcViews.DictateTimes >= Convert.ToDateTime("2017-08-01 00:00:00") &&
                                       ConcViews.DictateTimes <= Convert.ToDateTime("2018-08-12 23:59:59")
                                     group ConcViews by new
                                     {
                                         ConcViews.DictateTimes
                                     } into g
                                     where g.Count() > 1
                                     select new
                                     {
                                         Users = g.Count(),
                                         g.Key.DictateTimes
                                     });

    Thursday, August 2, 2018 7:52 PM

All replies

  • You'll need to add some more context.  That error doesn't sound like it's coming from Entity Framework.

    Microsoft Technology Center - Dallas
    My blog

    Thursday, August 2, 2018 8:01 PM
  • I'm running it from an Odata Service version 5.8.3

     DbContext = new MYServicesEntities(ServerServiceUri);

    Thursday, August 2, 2018 8:10 PM
  • Then your question isn't about Entity Framework.  It's about your client-side ODATA library, and your service.  IIRC aggregations are new-ish in ODATA and your client and server stack may not support them. 

    If you want to fetch the details and group them on the client, you could do something like this:

    var mycon = 
     ( from ConcViews in DbContext.ConcViews
       where ConcViews.DictateTimes >= Convert.ToDateTime("2017-08-01 00:00:00" &&
       ConcViews.DictateTimes <= Convert.ToDateTime("2018-08-12 
     23:59:59")
       select ConcViews
      ).ToList();
    
    var mycon2 = 
      ( from ConcViews in mycon
        group ConcViews by new { ConcViews.DictateTimes } 
        into g
        where g.Count() > 1
        select new
        {
          Users = g.Count(),
          g.Key.DictateTimes
        }
       ).ToList();

    David


    Microsoft Technology Center - Dallas
    My blog

    Thursday, August 2, 2018 9:34 PM