Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# DataTable.Select()中的子字符串测试_C#_Select_Datatable_Substring - Fatal编程技术网

C# DataTable.Select()中的子字符串测试

C# DataTable.Select()中的子字符串测试,c#,select,datatable,substring,C#,Select,Datatable,Substring,我有一个数据表,其结果已经从后端拉下来。 我想做一个DataTable.Select,但条件是基于其中一列的子字符串 Select方法中是否有允许列测试的子字符串使用的语法,或者我是否必须以艰难的方式执行此操作-扫描每一行。您可以在给定的表达式中使用LIKE运算符来选择: table.Select("ItemName LIKE '*product*'") 也许您可以使用linq,如以下示例: var x = from c in table.AsEnumerable() sele

我有一个数据表,其结果已经从后端拉下来。 我想做一个DataTable.Select,但条件是基于其中一列的子字符串


Select方法中是否有允许列测试的子字符串使用的语法,或者我是否必须以艰难的方式执行此操作-扫描每一行。

您可以在给定的表达式中使用LIKE运算符来选择:

table.Select("ItemName LIKE '*product*'")

也许您可以使用linq,如以下示例:

var x = from c in table.AsEnumerable()
        select c.Field<string>("MyColumn").Substring(index, length);


可以使用子字符串

DataRow[] selectRowsWithSubstring;
selectRowsWithSubstring = datatable.Select("substring(column, start, length) = value");
DataRow[] selectRowsWithSubstring;
selectRowsWithSubstring = datatable.Select("substring(column, start, length) = value");