Group By with substring throws an error

2 posts, 0 answers
  1. Frank Schürer
    Frank Schürer avatar
    13 posts
    Member since:
    Aug 2009

    Posted 01 Sep 2010 Link to this post


    i have this code snippet here and i try to get it working...

    Dim  Result = (From s In scope.Extent(Of ZipCodes)() _
              Where s.Coord = sValue _
              Group s By s.ZipCode.Substring(0, 2), s.Coord Into g = Group _
              Select  New  With  {.Region = ZipCode.Substring(0, 2), Coord})

    The interpreter says the following:
    Range variable name can be inferred only from a simple or qualified name with no arguments
    Has anybody came across this issue?

  2. Jordan
    Jordan avatar
    547 posts

    Posted 03 Sep 2010 Link to this post

    Hello Frank Schürer,

    It seems that you usually get such an error when you have not given a name to some expression.
    If you write the query like in the bellow snipped the error disappears:
    Dim Result = From s In zipCodes _
                Where s.Coord = "coord" _
                Group s By start = s.Name.Substring(0, 2), s.Coord Into Group _
                Select New With {.Region = start}
    Notice that the Substring expression is assigned to the start variable.
    You can take a look at the following blog post for more information:

    Sincerely yours,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top