我访问数据库的代码是..
using (MyDataContext target = DataContextFactory<MyDataContext>.GetDataContext())
{
var table_orders = from tab in target.Orders
select tab;
var cols = table_orders.First();
var colNames = (from property in cols.GetType().GetProperties()
select property.Name).ToList();
string[] fieldvalues;
foreach (var row in table_orders)
{
var i = 0;
foreach (var col in colNames)
{
var fieldvalues[i] = row.______.ToString(); <here I need to use 'col' variable not the hard typed property i.e., Order_Id, Order_Desc etc.
i++;
}
}
}
我如何完成它?我试图读取没有硬类型列名称的表,并将每一行加载到字符串数组中。如果还有其他方式也让我知道。