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
33
votes
3 answers

Mapping enum with fluent nhibernate

I am following the http://wiki.fluentnhibernate.org/Getting_started tutorial to create my first NHibernate project with Fluent NHibernate I have 2 tables 1) Account with fields Id AccountHolderName AccountTypeId 2) AccountType with…
Puneet
  • 1,014
  • 1
  • 8
  • 14
32
votes
5 answers

Install NHibernate 3.2 with NuGet

I'm new to NHibernate and have been trying to get up and running with it, Fluent NHibernate and NHProf using NuGet. After reading this article (http://gurustop.net/blog/2011/03/13/nhibernate-3-1-0-on-nuget-important-details) it seems that v3.1…
RuairiQ
  • 431
  • 1
  • 5
  • 9
32
votes
3 answers

Difference between FluentNHibernate and NHibernate's "Mapping by Code"

I am coming from an Entity Framework and LLBL background for my ORM tools. I have been asked to build a new system based on NHibernate. I have never done so, so I am coming at it with fresh eyes. What is the difference between mapping with Fluent…
30
votes
2 answers

Problem with linq query

I'm trying to use linq to NHibernate (with Fluent NHibernate) but I have problems with linq query. Everytime I try to execute it I get this message : "Method 'get_IsReadOnlyInitialized' in type 'NHibernate.Linq.Util.DetachedCriteriaAdapter' …
Athina
  • 533
  • 5
  • 20
29
votes
3 answers

How to tell Fluent NHibernate not to map a class property

I have a class that is mapped in fluent nhibernate but I want one of the classes properties to be ignored by the mapping. With class and mapping below I get this error: The following types may not be used as…
modernzombie
  • 1,987
  • 7
  • 25
  • 44
29
votes
4 answers

Fluent nhibernate one to one mapping

How do I make a one to one mapping. public class Setting { public virtual Guid StudentId { get; set; } public virtual DateFilters TaskFilterOption { get; set; } public virtual string TimeZoneId { get; set; } public virtual string…
chobo2
  • 83,322
  • 195
  • 530
  • 832
29
votes
4 answers

Class Map Generator for Fluent NHibernate

Is there a Class Map generator for Fluent NHibernate? I need something like db2hbm but I want it to generate Fluent Class Maps instead of xml mappings. I am aware of AutoMapping for Fluent but that is not what I want. I want to be able to generate…
kaptan
  • 3,060
  • 5
  • 34
  • 46
28
votes
8 answers

How do add NOLOCK with nHibernate?

How do you add NOLOCK when using nhibernate? (criteria query)
mrblah
  • 99,669
  • 140
  • 310
  • 420
27
votes
1 answer

Fluent NHibernate entity HasMany collections of different subclass types

So everything is working well with the basic discriminator mapping. I can interact directly with entities A and B without any problems. public class BaseType {} public class EntityA : BaseType {} public class EntityB : BaseType {} This maps without…
berko
  • 2,935
  • 4
  • 26
  • 31
26
votes
1 answer

NHibernate Eager loading multi-level child objects

I have a hierarchy of objects, Order, Contact, Address: public class Order { public virtual Contact BillingContact { get; set; } } public class Contact { public virtual Address Address { get; set; } } I want to query an order by id, and…
Sam Mueller
  • 445
  • 1
  • 4
  • 9
26
votes
2 answers

How to create composite UNIQUE constraint in FluentNHibernate?

I know that I can Map(x => x.GroupName).WithUniqueConstraint() for a single property. But how do create a composite unique constraint in fluent nHibernate (where the unique constraint operates on the combination of two columns)?
Nathan
  • 10,593
  • 10
  • 63
  • 87
25
votes
5 answers

Programming to interfaces while mapping with Fluent NHibernate

I have been whipped into submission and have started learning Fluent NHibernate (no previous NHibernate experience). In my project, I am programming to interfaces to reduce coupling etc. That means pretty much "everything" refers to the interface…
Rune Jacobsen
  • 9,907
  • 11
  • 58
  • 75
25
votes
3 answers

Generate table indexes using Fluent NHibernate

Is it possible to generate table indexes along with the rest of the database schema with Fluent NHibernate? I would like to be able to generate the complete database DDL via an automated build process.
Todd Brooks
  • 1,167
  • 1
  • 13
  • 24
25
votes
4 answers

Eager Loading Using Fluent NHibernate/Nhibernate & Automapping

I have a requirement to load a complex object called Node...well its not that complex...it looks like follows:- A Node has a reference to EntityType which has a one to many with Property which in turn has a one to many with PorpertyListValue public…
nabeelfarid
  • 4,156
  • 5
  • 42
  • 60
25
votes
4 answers

Fluent NHibernate & one-to-one

For a (very) long time I've been looking for an example on how to correctly implement a one-to-one mapping with Fluent NHibernate. Most resources I find say: I think you mean a many-to-one However no one actually gives an example on how to…
Bruno Reis
  • 37,201
  • 11
  • 119
  • 156