0
var query = from r in dataTable.AsEnumerable()
                where (r.Field<double?>(dataTable.Columns[0]).Equals(invoiceNo))
                select new
                        {
                            invoice = r.Field<double>(dataTable.Columns[0]),
                            name = r.Field<string>(dataTable.Columns[1]),
                            emp_id = r.Field<double>(dataTable.Columns[2]),
                            won = r.Field<double>(dataTable.Columns[3]),
                            expenses = r.Field<double>(dataTable.Columns[4]),
                        };

これは、dataTable からすべてのデータを読み取る linq クエリです。

 I want the query to be converted again into a datatable.Is it possible?
4

2 に答える 2

5

メソッドを使用できますCopyToDataTable

 DataTable dt = (from r in dataTable.AsEnumerable()
                where (r.Field<double?>(dataTable.Columns[0]).Equals(invoiceNo)))
             .CopyToDataTable();
于 2013-05-23T09:43:49.663 に答える
0

使用できます

dataTable.PrimaryKey = new DataColumn[]{_dataTable.Columns["Invoice"]};

dataTable.Rows.Find(invoiceNo)
于 2013-05-23T09:40:07.553 に答える