Datatable group by issue r.Field<T>
i was searching datatable group by option and found solution in stackoverflow.
DataTable t = //
var groups = t.AsEnumerable()
.GroupBy(r => r.Field<T>("col开发者_JAVA百科umnName"))
What does this mean... r.Field<T>
. why Field<T>
?
r.Field<Customer>
. read http://blogs.msdn.com/b/adonet/archive/2007/02/05/type-safety-linq-to-datasets-part-2.aspx
Edited:
1) why Field?
Field<T>
method : DataTable is not typed one,the values to be saved as object. so the Field method returns the value of the column with generic type parameter, thus enable type checking.
If it is a typed DataTable then you can Field<Customer.ID>
-
-
精彩评论