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
18
votes
6 answers

Is it possible to create a database using NHibernate?

I am using NHibernate with FluentNHibernate for my DAL. I am also using SchemaExport and SchemaUpdate to create and update my database schema. My problem is that the schema operations all require the database to exist before they will work. I want…
Andrew
  • 285
  • 1
  • 2
  • 11
18
votes
2 answers

Fluent Nhibernate Many to Many Mapping Way

I have two classes Order and Items I want a method like this class Order { public virtual IList GetItems(Order order) { //get items for that order. } } class Item { public virtual IList GetOrders(Item item) …
Infant Dev
  • 1,659
  • 8
  • 24
  • 48
18
votes
5 answers

Ignore public/internal fields for NHibernate proxy

I have some entity types that I would like to lazy load. However, they have some internal (assembly) fields they expose, but are not used outside that class. These fields are compiler generated (F#) and I cannot change them. The an example exception…
MichaelGG
  • 9,976
  • 1
  • 39
  • 82
18
votes
3 answers

NHibernate configuration for uni-directional one-to-many relation

I'm trying to set up a relationship as follows. Each Master item has one or more Detail items: public class Detail { public virtual Guid DetailId { get; set; } public virtual string Name { get; set; } } public class Master { public…
gregmac
  • 24,276
  • 10
  • 87
  • 118
18
votes
2 answers

How to store a non truncated varchar(max) string with NHibernate and Fluent NHibernate

My DB schema has a string as a varchar(max). I have read the other questions concerning setting Length to more than 4000 or 8000 so that it really generates a (n)varchar(max) in the mapping but when I use Length(10000) in my mapping class, the hbm…
Nicolas Cadilhac
  • 4,680
  • 5
  • 41
  • 62
18
votes
3 answers

nhibernate mapping: A collection with cascade="all-delete-orphan" was no longer referenced

I am having some probs with my fluent mappings. I have an entity with a child collection of entities i.e Event and EventItems for example. If I set my cascade mapping of the collection to AllDeleteOrphan I get the following error when saving a new…
Samuel Goldenbaum
  • 18,391
  • 17
  • 66
  • 104
18
votes
2 answers

Optimizing nhibernate session factory, startup time of webApp really slow

I have implement testing app. which uses fluent nhibernate mapping to db object inside mssql db. Since I want to learn fine tune nhib. mvc3 applications, I'm using this app. for testing purposes which have only one simple entity with 10 enum…
BobRock
  • 3,477
  • 3
  • 31
  • 48
17
votes
1 answer

FluentNHibernate and NuGet, problem with NH version

I just updated my project to use NuGet for external references. I added reference to NHibernate, which added all other dependencies for NH. Than I added FluentNHibernate. Versions of NH downloaded for NH and Fluent do not match. NuGet shows version…
epitka
  • 17,275
  • 20
  • 88
  • 141
17
votes
1 answer

Fluent Nhibernate Many-to-Many mapping with extra column

I want to map sth like this using fluent Nhibernate but I am not sure how to map the inventory table This is the tables I have : Product (Id,Name, ...) Warehouse(Id, Name, ...) Inventory(Product_id, Warehouse_id, StockInHand) and Mappings like…
pang
  • 3,964
  • 8
  • 36
  • 42
17
votes
3 answers

Generate XML mappings from fluent Nhibernate

How do I generate xml mappings files as part of my tests in MappingIntegrationTests I need to manually check if the fluent mappings correlate to the mappings in the leagcy project.
17
votes
3 answers

How to add event listener via Fluent NHibernate?

I want to add an event listener (IPreUpdateEventListener) to add NHibernate but I can't seem to find an example when using a fluent configuration. I want to be able to add the listener when I create the session factory, e.g. when the following code…
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
17
votes
2 answers

Fluent Nhibernate left join

I want to map a class that result in a left outer join and not in an innner join. My composite user entity is made by one table ("aspnet_users") and an some optional properties in a second table (like FullName in "users"). public class UserMap :…
Ronnie
  • 4,959
  • 10
  • 51
  • 69
16
votes
4 answers

Do Fluent NHibernate and migratordotnet play nicely together?

I love Fluent NHibernate for building my DBs and so far haven't found a restriction that has halted me in my tracks. However on my current project I expect to release to production very early in the product lifecycle and hence expect there to be…
16
votes
2 answers

VIEWS and Fluent NHibernate?

It's possible to map a VIEW using Fluent NHibernate? If so, how?
rguerreiro
  • 2,673
  • 3
  • 22
  • 23
16
votes
2 answers

How do I handle table relationships with the repository pattern?

I'm implementing the repository pattern as part of an ASP.NET MVC site. Most examples I've seen of repositories are fairly simple. For example here's a typical abstract repository interface. public interface IRepository { …