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

Fluent nHibernate: error 'there is a reference in the field "," but it is not defined'

here's the table schema UserLogin 1---* UserMessages 1---* UserMessagesReceiver mappings public class UserLoginMap : ClassMap { public UserLoginMap() { Table("UserLogin"); Id(x => x.Id).GeneratedBy.Assigned(); …
Tony
  • 12,405
  • 36
  • 126
  • 226
0
votes
1 answer

Fluent NHibernate mapping throws an exception of 'Id is not mapped'

I need help with auto mapping in Fluent Nhibernate. Here's the tables I want to have in my app (they are many of them, but I want to start from mapping only a few of them) Well, I'd like to use the AutoMapping functionality because I don't want to…
Tony
  • 12,405
  • 36
  • 126
  • 226
0
votes
1 answer

Fluent nHibernate with Automapping: How to get a parent or "containg" object from a child

I have an object model similar to this: public class Item { public virtual Guid Id { get; set; } } public class Box { public virtual Guid Id { get; set; } public virtual IList Contents { get;…
James Bender
  • 1,175
  • 1
  • 11
  • 22
0
votes
1 answer

Mapping Enum Error FluentNhibernate

I want to Map an enum to mysql Database. class CommisionWorking { public enum Color{ O, PP, FP }; } This is my mapping Class. class CommisionWorkingMap : ClassMap { public CommisionWorkingMap() { Map(x =>…
0
votes
1 answer

FluentNHiberante union-subclass mapping does not generate table for base class

I am trying to map following domain model using union-subclass strategy and FluentNHibernate. Here is how my classes look (with unneeded parts removed) public class Benefit { } public class Leave : Benefit { } public class SeasonTicketLoan :…
0
votes
1 answer

NHibernate (Fluent) mapping abstracting an intermediate class

I have a generic object type Entity and some classes that can relate to Entity such as EntityDescription and EntityLocation (many-to-one relationships). Entity class: public class Entity { public virtual Int64 ID { get; set; } // and other…
0
votes
1 answer

Fluent NHibernate parameterized typedef mapping

Does anyone know how the following HBM property mapping could be translated to Fluent? uNhAddIns.UserTypes.uNHAddinsEncryptor,…
BlakeH
  • 3,354
  • 2
  • 21
  • 31
0
votes
1 answer

Fluent NHibernate Convention mapping tree structure

I want to put a tree structure (stored as an adjacency list) into a database, and I want to use Fluent NHibernate with Convention mapping to do it. I have the following code: [...] NamespaceAutomapping automapping = new…
0
votes
1 answer

How to map a single datetime column to two seperate datetime properties in a model

If I have an object with a DateTime property is it possible to map the Date and the Time to seperate properties in the same object? I.e An object with a StartDateTime, StartDate and StartTime where StartDateTime exists as a column in the database…
0
votes
1 answer

Fluent Nhibernate save persisted entity twice in database

I have a base class with ID as Primary Key and 3 version numbers. [NotNull] public virtual int Id { get; private set; } [NotNull] [NotUpdatable] public virtual int BaseVersion { get; set; } [NotNull] [NotUpdatable] public virtual int MajorVersion {…
0
votes
1 answer

Fluent nHibernate map HasMany to Entity/Table with no Primary Key

I am having the worst trouble trying to setup a HasMany relationship to an entity backed by a table with no primary key. ClassA has a CompositeId. To circumvent the lack of a primary key on ClassB, I tried to create a CompositeId on ClassB that was…
Josh C.
  • 4,303
  • 5
  • 30
  • 51
0
votes
1 answer

Flatten class hierarchy for mapping and schema export (readonly base classes!)

I have several entities to access the same table. I would like to put them in a class hierarchy. I don't want nhibernate to generate any joined-subclasses or discriminators in the mapping. When I return IsDiscriminated = false it makes joined…
Vlad
  • 3,001
  • 1
  • 22
  • 52
0
votes
1 answer

Cascading a Multi-Level Delete and N+1

I'm finding that cascading deletes is sending SQL with many individual deletes, i.e. the N+1 problem. I have three tables: User, UserAttribute and Attribute. Each User has many UserAttributes, each UserAttribute has one Attribute - represented by…
0
votes
1 answer

Fluent nHibernate mapping with multiple columns

I have following database and I want to create mapping in Fluent nhibernate so that I can traverse object collection like survey.question.feedback to get all responses to questions .. how can I do that? I have following mapping so far public class…
0
votes
2 answers

Fluent nHibernate string length issue

I am trying to set the length for an nvarchar, but no success - it is still nvarchar(255). I am getting this error; "String or binary data would be truncated.\r\nThe statement has been terminated." Map(x =>…
Mert
  • 6,432
  • 6
  • 32
  • 68