Reputation: 2253
I wrote the following query in LINQ:
memberlist
is List
of membershipuserwrapper
List<usercodes> testlist = new List<usercodes>();
testlist.Add(new usercodes { usercode = "na02\\srosner" });
testlist.Add(new usercodes { usercode = "[email protected]" });
var filtered = (from c in memberList
where (from t in testlist
select t.usercode.ToLower())
.Contains(c.UserName.ToLower())
select c)
.ToList();
Now, I have DataTable
with a list of users in place of testlist
and I want to use that DataTable
in place of my LINQ query.
Can I use that how to do that in way of DataTable
?
Upvotes: 1
Views: 199
Reputation: 1064114
You should be able to use:
from t in testlist.AsEnumerable()
select t.Field<string>("usercode").ToLower()
in place of the original:
from t in testlist
select t.usercode.ToLower()
Personally, though, I'd say that the List<usercodes>
is a vast improvement from a DataTable
, and would encourage you to pursue the original version (maybe changing the class-name to UserCodes
or similar).
Upvotes: 2