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

Nhibernate parent child relationship where child does not reference the parent

I have a domain where the children don't reference the parents. I am using nh 3+ and fluent nh with automapping. An example would be like this. public class Parent { public Guid Id {get;set;} public string Name {get;set;} public…
2
votes
1 answer

Nhibernate SubClass relationship generating wrong SQL

I'm using Table Per Type(TPT) to do inheritance in Nhibernate v3.3.1.4000. I figured out that any SQL for SubClass relationships one-to-many are wrong. Class: public class Repasse : Colaboracao { public virtual string Descricao { get; set; } …
Fals
  • 6,813
  • 4
  • 23
  • 43
2
votes
1 answer

Fluent NHibernate Insert to table with int Identity

I'm new to Fluent NHibernate and I am having an issue inserting to a table which has an ID column set as INT IDENTITY(1,1). My user map is as follows... public class UserMap : ClassMap { public UserMap() { Table("User"); …
S-Unit
  • 135
  • 6
2
votes
1 answer

Multiple entity relationship mapping fluent NHibernate

This is a part of my entity-relationship model: I found few ways to map the 'It' relationship: One: Add new class, and then reference it using a many to many relatinship: class It{ A a; B b; C c; } class A{ public virtual ISet
2
votes
1 answer

NHibernate SaveOrUpdate merges child collections

I have a class Journal, which has an IList of JournalLine objects. I created a Journal and accidentally ran it through the same line generation method twice. The start of this method calls _journalLines.Clear() and the end does…
Colm Prunty
  • 1,595
  • 1
  • 11
  • 29
2
votes
2 answers

Many-to-one with formula

I have an NHibernate mapping file I want to convert to fluent. I'm stuck with this one particular case: (SELECT TOP(1)…
Becca Dee
  • 1,530
  • 1
  • 24
  • 51
2
votes
1 answer

FluentNHibernate mapping smalldatetime SQL data type

I have a legacy database that uses the smalldatetime SQL data type. That maps fine to the standard DateTime. However, when I use SchemaExport, it understandably generates the column with datetime format. What custom type should I be using in my…
2
votes
1 answer

Fluent NHibernate Reference to MembershipUser

I Want to create table (SQL Server) that contains users identity GUID and make reference to it in Fluent NHibernate, here is my model: public class Invoice { public virtual Guid Identity { get; set; } public virtual MembershipUser User {…
2
votes
2 answers

fluentNhibernate: how to add an extra attribute to a relationship (aka relationship attribute)

I have two entities, Albums and Photos, with a many-to-many relationship between then. Its all working fine. What I want is to add an relationship attribute i.e. an extra attribute to the mapping besides album_id and photo_id, for example the…
2
votes
2 answers

DB2 Fluent NHibernate mapping duplicate records in HasMany mapping

I accessing a pre-existing database (actually DB2 on an IBM i), and have an issue with the mappings for the following (simple) structure in Fluent NHibernate. I have had to construct an artificial example, so forgive any ommissions. Job ... public…
mmmm
  • 2,431
  • 2
  • 35
  • 56
2
votes
1 answer

Most optimal way to model a generic class in nHibernate

Say I have a class something like... public class SomeClass where T : ISomeConstrainingInterface { public T MyPropertyOfTypeT {get;set;} public int SomeIntProp {get;set;} public string SomeStringProp {get;set;} } Where T can be a…
Tim Jarvis
  • 18,465
  • 9
  • 55
  • 92
2
votes
1 answer

Fluent NHibernate With Dynamic Table Name

how can I map a dynamic table name to a entity? Ex, I can have many tables, all have the same structure, however, has its different name, how can I map this using Fluent NHibernate? remembering that before compiling I do not know the name of these…
2
votes
2 answers

How to fill just required properties of entity (FluentNHibernate)

I am using FluentNHibernate to access to my database. I would like to implement next - just required properties of my entity should be filled. By example, in one case all properties should be filled, in second case repository should return entity…
2
votes
1 answer

Fluent Nhibernate mapping not created after delete and add the same database

I am using fluent nhibernate to create 3 databases at run time using 3 sessions. ISessionFactory sessionFactory = Fluently.Configure() .Database(MsSqlConfiguration .MsSql2008 .ConnectionString(c => c …
2
votes
2 answers

Should NHibernate be responsible for mapping to viewmodels from domain objects?

I've started a new project and decided to user SharpArchitecture with Fluent nHibernate for my ORM. (I've never used nHibernate or SharpArchitecture before so be gentle if I'm missing something) What I'm trying to do and I'm not sure if this is the…