fluent-nhibernate

Is it possible to use NHibernate without altering a DDD model that is part of a framework

不羁的心 提交于 2019-12-20 09:38:25
问题 I dig a lot of things about the DDD approach (Ubiquitous language, Aggregates, Repositories, etc.) and I think that, contrary to what I read a lot, entities should have behavior rather then being agnostic. All examples I see tend to present entities with virtual automatic properties and an empty constructor (protected or worst, public) and that's it. I consider this kind of objects more like DTOs then entities. I'm in the process of creating a framework with its specific API and I don't want

Where can i find a Fluent NHibernate Tutorial?

二次信任 提交于 2019-12-20 08:39:41
问题 I have googled and looked around does anyone know of any hidden gems out there that is not in first couple pages of a google search.... 回答1: The wiki is your best bet. I've had a few Fluent NHibernate posts on my blog, but most of that content is mirrored on the wiki anyway. 回答2: I appreciate this tutorial, perhaps can help you: http://nhforge.org/blogs/nhibernate/archive/2008/09/17/value-objects.aspx The author explain the concept of value object, using them like components. 回答3: That helped

Linq Nhibernate left join

不羁的心 提交于 2019-12-20 07:52:28
问题 A Theft has an action property This is the query i'm trying to get NHibernate.Linq to produce: SELECT * FROM `thefts` LEFT JOIN memberThefts ON thefts.id = memberThefts.theftId AND memberThefts.memberId = 1 I want to get a list of all the thefts where action.memberId == some number or just null if it doesn't find a row, simple as a query yet it's been giving me a nightmare all day! thefts = session.Query<Theft>() .Fetch(x => x.action) .Where(x => x.action.memberId == member.id) .ToList();

Rollback to a specfic Migration in FluentMigrator

空扰寡人 提交于 2019-12-20 06:51:20
问题 Suppose I have crated a three Table using FluentMigrator and gave them version Number 1, 2, 3 respectively. Now Is there any way to rollback till version 2. I mean After rollback I should have Table 1 and 2 but not 3. 回答1: Here is a batch file I use with the command line runner tool @echo off if "%1" == "rollback" goto rollback if "%1" == "" goto migrate if "%1" == "version" goto version if "%1" == "down" goto down goto error :migrate migrate -db SqlServer2014 -connection "Server=[YOUR

Rollback to a specfic Migration in FluentMigrator

江枫思渺然 提交于 2019-12-20 06:50:46
问题 Suppose I have crated a three Table using FluentMigrator and gave them version Number 1, 2, 3 respectively. Now Is there any way to rollback till version 2. I mean After rollback I should have Table 1 and 2 but not 3. 回答1: Here is a batch file I use with the command line runner tool @echo off if "%1" == "rollback" goto rollback if "%1" == "" goto migrate if "%1" == "version" goto version if "%1" == "down" goto down goto error :migrate migrate -db SqlServer2014 -connection "Server=[YOUR

Accept Interface into Collection (Covariance) troubles with nHibernate

孤街浪徒 提交于 2019-12-20 06:07:17
问题 I am using Fluent nHibernate for my persistence layer in an ASP.NET MVC application, and I have come across a bit of a quandry. I have a situation where I need to use an abstraction to store objects into a collection, in this situation, an interface is the most logical choice if you are looking at a pure C# perspective. Basically, an object ( Item ) can have Requirements . A requirement can be many things. In a native C# situation, I would merely accomplish this with the following code.

Accept Interface into Collection (Covariance) troubles with nHibernate

我只是一个虾纸丫 提交于 2019-12-20 06:06:32
问题 I am using Fluent nHibernate for my persistence layer in an ASP.NET MVC application, and I have come across a bit of a quandry. I have a situation where I need to use an abstraction to store objects into a collection, in this situation, an interface is the most logical choice if you are looking at a pure C# perspective. Basically, an object ( Item ) can have Requirements . A requirement can be many things. In a native C# situation, I would merely accomplish this with the following code.

How implement the Open Session in View pattern in NHibernate?

二次信任 提交于 2019-12-20 05:23:50
问题 I'm using ASP.NET MVC + NHibernate + Fluent NHibernate and having a problem with lazy loading. Through this question ( How to fix a NHibernate lazy loading error "no session or session was closed"? ), I've discovered that I have to implement the Open Session in View pattern , but I don't know how. In my repositories classes, I use methods like this public ImageGallery GetById(int id) { using(ISession session = NHibernateSessionFactory.OpenSession()) { return session.Get<ImageGallery>(id); } }

using fluent-nhibernate and traditionally hbm.xml together

让人想犯罪 __ 提交于 2019-12-20 04:59:09
问题 So far I used this code to configure a session factory: Configuration configuration = new Configuration(); configuration.Configure(); SessionFactory = configuration.BuildSessionFactory(); Now I added some fluentNhibernate mapping classes, and used this code to configure: Configuration configuration = new Configuration(); configuration.Configure(); SessionFactory = configuration.BuildSessionFactory(); SessionFactory = Fluently.Configure(configuration).Mappings(m => { m.FluentMappings

NHibernate Mapping Breaks when upgrading to NHibernate 3.1

陌路散爱 提交于 2019-12-20 04:52:17
问题 I just recently upgraded to FluentNHibernate 1.2 which uses NHibernate 3.1. After upgrading some of my old mappings are not working. I've been having a hard time figuring out why, I thought maybe someone here could help. I have 3 classes, Practice, Drill, and PracticeDrill. A Practice has many Drills and a Drill can be in many Practices. PracticeDrill is the table that joins them and also includes an Order. Here are my C# POCOs: public class PracticeDrill { public virtual Practice Practice {