我试图在foreach循环中填充数据表,但它不起作用。我的代码是
@helper PrintProductYearChart(IEnumerable<DynamicNode> products)
{
DataTable dt = new DataTable();
foreach (var prd in products)
{
var query = "SELECT DISTINCT year(AddedDate) FROM Product WHERE PID='" + prd.Id + "' ORDER BY year(AddedDate) DESC";
SqlDataReader reader = SqlHelper.ExecuteReader(umbraco.GlobalSettings.DbDSN, CommandType.Text, query);
dt.Load(reader);
}
}
任何人都可以帮忙。谢谢