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

Generic Repository session management asp.net-mvc fluent nhibernate

I have gotten into a problem with my project. I am using a generic repository with structure map together with Fluent NHibernate. Everything works rather well, but when it comes to transactions and session management I have really no clue what to…
2
votes
1 answer

How can I Map a substring to a property with a Fluent Nhibernate Mapping Override?

I have a string property on a class that I would like mapped to a Substring of another column. Lets say this is my class: public class MyClass { public virtual string PartNumber { get; set; } public virtual string PartNumberPortion { get; set;…
shanabus
  • 12,989
  • 6
  • 52
  • 78
2
votes
3 answers

Adding conditions to outer joins with NHibernate ICriteria/QueryOver query

Is there a way to specify additional conditions on outer joins in NHibernate when querying using QueryOver or ICriteria? I need some extra conditions on the outer join-ed table, but NHibernate always adds them to the WHERE clause at the end - which…
James Crowley
  • 3,911
  • 5
  • 36
  • 65
2
votes
1 answer

NHibernate: Prevent Refresh to trigger uninitialized Collections

I have an Entity with a Collection, which holds other entities having more References on Entities. When the Entity is loaded and later refreshed, the lazy loaded collection is triggered and a lot of stuff is pulled from database which i dont need.…
Firo
  • 30,626
  • 4
  • 55
  • 94
2
votes
1 answer

C# NHibernate Simple Question

I'm using NHibernate-driven repository, Fluent mappings and attempt to use Linq to NHibernate. But for some simple query like this Retrieve(x => (x.Timestamp.CompareTo(start) >= 0 && x.Timestamp.CompareTo(end) <= 0…
Yippie-Ki-Yay
  • 22,026
  • 26
  • 90
  • 148
2
votes
3 answers

Table with a foreign key

how can I build a table of "orders" containing "IdOrder", "Description" and "User"?... the "User" field is a reference to the table "Users", which has "IdUser" and "Name". I'm using repositories. I have this repository: Repository
Thiago
  • 1,547
  • 3
  • 25
  • 40
2
votes
3 answers

nHibernate [TransactionAttribute] for UoW conflicts with Repository Pattern

Doing research into the best way to design IRepository structures, I came across a project called 'Whiteboard' (http://whiteboardchat.codeplex.com/) while looking through some forums for NHProf. I dug around its source code for a while, and…
Ciel
  • 17,312
  • 21
  • 104
  • 199
2
votes
1 answer

Fluent NHibernate Generated.Insert does not work as expected

I want to auto generate a number for an entity from the database with the following mapping: Map(m => m.No).Not.Nullable().ReadOnly().Unique().Generated.Insert(); Why is no value generated for the property "No" of type int? This is not an identity…
Rasmus Christensen
  • 8,321
  • 12
  • 51
  • 78
2
votes
1 answer

Update NHibernate object with child collection

I am trying to update an nHibernate object with a child collection using the .Update() method found on a hibernate session. The only thing that I can do with the current setup is add children, I can not modify them or remove them. For clarification…
Djim
  • 93
  • 8
2
votes
3 answers

Confused about Separation of Concerns with nHibernate's ISession and Eager Loading

I have an application built using Fluent NHibernate and ASP.NET MVC. It is divided into 5 projects, at the moment. WEB The ASP.NET MVC project contains only the HTML, CSS, Controllers, and very project specific Validators and Model Binders, as well…
Ciel
  • 17,312
  • 21
  • 104
  • 199
2
votes
1 answer

NHibernate does not filter data base on COORECT TYPE of meta data

I have an interface (IContactable) which is realizing by 3 classes : Person, Department, RestUnit public interface IContactable { Contact Contact { get; set; } string Title { get; } int? Id { get; set; } } public class…
Javid_p84
  • 848
  • 2
  • 12
  • 26
2
votes
2 answers

Nhibernate duplicating column

I want to mapping following simple entities: public class AnimalsOwner { public AnimalsOwner() { Cats = new List(); Dogs = new List(); } public virtual int Id { get; set; } public virtual IList
Sly
  • 15,046
  • 12
  • 60
  • 89
2
votes
1 answer

Fluent NHibernate mapping properties coming from an interface in one place

If many classes implement the same interface(s), is it possible to map those interface properties in one place? There's more code @ pastebin You can see here that classes have some common interfaces (but not all to make common base class) and I had…
Mike Koder
  • 1,898
  • 1
  • 17
  • 27
2
votes
3 answers

NHibernate Multiple Event Listeners

Is it possible to register multiple event listeners? We currently register event listeners using .ExposeConfiguration(AddSoftDelete) in which AddSoftDelete is a class registering the listener; private static void AddSoftDelete(Configuration…
Wozart
  • 125
  • 1
  • 7
2
votes
1 answer

Fluent Nhibernate and Custom Collections

I have the following Fluent NHibernate configuration... public class TemplateMap : ClassMap