DataTable方法测试
//测试DataTable的select DataTable dt = new DataTable(); //a.OrderType, //a.[Status] dt.Columns.Add("No", typeof(String)); dt.Columns.Add("Type", typeof(String)); dt.Columns.Add("Status", typeof(String)); dt.Rows.Add(new object[] { "A01", "N", "N1" }); dt.Rows.Add(new object[] { "A01", "G", "G1" }); dt.Rows.Add(new object[] { "A01", "T", "T1" }); dt.Rows.Add(new object[] { "A01", "N", "N2" }); dt.Rows.Add(new object[] { "A02", "G", "G1" }); dt.Rows.Add(new object[] { "A02", "T", "T1" }); dt.Rows.Add(new object[] { "A03", "N", "N1" }); dt.Rows.Add(new object[] { "A04", "S", "S1" }); dt.Rows.Add(new object[] { "A05", "G", "G1" }); dt.Rows.Add(new object[] { "A05", "T", "T1" }); DataRow[] arrRow = dt.Select("No='A01' and ((Type='N') or (Type='G' and Status<>'G1') or(Type='T' and Status<>'T1'))"); //Console.WriteLine(arrRow[0]["Type"]); var arrRow2= arrRow.Select<DataRow,DataRow>(dr=> { if (dr["Type"].ToString() == "N") return dr; else return null; }); foreach(var r in arrRow2) { if(r!=null) Console.WriteLine(r["No"].ToString()+"===="+r["Status"].ToString()); }