对NHibernate运行原始SQL,然后使用AutoMapper将其推送到列表中的最佳方式是什么?
示例:
public virtual List<T> GetList<T>(string mainsql)
{
IQuery q = GetSession().CreateSQLQuery(mainsql);
IEnumerable srcAllRows = q.List();
List<T> targetAllRows = new List<T>();
*** do AutoMapper thing to get srcAllRow to targetAllRows ***
return targetAllRows;
}发布于 2010-11-30 23:50:54
这就是我在do AutoMapper thing部分得到的结果
public virtual List<T> GetList<T>(string mainSql)
{
DataTable ldt = new DataTable();
StartReader(mainSql); //load a reader with data.
ldt.Load(reader);
DataTableReader rdr = ldt.CreateDataReader();
return (List<T>)Mapper.Map<IDataReader, IList<T>>(rdr);
}https://stackoverflow.com/questions/3659653
复制相似问题