This question is locked. New answers and comments are not allowed.
I have the following group by LINQ query in C# that I'm trying to rewrite in VB, but I get an error on my vb code. Can anyone see what is wrong with it.
C#
var dupValues = from mrows in dtLoadedData.Select()
group mrows by new
{
a = mrows.Field<object>(compositeColls[0].ColumnName),
b = mrows.Field<object>(compositeColls[1].ColumnName),
c = mrows.Field<object>(compositeColls[2].ColumnName),
d = mrows.Field<object>(compositeColls[3].ColumnName)
}
into grp where grp.Count() >= 2 select new { grp.Key.a, grp.Key.b, grp.Key.c, grp.Key.d, e = grp.Count() };
VB
Dim dupValues = From grp In From mrows In dtLoadedData.[Select]() Group mrows By New With { _
a = mrows.Field(Of Object)(compositeColls(0).ColumnName), _
b = mrows.Field(Of Object)(compositeColls(1).ColumnName), _
c = mrows.Field(Of Object)(compositeColls(2).ColumnName), _
d = mrows.Field(Of Object)(compositeColls(3).ColumnName) _
} Into grp() Where grp.Count() >= 2 Select New With { _
grp.Key.a, grp.Key.b, grp.Key.c, grp.Key.d, Key .e = grp.Count() }
Error: Anonymous type member name must be preceded by a period
C#
var dupValues = from mrows in dtLoadedData.Select()
group mrows by new
{
a = mrows.Field<object>(compositeColls[0].ColumnName),
b = mrows.Field<object>(compositeColls[1].ColumnName),
c = mrows.Field<object>(compositeColls[2].ColumnName),
d = mrows.Field<object>(compositeColls[3].ColumnName)
}
into grp where grp.Count() >= 2 select new { grp.Key.a, grp.Key.b, grp.Key.c, grp.Key.d, e = grp.Count() };
VB
Dim dupValues = From grp In From mrows In dtLoadedData.[Select]() Group mrows By New With { _
a = mrows.Field(Of Object)(compositeColls(0).ColumnName), _
b = mrows.Field(Of Object)(compositeColls(1).ColumnName), _
c = mrows.Field(Of Object)(compositeColls(2).ColumnName), _
d = mrows.Field(Of Object)(compositeColls(3).ColumnName) _
} Into grp() Where grp.Count() >= 2 Select New With { _
grp.Key.a, grp.Key.b, grp.Key.c, grp.Key.d, Key .e = grp.Count() }
Error: Anonymous type member name must be preceded by a period