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
12
votes
2 answers

How to activate the second level cache on a lazy loaded property with own user type?

Preface: In my application, I store raw WAV data in the database as byte[]. In my domain model there is a class PcmAudioStream that represents that raw WAV data. I created an implementation of NHibernate's IUserType to convert between my class and…
Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
12
votes
1 answer

Inserting parent and children with NHibernate at the same time

I am attempting to save(insert) a Parent entity with list Child entities. Both entites use a Guid as primary keys. The keys are none nullable and there is no key relationship set up in the db. The save doesn't work, an exception is thrown claiming -…
Dan
  • 29,100
  • 43
  • 148
  • 207
12
votes
4 answers

How does one make NHibernate stop using nvarchar(4000) for insert parameter strings?

I need to optimize a query that is being produced by a save (insert query) on a domain entity. I've configured NHibernate using Fluent NHibernate. Here's the query generated by NHibernate during the insertion of a user's response to a poll: exec…
12
votes
2 answers

NHibernate - How to map to a class that has no table (for custom sql queries)

Update - Edited config for readability in SO Hi, I've been learning NHibernate for a day or two but getting stuck on one point. I need to be able to execute custom stored procedures and use NHibernate to map them back to domain classes. I have…
gbro3n
  • 6,729
  • 9
  • 59
  • 100
12
votes
2 answers

nhibernate "cascade="all-delete-orphan" error

i have 3 tables in my database: Projects (id, name) Tags (id, name) ProjectsTagss (id, projectId, tagid) As you can see the ProjectsTags table is a bridge table here is my fluent nhibernate mapping ProjectMap.cs: Map(x =>…
leora
  • 188,729
  • 360
  • 878
  • 1,366
12
votes
1 answer

Help with QueryOver and WhereExists

I have a problem. I have Persons and Cats. Each Person has some Cats (there is a foreign key in Cats that points to the primary key in Persons). Each Cat has an Age. I want to select the Persons that have "Old" Cats. I want ALL the Cats of these…
xanatos
  • 109,618
  • 12
  • 197
  • 280
12
votes
3 answers

Fluent nHibernate automapping property as nvarchar(max)

using fluent nhibernate, and automappings (nhibernate creates my db schema), how can i get nhibernate to create a nvarchar(max) column in the database based on the following class public class VirtualPage : BaseEntity { public virtual int…
stoic
  • 4,700
  • 13
  • 58
  • 88
12
votes
7 answers

Problems using FluentNHibernate + SQLite with .NET4?

I have a WPF application running with VS2010 .Net3.5 using Nhibernate with FluentNHibernate + SQLite, and all works fine. Now I want to change to use .Net4, but this has turned into a more painful experience then I expected.. When setting up the…
stiank81
  • 25,418
  • 43
  • 131
  • 202
12
votes
2 answers

Fluent NHibernate caching with automapping

I'm trying to understand how to configure Fluent NHibernate to enable 2nd-level caching for queries, entities, etc... And at the same time use automapping. There is very little information online on how to do that. Sure it can be done when mapping…
md1337
  • 1,440
  • 2
  • 16
  • 32
12
votes
2 answers

Make Fluent NHibernate output schema update to file

I am successfully getting Fluent NHibernate to update my database by calling UpdateBaseFiles: Public Sub UpdateBaseFiles() Dim db As SQLiteConfiguration db = SQLiteConfiguration.Standard.UsingFile(BASE_DBNAME) Fluently.Configure() _ …
Bender
  • 1,688
  • 2
  • 14
  • 20
12
votes
3 answers

How to get Fluent NHibernate working with NHibernate 3.x

How to get Fluent NHibernate working with latest NHibernate 3.x trunk I got the following Exception : Could not load file or assembly 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its…
Yoann. B
  • 11,075
  • 19
  • 69
  • 111
12
votes
1 answer

IndexOutOfRangeException Deep in the bowels of NHibernate

I have the following mappings: public class SecurityMap : ClassMap { public SecurityMap() { Table("Security"); CompositeId().KeyProperty(k => k.Id, "SecurityId").KeyProperty(k => k.EndDate); …
NotMyself
  • 29,209
  • 17
  • 56
  • 74
12
votes
5 answers

Why Fluent NHibernate vs. hbm XML files?

While this is a subjective question, as a new NHibernate user, I'm curious as to why one would choose Fluent vs traditional XML mapping. From my standpoint, when I first worked with NHibernate, I used the Fluent interface, but ran into some…
Bob Palmer
  • 4,714
  • 2
  • 27
  • 31
12
votes
3 answers

Fluent NHIbernate automapping of List?

Fluent NHibernate doesn't like this, throwing an error: {"Association references unmapped class: System.String"} OK fine, I can see why this would cause a problem - but what's the best solution? I don't really want it to store a delimited list of…
Alex
  • 3,099
  • 6
  • 41
  • 56
12
votes
1 answer

Fluent NHibernate Default Conventions

I'm trying to find a resource that shows what default conventions Fluent NHibernate uses with no custom (user) conventions applied. Thanks!
Steve Horn
  • 8,818
  • 11
  • 45
  • 60