nhibernate

How can I gradually transition to NHibernate persistence logic from existing ADO.NET persistence logic?

让人想犯罪 __ 提交于 2020-01-25 21:42:10
问题 The application uses ADO.NET to invoke sprocs for nearly every database operation. Some of these sprocs also contain a fair amount of domain logic. The data access logic for each domain entity resides in the domain class itself. ie, there is no decoupling between domain logic and data access logic. I'm looking to accomplish the following: decouple the domain logic from the data access logic make the domain model persistence ignorant implement the transition to NHibernate gradually across

Parsing criteria in NHibernate

走远了吗. 提交于 2020-01-25 12:57:05
问题 Is it possible to parse criteria from string? 回答1: You're not giving anyone much to go on, so I'll just have to take a guess at what you're trying to ask... If you're looking for a simple criteria.Parse("string here"); then no, I don't such a thing exists. However, the criteria interface lends itself very well to dynamic creation (in fact, that's its intended purpose). As such, yes, you could write a string parser to create ICriteria elements from tokens. Perhaps if you provide more

Upgrade to NHibernate 3.2

谁说我不能喝 提交于 2020-01-25 12:22:48
问题 I have a project by NHibernate (version 2.1). For upgrade to NHibernate 3.2, what should I do? Do I need that upgrade following dll? Antlr3.Runtime Castle.Core Castle.DynamicProxy2 NHibernate.ByteCode.Castle I could not find those dll in NHibernate 3.2. Now what should I do? 回答1: They are not needed any more. Just delete all dlls that are not there any more (except maybe log4net, that's now optional but without it there won't be any logging). You might also get errors in your hibernate.cfg

Upgrade to NHibernate 3.2

♀尐吖头ヾ 提交于 2020-01-25 12:22:23
问题 I have a project by NHibernate (version 2.1). For upgrade to NHibernate 3.2, what should I do? Do I need that upgrade following dll? Antlr3.Runtime Castle.Core Castle.DynamicProxy2 NHibernate.ByteCode.Castle I could not find those dll in NHibernate 3.2. Now what should I do? 回答1: They are not needed any more. Just delete all dlls that are not there any more (except maybe log4net, that's now optional but without it there won't be any logging). You might also get errors in your hibernate.cfg

NHibernate- QueryOver using base classes?

大兔子大兔子 提交于 2020-01-25 01:23:05
问题 Right now I'm using the Criteria API and loving it, but it would be even better if I could make the switch to the QueryOver API. However, my setup is a little strange. In order to partition data into tables, I have one base abstract class: Listing and a number of classes which inherit from that: Listing_UK Listing_US etc. With the criteria API, I can do something like: Type t = typeof(Listing_UK); if (condition) t = typeof(Listing_US); DbSession.CreateCriteria(t) .Add(Restriction.Eq("field"

NHibernate - dynamic QueryOver parameter

一个人想着一个人 提交于 2020-01-24 20:49:06
问题 I have an MVC project that I'm trying to setup a nice paging solution for. I have several tables in SQL Server that have several thousand rows that I would like to be able to page through. If I don't have any type of filter to apply to the paging, it works great. This is the method I'm using to do that: public virtual PagedList<T> GetPagedData(int startIndex, int count) { var rowCount = session.CreateCriteria(typeof(T)).SetProjection(Projections.RowCount()).FutureValue<Int32>().Value; var

How to get object from session with unknown type and id?

冷暖自知 提交于 2020-01-24 20:19:26
问题 What I'm trying to do is get object data from session. Code below should make clear all: //Type of object which i need to get in runtime Type someUnknownType = typeof(someObject); int id = 1; // for example // here i got error cannot resolved someUnknownType ISession.Get<someUnknownType>(id); How can I do that? Edit: someObject is instance variable. 回答1: First, you have a mistake: if someObject is an instance variable, you can't call typeof(someObject) . You can only call someObject.GetType()

nhibernate : how to initialise child list objects

喜夏-厌秋 提交于 2020-01-24 19:25:10
问题 I have the following method in my repository. This works fine, my orderItems are initialised as intended however orderItems contains another collection called OrderItemAddress. These are not initialised. How would i do this? public Model.Order Get(int id) { using (ISession session = NHibernateHelper.OpenSession()) { Model.Order order = session .CreateCriteria(typeof(Model.Order)) .Add(Restrictions.Eq("Id", id)) .UniqueResult<Model.Order>(); NHibernateUtil.Initialize(order.OrderItems); return

Is it one-to-one or Component ? Nhibernate Mapping

别说谁变了你拦得住时间么 提交于 2020-01-24 18:21:17
问题 Assume that I have Person and Address Classes and they have different tables in DB. One Person can have one Address Class in it. This is the important part for me. One Person can have only one Address as it s child element and i want to keep them in different tables in DB. Normally i know that i need to hold them in the same table, but my scenario needs this. (and also it looks like a one-to-many but i dont want to have a collection just for one object) Person Address ------- ------- id id

Error using NHibernate

蓝咒 提交于 2020-01-24 17:47:07
问题 Considering this example as a base example. I created the application but when I execute this application getting the following error. The ProxyFactoryFactory was not configured. Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers. Example: NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu Example: NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle