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
1 answer

Fluent Nhibernate Mapping for Sql Views

i am using Fluent Nhibernate in asp.net mvc3 with c# i am working in following way to generate and map a class Mapping using FluentNHibernate.Mapping; using Com.Web.Domain; namespace Com.Web.Mapping { public class CompanyMap :…
12
votes
3 answers

NHibernate Image Storage - The length of the byte[] value exceeds the length configured

I am using Fluent NHibernate and am trying to store an image. Small images work, but larger images do not, and I receive this error when saving to the database (SQL Server): Exception: Error dehydrating property value for…
jkriddle
  • 708
  • 1
  • 6
  • 15
12
votes
1 answer

Generate table for mapping IPAddress as INET type in PostgreSQL?

I got a mapping that maps IPAddress object field to database. There is inet type in PostgreSQL suited for this, but in my case it uses bytea type instead when it generates schema. Is there a way to force resulting generated schema type for this…
Valentin Kuzub
  • 11,703
  • 7
  • 56
  • 93
11
votes
11 answers

NHibernate, a different object with the same identifier value was already associated with the session

I have been working with NHibernate, using Fluent NHibernate for mapping. I solved a lot of issues, and started to think myself as experienced in nhibernate. However, this error is quite strange. This is my model: public class MessageNew …
SadullahCeran
  • 2,425
  • 4
  • 20
  • 34
11
votes
2 answers

NHibernate inconsistent sql column alias

When looking at our queries from NHibernate it's clear that the column alias is not consistent, that a problem for performance when the sql server execution plan seeing the same query as different query's because of the inconsistent column alias. An…
Lehto
  • 257
  • 1
  • 14
11
votes
1 answer

Fluent nHibernate: Unsupported mapping type

I'm setting up a new solution to map against SQL data that has been imported from an Access database. Auto Mappings work fine against the entities I have defined but I need to be able to use the Fluent mapping type to give access to the…
11
votes
1 answer

How to alter column using nhibernate SchemaUpdate functionality

I have entity model which I want to be reflected to database each time I run application but without clearing the data thus I'm using SchemaUdpate with fluent nhibernate mappings method in a way var config =…
tchrikch
  • 2,428
  • 1
  • 23
  • 43
11
votes
3 answers

NHibernate - KeyNotFoundException: The given key was not present in the dictionary

Update: I have fixed this issue I have the following block of code which should ultimately update a record if (session.Contains(entity)) { session.Evict(entity); } which errors on Session.Evict(entity) with a KeyNotFoundException, and the…
Michael S
  • 4,352
  • 5
  • 23
  • 29
11
votes
3 answers

Fluent NHibernate - How to map the foreign key column as a property

I am sure this is a straightforward question but consider the following: I have a reference between company and sector as follows: public class Company { public Guid ID { get; set; } public Sector Sector { get; set; } public Guid…
Steve
11
votes
1 answer

Fetch.Join() not working in Fluent NHibernate

I have the following mapping override on one side of the relationship: public void Override(AutoMapping mapping) { mapping.HasMany(x =>…
MylesRip
  • 1,212
  • 17
  • 29
11
votes
1 answer

Fluent NHibernate generates extra columns

We are using Fluent NHibernate for data object model in the company i work. A couple of days ago, we encountered an issue that Fluent NHibernate generates an extra column which does exist neither in model nor in mapping. Here is the situation: My…
11
votes
2 answers

Why is NHibernate saving objects when I never execute session.Save?

I'm using NHibernate with Fluent NHibernate. I have code where I start a transaction, then I enter a loop which creates several objects. For each object I check certain conditions. If these conditions are met, then I execute a…
MylesRip
  • 1,212
  • 17
  • 29
11
votes
4 answers

Fluent-NHibernate many-to-many cascade does not populate the link table

OK, no matter how I define these mappings, my many-to-many mapping does not want to work with cascade insert. I have tried various combination of Cascade() with Reverse() and removing all unnecessary properties just to understand if they had…
Aliostad
  • 80,612
  • 21
  • 160
  • 208
11
votes
1 answer

Disconnect object from NHibernate session

In my nhibenate session I Mapping object with AutoMapper and in the afterMap action i create new instance of the object because I extract the object from the DB for properties compare. So The AutoMapper create two instances of one object with the…
user556882
  • 121
  • 1
  • 5
11
votes
4 answers

NHibernate Profiler - large discrepancy between database duration and total duration?

I have an application that makes extensive use of NHibernate. I've started using the NHibernate Profiler to identify possible performance issues. My question is related to the Query Durations statistic. The stat is broken down in Database Duration…
Mark Sherretta
  • 10,160
  • 4
  • 37
  • 42