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

NHibernate IQueryable collection as property of root

I have a root object that has a property that is a collection. For example: I have a Shelf object that has Books. // Now public class Shelf { public ICollection Books {get; set;} } // Want public class Shelf { public…
Khalid Abuhakmeh
  • 10,709
  • 10
  • 52
  • 75
14
votes
2 answers

Ensure NHibernate SessionFactory is only created once

I have written an NHibernateSessionFactory class which holds a static Nhibernate ISessionFactory. This is used to make sure we only have one session factory, and the first time OpenSession() is called I create the actuall SessionFactory - next times…
stiank81
  • 25,418
  • 43
  • 131
  • 202
14
votes
2 answers

AssertionFailure: "null identifier" - FluentNH + SQLServerCE

The code fails at session.Save(employee); with AssertionFailure "null identifier". What am I doing wrong? using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using FluentNHibernate.Mapping; using NHibernate; using NHibernate.Cfg; using…
Stefan
  • 4,166
  • 3
  • 33
  • 47
14
votes
4 answers

Is NHibernate SchemaUpdate safe in production code?

For simplicity's sake. I'm using Fluent NHibernate's Automapping combined with NHibernate's SchemaUpdate during runtime. On each run Automapper creates mappings for all entity classes and SchemaUpdate applies the schema to the existing database. I…
Kenneth Cochran
  • 11,954
  • 3
  • 52
  • 117
14
votes
2 answers

Mapping nested components in Fluent NHibernate

I have a 'User' Entity that contains an 'Address' Value Object. I have this mapping ok using FNH's Component concept. However, the Address VO also contains a Country which is another value object. I had assumed that this should be just nested as…
UpTheCreek
  • 31,444
  • 34
  • 152
  • 221
14
votes
2 answers

fluent nhibernate auto increment non key (Id) property

Is it possible to have an integer property of a class auto increment managed by the database but not be a primary key (or Id as NHibernate refers to them)? I'm having trouble finding examples of how to do this. Any help would be appreciated. …
Matt Florence
  • 688
  • 6
  • 9
14
votes
6 answers

How do I get fluent nhibernate to create a varbinary(max) field in sql server

How can I get fluent nhibernate to create a varbinary field in a sql server 2005 table that uses a field size of varbinary(max)? At the moment I always get a default of varbinary(8000), which isn't big enough as i'm going to be storing image…
czk
  • 151
  • 1
  • 1
  • 5
13
votes
3 answers

Fluent NHibernate Cascade Issue - Trying To Insert NULL ID

I have the following models & mappings (code snippets further below). One Competition has to have multiple CompetitionAnswers associated with it (multiple choice) from the outset. At present, using the Fluent NHibernate mappings shown below, when I…
marcusstarnes
  • 6,393
  • 14
  • 65
  • 112
13
votes
2 answers

How do you map an enum as string in fluent nhibernate?

Is it possible to map an enum as a string using Fluent Nhibernate?
Chris Conway
  • 16,269
  • 23
  • 96
  • 113
13
votes
3 answers

Fluent Nhibernate 1.0 - Specify foreign key constraint name between class and joined subclass

I think this should be simple, but I can't figure out how to do it. Suppose I have the following maps: public class AnimalMap : ClassMap { Id( x => x.Id); } public class CatMap: SubclassMap { Extends(); Map(x =>…
13
votes
2 answers

Does Fluent-NHibernate support mapping to procedures?

I've been wondering if it's possible to have Fluent-NHibernate communicate with stored procedures that already exist and assign mapping from the result set to my own domain objects. Also is Fluent-NHibernate able to directly execute procedures with…
13
votes
4 answers

Setting string to be sql type of "varchar" instead of "nvarchar"

I have the following mapping: public class LogEntryMap { public LogEntryMap() { Map.Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.Context).CustomSqlType("varchar").Length(512); } } However, using SchemaExport to…
Ted
  • 7,122
  • 9
  • 50
  • 76
13
votes
3 answers

MS Entity Framework VS NHibernate and its derived contribs (FluentNHibernate, Linq for NHibernate)

I just read this article about the Entity Framework 4 (actually version 2). Entity Framework seems to offer a huge improvement over its first release. Thus, I have never ever used EF in any project, since I think EF is not mature enough in…
Will Marcouiller
  • 23,773
  • 22
  • 96
  • 162
13
votes
1 answer

nhibernate, could not resolve property

I have a problem with NHibenate. When I run queryover, I get an error "could not resolve property: User.Name of: MegaOnlineChat.Core.Entities.Message".What am I doing wrong? Entity objects public class EntityObject { public virtual…
valik
  • 171
  • 1
  • 1
  • 9
12
votes
2 answers

Inserts of stateless session of NHibernate are slow

It's been a couple of days that I'm working on improving NHibernate Insert performance. I'd read in many posts (such as this one) that stateless session can insert like 1000~2000 records per second.... However the best time that it could insert…
Javid_p84
  • 848
  • 2
  • 12
  • 26