DataTable 使用Select方法查询并排序,以及【拼接转义符的问题】

关于DataTable 里面用 /转义符拼接的问题

//这种写法表面上是正确,实现上在运行时调用Select方法实行查询会报错 
string str = resetstrWhere + """ + "," + """ + dataQuery.DefaultOrderByClause; table = table.Select(str).CopyToDataTable();
//这种写法表面上是正确,实现上在运行时调用Select方法实行查询会报错
string
str = string.Format("{0}","{1}", resetstrWhere, dataQuery.DefaultOrderByClause); table = table.Select(str).CopyToDataTable();
//这种方法是正确的。
DataTable table =new DataTable(); table = table.Select(string.Format("{0}", resetstrWhere), string.Format("{0}", Tool.sortName + strtype)).CopyToDataTable();

DataTable 使用Select方法

Select();

Select("id>='3' and name='3--hello'");//支持and

Select("id>='3' or id='1'");//支持or

Select("name like '%hello%'");//支持like   

 Select("id>5","id desc");

Select("id>5", "id desc",DataViewRowState.Added);

原文地址:https://www.cnblogs.com/suntanyong88/p/4562706.html