问题标签 [nhibernate]
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# - Problem using SQLite :memory: with NHibernate
I use NHibernate for my dataacess, and for awhile not I've been using SQLite for local integration tests. I've been using a file, but I thought I would out the :memory: option. When I fire up any of the integration tests, the database seems to be created (NHibernate spits out the table creation sql) but interfacting with the database causes an error.
Has anyone every gotten NHibernate working with an in memory database? Is it even possible? The connection string I'm using is this:
c# - NHibernate 按问题排序
好的,所以我有一个返回对象的 nHibernate ICriteria。我想按单个属性排序,但不是 asc 或 desc 我希望该属性的某些值根据选择出现在转发器的顶部。就像我选择“视频”一样,我希望所有带有视频的记录都排在最前面。
现在,我可以在查询中执行此操作吗?还是中继器?标准?
谢谢你的帮助。
nhibernate - NHibernate Criteria:用 IN 表达式连接两列
这是我想要完成的 SQL:
我一辈子都找不到合适的表达方式。而且我不认为我可以使用两个表达式作为域名和组名需要连接。
谢谢!
.net - 如何使用 NHibernate 和 SQL Server 2005 保存 PDF 文件
我正在开发一个网络应用程序,用户有机会以 pdf 格式上传他的简历。我使用 NHibernate 作为数据映射器和 MS SQL SERVER 2005。
我希望能够将 .pdf 文件保存到给定的表中……有什么想法吗?
非常感谢你!
.net - 使用 LINQ 进行多次删除(更具体地说是 Linq2Nhibernate,但是......)
有什么聪明的方法可以做到这一点吗?
如果使用Linq2Nhibernate
,您似乎真的必须依赖HQL
或喜欢从数据库中进行多次删除(无需加载并一一删除)?
好像Linq2Sql
也没有?我只想要一些可以做的事情,比如:
有任何想法吗?
c# - Bidi 关联和 NHibernate 映射
我有 BidiParent 和 BidiChildList 类,它们以双向父子关系链接父母和孩子。如果一个孩子的父母被例如服务层更新,旧的和新的父母的孩子列表会自动更新以反映变化。同样,如果通过例如添加新孩子来更新父母的孩子列表,则孩子的父母会自动改变,就像旧父母的孩子列表一样。我想尝试建立一个“智能”域模型。
显然,第一个问题是:这甚至是个好主意吗?
第二个问题是:是否可以告诉 NHibernate 访问和修改字段_Children 或 _Parent,但考虑属性Children 或 Parent 与该字段完全同义?NHibernate 应该加载和保存内部字段,但 HQL 或 LINQ 查询应该使用公共属性?
nhibernate - 如何告诉 NHibernate 总是强制引用标识符?
如标题:我将如何一劳永逸地告诉 NHibernate,所有表名和列名都将在它生成的 SQL 中被引用?
linq - Persistence framework?
I'm trying to decide on the best strategy for accessing the database. I understand that this is a generic question and there's no a single good answer, but I will provide some guidelines on what I'm looking for. The last few years we have been using our own persistence framework, that although limited has served as well. However it needs some major improvements and I'm wondering if I should go that way or use one of the existing frameworks. The criteria that I'm looking for, in order of importance are:
Client code should work with clean objects, width no database knowledge. When using our custom framework the client code looks like:
SessionManager session = new SessionManager(); Order order = session.CreateEntity(); order.Date = DateTime.Now; // Set other properties OrderDetail detail = order.AddOrderDetail(); detail.Product = product; // Other properties
// Commit all changes now session.Commit();
Should as simple as possible and not "too flexible". We need a single way to do most things.
- Should have good support for object-oriented programming. Should handle one-to-many and many-to-many relations, should handle inheritance, support for lazy loading.
- Configuration is preferred to be XML based.
With my current knowledge I see these options:
- Improve our current framework - Problem is that it needs a good deal of effort.
- ADO.NET Entity Framework - Don't have a good understanding, but seems too complicated and has bad reviews.
- LINQ to SQL - Does not have good handling of object-oriented practices.
- nHibernate - Seems a good option, but some users report too many archaic errors.
- SubSonic - From a short introduction, it seems too flexible. I do not want that.
What will you suggest?
EDIT:
Thank you Craig for the elaborate answer. I think it will help more if I give more details about our custom framework. I'm looking for something similar. This is how our custom framework works:
- It is based on DataSets, so the first thing you do is configure the DataSets and write queries you need there.
- You create a XML configuration file that specifies how DataSet tables map to objects and also specify associations between them (support for all types of associations). 3.A custom tool parse the XML configuration and generate the necessary code. 4.Generated classes inherit from a common base class.
To be compatible with our framework the database must meet these criteria:
- Each table should have a single column as primary key.
- All tables must have a primary key of the same data type generated on the client.
- To handle inheritance only single table inheritance is supported. Also the XML file, almost always offers a single way to achieve something.
What we want to support now is:
- Remove the dependency from DataSets. SQL code should be generated automatically but the framework should NOT generate the schema. I want to manually control the DB schema.
- More robust support for inheritance hierarchies.
- Optional integration with LINQ.
I hope it is clearer now what I'm looking for.
nhibernate - 从 NHibernate 获得汇总结果的最佳方法是什么?
例如,我试图在不同情况下获取最小日期、最大日期和总和。我试图避免对 SQL 字符串进行硬编码或通过 IList 循环来获取这些值。
nhibernate - 代码生成器不好吗?
我使用 MyGeneration 和 nHibernate 来创建基本的 POCO 对象和 XML 映射文件。我听说有些人说他们认为代码生成器不是一个好主意。目前最好的想法是什么?当它生成数千行无法理解的代码时,代码生成是不是很糟糕?