DataTable转数组List:
简单粗暴方法如下测试:
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(string));
dt.Columns.Add("BillNo", typeof(string));
for (int i = 0; i < 3; i++)
{
DataRow dr = dt.NewRow();
dr["ID"] = i;
dr["BillNo"] = "A00" + i;
dt.Rows.Add(dr);
}
var lists = dt.AsEnumerable().Select(t => t.Field<string>("BillNo")).ToList();
string values = "AND CompanyID IN('" + string.Join("','", lists) + "')";
Console.WriteLine("-->"+ values);
Console.ReadKey();
效果图: