You can't do this from a query expression, but you can do it with dot notation: var query = dataTable.AsEnumerable() . GroupBy(x => table. Field(Column1), StringComparer.
InvariantCultureIgnoreCase) . Select(groupedTable => new { value = groupedTable. Key, count = groupedTable.Count() }) You can even use a more complicated overload of GroupBy to do it in one call: var query = dataTable.AsEnumerable() .
GroupBy(x => table. Field(Column1), (key, group) => { value = key, count = group.Count() }, StringComparer. InvariantCultureIgnoreCase)) Obviously that's using the invariant culture - you could also use the current culture or ordinal rules.
You can't do this from a query expression, but you can do it with dot notation: var query = dataTable.AsEnumerable() . GroupBy(x => table. Field(Column1), StringComparer.
InvariantCultureIgnoreCase) . Select(groupedTable => new { value = groupedTable. Key, count = groupedTable.Count() }); You can even use a more complicated overload of GroupBy to do it in one call: var query = dataTable.AsEnumerable() .
GroupBy(x => table. Field(Column1), (key, group) => { value = key, count = group.Count() }, StringComparer. InvariantCultureIgnoreCase)); Obviously that's using the invariant culture - you could also use the current culture or ordinal rules.
Thanx for the answer. This is what I am looking for! By the way if I want to apply group by on more than one column(Column1 and Column2) then how should this query look like?
– Anoop Sep 29 '09 at 8:47 @Anoop: Grouping by more than one column and doing so in a case-insensitive manner will be tricky. You'd probably be best off building a custom type containing the columns you're interested in, and overriding Equals. – Jon Skeet Sep 29 '09 at 9:06 Jon!
Can you please explain it in a little more detailed manner? – Anoop Sep 29 '09 at 9:33 I'm afraid I don't have time at the moment. I'll try to come back to this later on.
– Jon Skeet Sep 29 '09 at 9:38.
This MSDN article has some information on datasets and case sensitivity.. You can control the case sensitivity of filtering, searching, and sorting by setting the dataset's CaseSensitive property.
In my case DataTable is independent of Dataset so case sensitive property is set to false. I think Linq doesn't refer to this property. It is for the operations exposed by Dataset/Datatable class.
– Anoop Sep 29 '09 at 7:15 DataTable also has the property. But honestly I haven't used LINQ to interact with datasets/tables so I can't say whether it would actually have an effect. – Quintin Robinson Sep 29 '09 at 7:22.
I have a data table and I want to perform a case insensitive group by over a column of data table (say Column1 of type string). I observed that normally LINQ to DataSet perform case sensitive comparison. For example if Column1 is having two values say Test and test, after applying group by it returns two seperate rows with values Test and test.
So, is there any method exist to perform case in-sensitive group by so that in above example I get only one row with one value either Test or test? Also I don't want to use ToUpper or ToLower methods because it actually changes the values to either upper case or lower case.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.