问题描述
DataSetset=newDataSet();using(SqlConnectiontestConnection=newSqlConnection(connectionString)){SqlDataAdapteradapter=newSqlDataAdapter("select*froms",testConnection);adapter.Fill(set);}Sdata.SDataTablestable=newSdata.SDataTable();SdataTableAdapters.STableAdaptersadap=newLinqExams.SdataTableAdapters.STableAdapter();sadap.Fill(stable);varresult=fromrowinstablewhererow.Sno=="2002340"selectrow;varquery=fromrowinset.Tables[0].AsEnumerable()whererow.Field<string>("sno")=="2002340".Trim()selectrow;custEntityDataContextdb=newcustEntityDataContext();Table<S>s=db.GetTable<S>();varres=fromrowinswhererow.Sno=="2002340"selectrow;foreach(varrinquery){Console.WriteLine("{0}:{1}",r["sno"],r["sname"]);}foreach(varrinresult){Console.WriteLine("{0}:{1}",r.Sno,r.Sname);}foreach(varrinres){Console.WriteLine("{0}:{1}",r.Sno,r.Sname);}查询条件都一样前面两个用LinqtoDataSet无数据(无条件时是有数据的,证明数据集有相应数据)后面一个用LinqtoSql有数据
解决方案
解决方案二:
单步调试查看DATASET内的值对应列是否有符合条件的数据