Questions tagged [fluent-nhibernate]

Fluent NHibernate lets you write NHibernate mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents (.hbm.xml files), Fluent NHibernate lets you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Installation Fluent NHibernate can most easily be installed through its NuGet package.

Install-Package FluentNHibernate

Resources

5486 questions
9
votes
2 answers

Fluent NHibernate - Unnecessary update

In a unidirectional many-to-many relationship between Registration and Item, where a Registration has an ISet ItemsPurchased and Item has no reference back to registrations (it's not a useful way to explore the object graph), when I look at…
9
votes
1 answer

Unrecognized configuration section applicationSettings in NHibernate

I'm using fluent NHibernate. I have an app.config file with few specific keys (applicationSettings and userSettings). It seems that the nhibernate doesn't like these keys. As long as these keys exist in the file, the Fluently.Configure() fails and…
8
votes
3 answers

When using nhibernate, how do I figure out optimal batch size in the mapping code?

I am using nhibernate and i have code like this in the mapping area: HasMany(x => x.People).AsBag().Inverse().Cascade.AllDeleteOrphan().Fetch.Select().BatchSize(80); HasMany(x =>…
leora
  • 188,729
  • 360
  • 878
  • 1,366
8
votes
2 answers

Mapping DayOfWeek from the System namespace using Fluent Nhibernate

I'm currently working on an MVC 3 project which uses Fluent NHibernate. I utilise the System.DayOfWeek enum but when mapping this I received the following error - Stack Trace: [MappingException: Could not determine type for: DayOfWeek, for…
rsw
  • 89
  • 6
8
votes
6 answers

Fluent-NHibernate table mapping with no primary key

I am trying to create a mapping to a database table that has no primary keys/references. public class TestMap : ClassMap<Test> { public TestMap() { WithTable("TestTable"); Map(x => x.TestColumn); } } This fails…
JT
8
votes
5 answers

Based on your experience, how many of you would recommend fluent NHibernate over Nhibernate way of doing things for my new project?

I just want to do a quick poll to see if Fluent Nhibernate is well received or if it is having lot of issues. I like Nhibernate but I definitely see the problem with xml to do mapping. So, I am looking forward to community members for some insight…
Srikar Doddi
  • 15,499
  • 15
  • 65
  • 106
8
votes
1 answer

CompositeId causes Could not compile the mapping document error

I am trying to use CompositeId to map to a legacy system. The source database has a composite primary key so I can't use the normal this.Id mapping. Here is my attempt to map it: public PriorityListPartMap() { this.Schema("EngSchedule"); …
Matthew MacFarland
  • 2,413
  • 3
  • 26
  • 34
8
votes
2 answers

Entity Framework + POCO

I am building a WPF application using the MVVM pattern. Our stack looks like this: SQL Server 2008 -> Entity Framework We use StructureMap for dependency injection to inject our DataFactory which essentially does the CRUD for our POCO business…
Lukasz
  • 8,710
  • 12
  • 44
  • 72
8
votes
1 answer

Generate database with Nhibernate using Fluent NHibernate

I'm trying to use (new with) Fluent NHibernate (trying to switch from XML mapping file to FNH). With the code below, I generated the database, I'm trying to find the same solution but with FNH (I'd like still use hibernate.cfg.xml) : public void…
TheBoubou
  • 19,487
  • 54
  • 148
  • 236
8
votes
1 answer

Fluent nHibernate QueryOver SQL 'CASE' equivalent

Basically what I want to do is to write this piece of SQL: SELECT CASE WHEN t.type = 'a' THEN t.name ELSE t.otherName END as "Name" FROM myTable t in QueryOver
Perpetuum
  • 230
  • 2
  • 10
8
votes
3 answers

Obscure NHibernate/Fluent NHibernate error

I've been encountering the following error when trying to build a session factory: PersistenceTests.Can_Map_Orders_To_Database : Failed System.IndexOutOfRangeException: Index was outside the bounds of the array. at…
Jimit
  • 765
  • 2
  • 10
  • 18
8
votes
2 answers

NHibernate Configuration "current_session_context_class" possible values and descriptions

I currently have this Fluent NHibernate configuration: public class NHibernateConfig { public static Configuration Configure() { var cfg = Fluently.Configure() .Database(Config.PersistenceConfiguration) …
johnofcross
  • 669
  • 1
  • 6
  • 19
8
votes
2 answers

Nhibernate 2nd level caching issues / questions when moving from a single web server to a multiple web server load balanced environment

My previous setup was a single web server and a single database server. I was using nhibernate 2nd level caching to cache stuff to avoid lots of calls going to the database. This has worked great as i was using this this assembly…
leora
  • 188,729
  • 360
  • 878
  • 1,366
8
votes
2 answers

NHibernate with Firebird... are these features enabled?

We're using NHibernate to great success with a Firebird backend. My question relates to the features available in NHibernate being supported by Firebird. If you have any expertise with Firebird and NHibernate your comments are welcome. Does…
Kotarsi
  • 81
  • 2
8
votes
4 answers

How to add mappings by namespace in Fluent NHibernate

In my application, I need to talk to multiple databases. I am handling this in NHibernate by creating one SessionFactory per database (I assume this is the correct thing to do). So I have two sets of models (one per database), and two sets of Fluent…