2015-05-11  745 views 评论

LINQ表达式实现对Datatable的排序

 标签:  

传统:

DataTable dt= sqlhelper.GetList("SELECT [MAJOR_ID],[MAJOR_NAME],[FLAG] FROM [T_MAJOR]").Tables[0];

Linq:

dt=dt.AsEnumerable().OrderBy(o => o.Field<string>("MAJOR_NAME")).CopyToDataTable();

给我留言

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: