I was trying a more advanced usage of GetDistinct that threw an exception.
The thing i'm trying to do is get all unique first letters that are used in the object's title.
IEnumerable<string> listOfUniqueStartingLetters = SomeCollection.GetDistinct(x => x.Title.ToString());
So far so good. Looks like the initial SQL command that is generated is correct but on further processing the exception is thrown.
I think the exception is due to an error during field splitting. The resulting SQL correctly contains SUBSTRING([t0].[title], @p0 + 1, 1) but in LinqSQLParser.Generated.cs (in the method ParseSelect()) the statement is incorrectly parsed
into the different fields.
It gets all the fields from the string by splitting on a comma but in this case because there's a SQL function in there that itself holds comma's it get more "fields" and further down the method some assumptions go bunkers.
You can easily duplicate this with any model that has a string field and calling the above GetDistinct() statement.