class ClientStruct { public string ID = "ID"; public string Name = "Name"; public string Company = "Company"; public string CreatedDate = "CreatedDate"; } " } }; protected void LinqDataTable() { DataRow row; Cl…
方法一:更简洁 Console.WriteLine(dt.Rows.OfType<DataRow>().First(x => x.Field<string>("xx_Name") == "A").Field<string>("xx_NO")); 方法二:linq 更清晰 var query = from dr in dt.AsEnumerable() where dr.Field<string>…
IEnumerable<DataRow> q = from dr in dt.AsEnumerable() where dr.Field<int>("ID").ToString() == "1" select new { ID=dr["ID"].ToString(), Name=dr["Name"].To…
我们都知道,Linq能查询泛型集合,确切的说是:LINQ能实现查询泛型对象或者实现了IEnumerable.但是,很遗憾的是诸如ArrayList这样的非泛型集合并没有实现IEnumerable.那咋办呢?总不能把这么绚丽的Linq技术对非泛型关上大门把!~其实,方法还是有的. 场景还原: 定义一个car的类: class Car { public int CurrentSpeed; public int MaxSpeed; public string PetName; } 对ArrayList…