问题标签 [nhibernate-3]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - 在 C# 中,为什么我不能访问这个流?
我从 NHibernate 3 Cookbook(一本优秀的书,顺便说一句)中得到了这段代码,虽然我在勘误表中找不到任何内容。我收到错误“无法访问关闭的流”:
该错误在 sr.ReadToEnd() 行上引发。
nhibernate - NHibernate 3.0 中有什么新功能?
任何人都可以链接或列出 NHibernate 3.0 的新功能吗?
nhibernate - nHibernate 3 - QueryOver 与 DateTime
我正在尝试编写一个查询以使用 DateTime 进行选择。Year 作为 where 参数,但我从 nunit 收到此错误:
NHibernate.QueryException:无法解析属性:Register.Year of:Estudantino.Domain.Events
在类事件中,我有一个名为Register作为 DateTime 类型的属性。
这是返回错误的方法:
变量 year 的类型是int,它被传递给方法。
有谁知道我做错了什么?我的数据库服务器是 SQL Server 2005 Express。
nhibernate - nhibernate,外键列中为 0
我得到了一个遗留数据库,其中 FK 列中使用了 0 的值来表示没有指定任何关系。
这不是我可以以微不足道的方式改变的事情。是否可以告诉 NHibernate 在指定列中将 0 视为 null ?
编辑
我知道not-found
,但我只想忽略那些 0。
fluent-nhibernate - NHibernate 3.0 版中是否有更好的 SybaseDialect 实现?
我们已经使用 Fluent-NHibernate 升级到 NHibernate 3.0。
在 2.1.2 版中,我们可以将 SybaseDialect 用于 ASE 12。在 3.0 版中,不支持用于 ASE 12 的 SybaseDialect。
我重用了 Nhib 2.1.2 中的旧方言,一切正常。
我想问的是,因为这个被认为不是一个好的实现而被删除了,有没有更好的实现?
由于它正在工作,我不确定需要进行哪些改进,但我想我会问。
nhibernate - 禁用一个模型的缓存
我得到了一个由两个应用程序修改的表。其中之一是使用休眠。如何禁用该表的缓存?可以在映射文件中完成吗?
nhibernate - NHibernate 3.0:TransactionScope 和自动刷新
在 NHibernate 3.0 中,FlushMode.Auto
仅在环境事务下运行时不起作用(即,不启动 NHibernate 事务)。应该是?
(示例无耻地从这个相关问题中窃取)
在 NHibernate 源代码中,我可以看到它正在检查是否有正在进行的事务 (in SessionImpl.AutoFlushIfRequired
),但相关方法 ( SessionImpl.TransactionInProgress
) 不考虑环境事务 - 不像它的表亲ConnectionManager.IsInActiveTransaction
,它确实考虑环境事务。
c# - NHibernate 3 LINQ - 如何为 Average() 创建有效参数
假设我有一个非常简单的实体,如下所示:
这个人为的示例对象使用 NHibernate(使用 Fluent)进行映射并且工作正常。
是时候做一些报告了。在这个例子中,“testGuys”是一个已经应用了一些标准的 IQueryable。
这工作得很好。在 NHibernate Profiler 中,我可以看到生成了正确的 SQL,并且结果符合预期。
受我成功的启发,我想让它更灵活。我想让它可配置,以便用户可以获得 OtherValue 和 InterestingValue 的平均值。不应该太难,Average() 的参数似乎是一个 Func(因为在这种情况下值是整数)。十分简单。我不能只创建一个基于某些条件返回 Func 的方法并将其用作参数吗?
然后,在其他地方,我可以这样做:
好吧,我以为我能做到。然而,当我列举这一点时,NHibernate 会抛出一个合适的:
所以我猜测在幕后,一些转换或强制转换或一些这样的事情正在发生,在第一种情况下接受我的 lambda,但在第二种情况下,NHibernate 无法转换为 SQL。
My question is hopefully simple - how can my GetAverageField function return something that will work as a parameter to Average() when NHibernate 3.0 LINQ support (the .Query() method) translates this to SQL?
Any suggestions welcome, thanks!
EDIT
Based on the comments from David B in his answer, I took a closer look at this. My assumption that Func would be the right return type was based on the intellisense I got for the Average() method. It seems to be based on the Enumerable type, not the Queryable one. That's strange.. Need to look a bit closer at stuff.
The GroupBy method has the following return signature:
That means it should give me an IQueryable, all right. However, I then move on to the next line:
If I check the intellisense for the g variable inside the new { } object definition, it is actually listed as being of type IGrouping - NOT IQueryable>. This is why the Average() method called is the Enumerable one, and why it won't accept the Expression parameter suggested by David B.
So somehow my group value has apparently lost it's status as an IQueryable somewhere.
Slightly interesting note:
I can change the Select to the following:
And now it compiles! Black magic! However, that doesn't solve the issue, as NHibernate now doesn't love me anymore and gives the following exception:
What baffles me is that this works when I give the lambda expression to the Average() method, but that I can't find a simple way to represent the same expression as an argument. I am obviously doing something wrong, but can't see what...!?
I am at my wits end. Help me, Jon Skeet, you're my only hope! ;)
migration - NHibernate 3:值得迁移吗?
我们在一个大型 .NET 3.5 C# 项目上使用 Nhibernate 1.2,并且我们正在考虑升级到 Nhibernate 3.1。但是我有点困惑,因为我在互联网上没有找到很多涉及的文章
- 新版本的改进 (2.0 -> 3.1)
- 1.2、2.x、3.x 之间的基准
大多数时候人们只是说:NHibernate XY 出来了,太好了,太棒了,你必须升级,并链接到 ChangeLog。
到目前为止,我只听说过 Linq2Nhibernate 和 MultiCriteria,没有关于性能基准的内容。
wcf - NHibernate + WCF + Windows 服务和 WcfOperationSessionContext 类
- 我有一个 Windows 服务应用程序,我在其中创建 WCF 服务。
- 其中一项服务是数据服务:通过 WCF 添加、删除、读取、更新数据。
- WCF 使用 NHibernate 进行数据操作
所以我的猜测是:
使用 WCF 进行 Hibernate 会话管理的任何建议(最佳实践)?
任何人都知道
WcfOperationSessionContext (hibernate 3.0) 类?
好吧,让它具体化:
假设我有名为DataServices的 WCF 服务
我需要一个NHibernateServiceProvider类
最良好的祝愿
PS:我已经阅读了类似的条目here和其他网页。但看不到“具体”的答案。