System.Linq.Dynamic.Core icon indicating copy to clipboard operation
System.Linq.Dynamic.Core copied to clipboard

Question: GroupBy fails for field named SHORT

Open alexfestbaum opened this issue 8 years ago • 2 comments

Issuing a GroupBy against a entity field named SHORT results in the following error:

'.' or '(' or string literal expected

var result = baseData .Select(entityName) .GroupBy("SHORT", "it") .Select("new (it.Key as value, it.Count() as count)") .ToDynamicList();

Short seems to be a protected key/word. How can I resolve this issue? Padding the field with '[SHORT]' like SQL Server would do did not help.

alexfestbaum avatar Jun 29 '18 16:06 alexfestbaum

Adding the prefix it. helped to prevent the issue: var result = baseData .Select(entityName) .GroupBy("it.SHORT", "it") .Select("new (it.Key as value, it.Count() as count)") .ToDynamicList();

alexfestbaum avatar Jun 29 '18 16:06 alexfestbaum

SHORT is probably a reserved keyword.

StefH avatar Jul 22 '18 10:07 StefH