Questions tagged [nhibernate-mapping]

XML mappings for the .NET framework object-relational mapper (ORM) NHibernate as created with .hbm.xml files.

NHibernate mappings done in XML files indicate how classes map to database objects. Refer to the relevant NHibernate reference section for details on how to create such mappings.

2300 questions
16
votes
3 answers

Enum parsing doesn't seem to work with Fluent NHibernate

I have a data access class with an Enum called Salutation: public enum Salutation { Unknown = 0, Dame = 1, etc Mr = 5, etc } I am peristing the class with NHibernate, and up until this morning I was using .hbm.xml files for…
David
  • 15,750
  • 22
  • 90
  • 150
16
votes
1 answer

Discriminated unions in NHibernate

I'm wondering if there's any relatively easy way to extend NHibernate to support F#'s discriminated union. Not just a single IUserType or ICompositeUserType, but something generic that I can re-use regardless of the actual contents of the DU. For…
MichaelGG
  • 9,976
  • 1
  • 39
  • 82
16
votes
1 answer

NHibernate - Cascade Merge to child entities fails for detached parent entity

Current Approach In an ASP.NET web forms app (using Spring.NET and NHibernate) we have an aggregate root (Person) whose details are captured across a number of screens/pages. The Person entity exists prior to entering into this workflow, and all…
RuairiQ
  • 431
  • 1
  • 5
  • 9
15
votes
2 answers

How to create a Multi-Column Index or Unique Constraint with NHibernate

How to create a Multi-Column Index and/or Unique Constraint using NHibernate Mapping or Fluent NHibernate.
Wahid Shalaly
  • 2,047
  • 1
  • 18
  • 29
15
votes
1 answer

Using NHibernate with an EAV data model

I'm trying to leverage NH to map to a data model that is a loose interpretation of the EAV/CR data model. I have most of it working but am struggling with mapping the Entity.Attributes collection. Here are the tables in…
devonlazarus
  • 1,277
  • 10
  • 24
14
votes
2 answers

NHibernate Fluent vs. Attributes

I'm interested in moving some NHibernate configurations/mappings into the code to help with some maintenance issues. Can anyone provide any advice/pros/cons/comparisons of Fluent NHibernate vs. NHibernate.Mapping.Attributes? I have some experience…
Andy White
  • 86,444
  • 48
  • 176
  • 211
14
votes
1 answer

Prevent Nhibernate schemaexport from generating foreign key constraints on has many relationship

I have a mapping like this: HasMany(x => x.Orders).KeyColumn("CustomerID"); Which is causing a constraint like this to be generated by schemaexport: alter table [CustomerOrder] add constraint FK45B3FB85AF01218D foreign key (CustomerID) …
14
votes
1 answer

How do I change a child's parent in NHibernate when cascade is delete-all-orphan?

I have two entities in a bi-directional one-to-many relationship: public class Storage { public IList Boxes { get; set; } } public class Box { public Storage CurrentStorage { get; set; } } And the mapping:
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
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
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
2 answers

Nhibernate Conformist Mapping "Unable to determine type..."

The class: public class SOPProcess : ISOPProcess { public virtual Guid Id { get; set; } public virtual SOP SOP { get; set; } public virtual ProcessType Type { get; set; } public virtual SOPProcessInput Input { get; set;…
tom.dietrich
  • 8,219
  • 2
  • 39
  • 56
13
votes
1 answer

How do you make NHibernate ignore a property in a POCO

We have POCO, something like: public class Person { public Guid PersonID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public DateTime DateOfBirth { get; set; } public string …
Sanket Naik
  • 215
  • 1
  • 4
  • 11
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
1 answer

Applying the Hibernate filter attribute to a Bag with a many-to-many relationship

Consider the following Hibernate mapping file: ...
David P
  • 3,604
  • 3
  • 37
  • 54
13
votes
1 answer

NHibernate - Wrong Columns on Queries

I'm getting an intermittant problem with NHibernate where it generates a query for an entity, but replaces one of the columns with a column from completely different (and unrelated) entity. It only ever replaces a single column, and is generally…
tpither
  • 256
  • 1
  • 11