开发者

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>?

Can't I here specify 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>

    -
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜