Questions tagged [fluent-nhibernate-mapping]

Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate

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.

Resources

626 questions
2
votes
0 answers

Unable to locate persister for the entity named

I am trying to connect to nHibernate but I did not do that. I have a configuration file which is look like below
Shohel
  • 3,886
  • 4
  • 38
  • 75
2
votes
0 answers

Fluent NHibernate mapping with aggregated class

I need help with a fluent NHibernate map configuration of a class with aggregation. The following code displays the class Provider with property Logo of type Image. My problem is that the property Logo.EntityId should have the Provider.Id. When I…
2
votes
0 answers

FluentNHibernate SubclassMap set entire class ReadOnly

I have a Class that I want to set readonly using Fluent NHibernate. On a normal ClassMap this can be done. But I can find no way of doing this on a Subclass without moving all the mapping into the subclass and no longer using inheritance. Maybe…
2
votes
1 answer

FNH Mapping Overrides on HasMany

Sorry for the wall of text please don't TLDR. I have a very simple object model, basically it's public class Colony { public virtual IList Ants { get; set; } } public class Ant { public bool Dead { get; set } public virtual…
2
votes
2 answers

NHibernate fluent mapping to an entity property

I have a table called "Customers" and in this table there are store and office address. In the code there is a Customer class with two properties that are of type Address (one for StoreAddress and OfficeAddress). public class Customer { public…
2
votes
1 answer

NHibernate map one-to-many relationship with intermediate table

How to define mapping without intermediate class PostTag creation? I have three tables t_post(id...) t_tag(id, name) t_post_tag(id,post_id, tag_id) I want to have a collection with Tags in Post type classes: class Post { public virtual…
2
votes
1 answer

Mapping Geometry from SQLServer2008 to .NET (NHibernate 4.0.0.4000)

I try to map a SqlServer2008 geometry with FluentNHibernate. I am using NHibernate version 4.0.0.4000. I installed NHibernate.Spatial, NetTopologySuite, GeoAPI and NHibernate with FluentNhibernate all with NUget. My Fluent mapping looks like…
Philipp
  • 649
  • 2
  • 7
  • 23
2
votes
1 answer

c# Fluent nHibernate primary key is foreign key

My database layout looks like this: Users ------------ |UserId | <-PK |FirstName | |LastName | |MiddleName| |Email | ------------ Admins ------------ |UserId | <-PK/FK to Users ------------ I Just want the ability to put in the unique…
dangerisgo
  • 1,261
  • 3
  • 16
  • 28
2
votes
1 answer

Fluent NHibernate HasManyToMany with a discriminator column specifying relationship type

I'm using Fluent NHibernate and I'm trying to map a many-to-many property that simply bypasses the join table. The tricky thing is, the join table has a column that determines what type of relationship it is. For the purpose of this question, let's…
2
votes
2 answers

Fluent Nhibernate List mapping

I have a simple class with a IList property. How to map this property in Fluent Nhibernate ? [Serializable] public class ExportTask { private IList _csvExportList = new List(); public ExportTask() {} public…
2
votes
1 answer

Fluent NHibernate Mapping: one-to-one (or none)

I have a following database scheme setup which I can't really change. User ---- Id (primary key) [Some simple properties...] UserAdditionalData ------------------ Id (primary key) [Some simple properties...] USERID (foreign key to…
2
votes
1 answer

How to map composite foreign key to a non-primary unique key in FluentNHibernate?

I need to map a legacy db that has composite foreign keys referring to non-primary unique keys. First, I was trying to map it in EntityFramework. Unfortunately, I have found that EntityFramework (or at least 5.0) does not support that. Now, I am…
TN.
  • 18,874
  • 30
  • 99
  • 157
2
votes
0 answers

Multple Composite PrimaryKey reference as foreign key map in Fluent nHibernate

This is a legacy table structure hence no Schema modification is possible. Patient ------- Code - PK HospitalCode - PK - FK with Hospital.Code HospitalGroup - PK - FK with Hospital.HospitalGroup Other fields Hospital ------- Code - PK HospitalGroup…
2
votes
1 answer

NHibernate Save Is Trying to Clear Child KeyColumn Id On Update

I am trying to create a parent object that has multiple children in a 1 to many relationship. I am not referencing the Parent object on the child object, instead I am mapping its keycolumn as a field. When I try to save this object for the first…
spyter
  • 727
  • 1
  • 9
  • 25
2
votes
2 answers

FluentNhibernate Formula mapping with parameters from joined table

I have a problem with FluentNhibernate Formula mapping. I need to use a column from joined table in the formula. Problem is demonstrated on the following three tables: City, Person, Address class Person { int PersonId { get; set; } int…