简体   繁体   English

NHibernate的LINQ等同于SQL和EF的Translate <T> ()

[英]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). 我有一个查询,由于性能原因,我需要使用原始ADO.NET编写实际命令(它涉及表值参数)。 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> . 使用LINQ to SQL或EF,我可以简单地将DbCommand.ExecuteReader()返回的DbDataReader传递给DataContext.Translate<T>(DbDataReader)ObjectContext.Translate<T>(DbDataReader)方法,它将转换结果-设置为对象,返回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? NHibernate中是否有等效的API,我可以传递DbDataReader / IDataReader甚至DbCommand / IDbCommand并返回NHibernate实体?

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? 也许有一种方法可以拦截由ISession.CreateQuery(string)创建的命令的构造,以便我可以修改基础的DbCommand使其按需要的方式工作?

You can probably create a custom UserType to handle the table-valued parameter. 您可能可以创建一个自定义UserType来处理表值参数。

NHibernate does not expose the DataReader -> entities transformation in any public methods. NHibernate不会在任何公共方法中公开DataReader->实体转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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