Whats the best way to convert a datarow[] to List<int>?
I want to convert a datarow[]
into a List<int>
List<int> UserIds;
public void GetGravata开发者_如何学运维rs()
{
var cmd = access.GetSqlCommandStoredProcedure("uspMembershipGetUserGravatarList");
var table = access.ExecuteDataTable(cmd, DAL.Logic.Common.ConnectionStrings.User);
int[] rows = new int[table.Rows.Count];
table.Rows.CopyTo(rows, 0);
UserIds = rows.ToList<int>();
}
public bool UserHasGravatar(int userId)
{
UserIds.Find(
delegate(int i)
{
return i == userId;
}
);
return false;
}
What is the best way of doing this?
Edit: My code needs to loop through a list of users, about 40000, and update their image, if they dont have one, so I thought it would be quickest, to load all the userids with images into a List, then check that against all userids in the database, if userid doesnt exists, then update image, otherwise continue.
rows.Select(r=>/*However you get a single int from a single row*/).ToList();
Update:
I assumed that you are using .NET Framework 3.5? But I may be wrong...
精彩评论