0

I have a field in a dataset and im querying using Linq my code is

 var countriesQry = from a in countTbl.AsEnumerable()
                               where a["CountryId"].ToString().Contains(countryId)
                               orderby a["CountryId"]

my problem is that in the "CountryId" field there can be a countryid of 1,22,13 (its a varchar field) so something can be a few countries. as you can guess its returning 1 and 13 if the "Countryid" = 1 can anyone tell how I can correct it

thanks

4

3 回答 3

1

只需更改ContainsEquals

var countriesQry = from a in countTbl.AsEnumerable()
                           where a["CountryId"].ToString().Equals(countryId)
                           orderby a["CountryId"]
于 2012-10-22T11:23:52.993 回答
0

尝试使用 Any() 而不是包含。

于 2012-10-22T11:26:27.043 回答
0
var countriesQry = from a in countTbl.AsEnumerable()
                           where a["CountryId"].ToString().Equals(countryId)
                           orderby a["CountryId"]
于 2012-10-22T11:24:02.573 回答