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)
DataRow[] dr = dt.Select(“col='XXXX'”);//条件:就是字段名='某某'
/// 执行DataTable中的查询返回新的DataTable
/// </summary>
/// <param name="dt">源数据DataTable</param>
/// <param name="condition">查询条件</param>
/// <returns></returns>
private DataTable GetNewDataTable(DataTable dt, string condition,string sortstr)
{
DataTable newdt = new DataTable();
newdt = dt.Clone();
DataRow[] dr = dt.Select(condition,sortstr);
if (dr== null || dr.Length == 0) return null
for (int i = 0; i < dr.Length; i++)
{
newdt.ImportRow((DataRow)dr[i]);
}
return newdt;//返回的查询结果
}
————————————————
版权声明:本文为CSDN博主「qq1429351723」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_30469045/article/details/52105132