通过linq查询datatable数据集合满足条件的数据集
1.首先定义查询字段的变量,比如深度
string strDepth=查询深度的值;
var dataRows = from datarow in dataTable(需要查询的datatable数据集).AsEnumerable() where string.Compare(datarow.Field("查询字段,比如深度字段"), strDepth) >= 100 && string.Compare(datarow.Field("查询字段,比如深度字段"), strDepth) <=200 select new { DT中深度字段名称= datarow["查询的字段,比如深度字段"].ToString(), };
2.直接调用上面的linq语句后,上述linq 意思是查询字段深度值的范围是100-200,可以根据自己的项目要求进行重新查询字段
|