开发者

NHibernate: Converting an IQUERY to a dataset?

Is it pos开发者_开发知识库sible to convert an IQuery that is returned from Nhibernate to a dataset?

I have managed to get the data to an ILIST (collection of hashtables) but how do i get it converted into a dataset?

Thanks in advance


I found this on google, check all the code:

DataTable dt = new DataTable();
dt.Columns.Add("CustomerId", typeof(int));
dt.Columns.Add("CustomerName", typeof(string));
dt.Columns.Add("RegisteredAt", typeof(string));//not a typo, sadly.

// ... lot more properties, often nested ones.

foreach(Customer cust in customers)
{
  DataRow row = dt.NewRow();
  row["CustomerId"] = cust.Id;
  row["CustomerName"] = cust.At(reportDate).Name;
  row["RegisteredAt"] = cust.RegisteredAt.ToShortDateString();
  //... lot more properties

  dt.Rows.Add(row);
}
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜