Disclaimer: I know its asked at so many places at SO.
My query is a little different.
Coding Language: C# 3.5
I have a DataTable named cardsTable that
Here is a simple way to convert to generic list in c# with Where condition
List filter = ds.Tables[0].AsEnumerable()
.Where(x => x.Field("FilterID") == 5)
.Select(row => new Filter
{
FilterID = row.Field("FilterID"),
FilterName = row.Field("FilterName")
}).ToList();
First Define properties and use as per
public class Filter
{
public int FilterID { get; set; }
public string FilterName { get; set; }
}
Put Package:
using System.Linq;
using System.Collections.Generic;