标签:
实例:
DataTable data = new DataTable();
data.Columns.Add("schoolid", Type.GetType("System.Int32"));
data.Columns.Add("ccid", Type.GetType("System.Int32"));
DataRow newRow1 = data.NewRow();
newRow1["schoolid"] = 2;
newRow1["ccid"] = 1;
data.Rows.Add(newRow1);
DataRow newRow2 = data.NewRow();
newRow2["schoolid"] = 2;
newRow2["ccid"] = 2;
data.Rows.Add(newRow2);
DataRow newRow3 = data.NewRow();
newRow3["schoolid"] = 1;
newRow3["ccid"] = 2;
data.Rows.Add(newRow3);
string ceshi = "1,2";
var dataSelect = data.AsEnumerable();
dataSelect = from r in dataSelect
where r.Field<int>("schoolid") == 2 && !(new int?[] {int.Parse(ceshi) }).Contains(r.Field<int>("ccid")) select r; foreach (DataRow row in dataSelect)
{
string schoolid = row["schoolid"].ToString();
string ccid = row["ccid"].ToString();
}
标签:
原文地址:http://www.cnblogs.com/yinchuan/p/5297161.html