简体   繁体   中英

NHibernate's equivalent of LINQ to SQL's and EF's Translate<T>()

I have a query that due to performance reasons I need to craft the actual command using raw ADO.NET (it involves table-valued parameters). With LINQ to SQL or EF, I could simply pass the DbDataReader that was returned by DbCommand.ExecuteReader() to the DataContext.Translate<T>(DbDataReader) or ObjectContext.Translate<T>(DbDataReader) method and it would convert the result-set to objects, returning an IEnumerable<T> .

Is there any equivalent API in NHibernate that I can either pass a DbDataReader / IDataReader or even an DbCommand / IDbCommand and get NHibernate entities back?

Or perhaps there's a way to intercept the construction of the command created by ISession.CreateQuery(string) so that I could modify the underlying DbCommand to work the way I need to?

You can probably create a custom UserType to handle the table-valued parameter.

NHibernate does not expose the DataReader -> entities transformation in any public methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM