更新时间:2023-01-13 14:20:09
你***使用 DataTable.Select
方法,但如果你必须使用 LINQ 那么你可以尝试:
You are better of using DataTable.Select
method, but if you have to use LINQ then you can try:
DataTable selectedTable = tb.AsEnumerable()
.Where(r => r.Field<string>("Modul") == value)
.CopyToDataTable();
这将基于过滤的值创建一个新的 DataTable
.
This would create a new DataTable
based on filtered values.
如果您使用 DataTable.Select
string expression = "Modul =" + value;
DataRow[] selectedRows = tb.Select(expression);