Nhibernate by default doesnot provide an interface for fetching data into a dataset. So you have to write custom code to create a dataset based on the objects stored in the IList Collection.
I too was facing the same problem until i found the solution in this article
http://forum.hibernate.org/viewtopic.ph ... ht=dataset
This guy has beautifully explained it.
I used a similar kind of code here:
//Method for returning a dataset using Nhibernate
public DataSet GetDataSource()
{
DataSet objDataSet=new DataSet();
DataTable objTable=new DataTable("CurrencyTable");
IList objlist=GetCurrencyList();
objTable.Columns.Add("CurrencyId");
objTable.Columns.Add("CurrencyName");
objTable.Columns.Add("CountryName");
DataRow myRow;
foreach (object[] arrobject in objlist)
{
myRow=objTable.NewRow();
myRow[0]=arrobject [0];
myRow[1]=arrobject [1];
myRow[2]=arrobject [2];
objTable.Rows.Add(myRow);
}
objDataSet.Tables.Add(objTable);
return objDataSet;
}
//Method for executing the query in nhibernate.I have used the NhibernateHelper class provided by nhibernate for beginning the session and closing the session
private IList GetCurrencyList()
{
ISession session=NHibernateHelper.GetCurrentSession();
IQuery query = session.CreateSQLQuery("SELECT Currency.CurrencyId, Currency.CurrencyName, country.CountryName FROM country INNER JOIN Currency ON country.CountryId = Currency.CountryId");
IList objList = query.List();
NHibernateHelper.CloseSession();
return objList;
}