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
11
votes
5 answers

NHibernate still issues update after insert

I have a very simple unidirectional mappings. see below: public ContactMap() { Id(x => x.Id).GeneratedBy.Assigned(); Map(x => x.Name); References(x => x.Device); HasMany(x => x.Numbers) …
Davita
  • 8,928
  • 14
  • 67
  • 119
10
votes
1 answer

Fluent Nhibernate mapping hasMany

In my MSSQL I have two tables, Property and Photo. To make it shorter I will write here just few fields. Property table Id int not null Title nvarchar(255) not null PhotoId int not null Photo table Id int not null ImageData varbinary(MAX)…
BobRock
  • 3,477
  • 3
  • 31
  • 48
10
votes
4 answers

An association from the table X refers to an unmapped class: System.Guid

I have this class: public class AttachmentLocation { #region properties public virtual Guid UserId { get; set; } public virtual Guid LocationId { get; set; } public virtual long IndexInLocation { get; set; } #endregion …
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
10
votes
2 answers

how to achieve table per concrete class when base class is abstract in fluent nhibernate?

i have the following scenario public abstract class BaseClass { public virtual int Id {get; set}; public virtual string Name {get; set;} } public class FirstSubClass : BaseClass { //properties and behaviour here } public class…
10
votes
3 answers

Null value objects in NHibernate

I have a person entity containing an Address as a value object: public Person() { WithTable("Person"); Id(x => x.Id); Component
(x => x.Address, a => { a.Map(x => x.Address1); a.Map(x => x.Address2); …
James Allen
  • 6,406
  • 8
  • 50
  • 83
10
votes
1 answer

NHIbernate (3.1) - Linq group by then order by count issue

I am trying to get a group by followed by an order by count to work but I keep getting a 'Antlr.Runtime.NoViableAltException' being thrown. Here is the simplest error case I can create. var results = ArticleStatsRepository.GetAll().GroupBy(x =>…
CountZero
  • 6,171
  • 3
  • 46
  • 59
10
votes
7 answers

Getting Fluent NHibernate to work with SQLite

I'm sure there is something simple I've not done but I'm trying to get Fluent NHibernate to work with Sqlite on my machine. I used NuGet to download fluent nhibernate and added the following entity and mapping: public class Customer { public…
CraftyFella
  • 7,520
  • 7
  • 47
  • 61
10
votes
4 answers

NHibernate SaveOrUpdate Child Collection Not Updated With Identity Ids

I am clearly missing something (hopefully obvious), and I have had no luck with Google so far. I have a Parent-Child relationship mapped as follows Simplified Parent Map public sealed class ParentMap : ClassMap { public…
Chris Baxter
  • 16,083
  • 9
  • 51
  • 72
10
votes
3 answers

Self referencing many to many relationships in Fluent NHibernate automapping automapping to 1:n and not n:n

The title pretty much explains it all, I have a Member object that references 'Friends' who are also type Member. public class Member : Entity { public Member() { Friends = new List(); } …
Eitan
  • 1,434
  • 6
  • 21
  • 53
10
votes
2 answers

2010 Beginners guide to fluent nHibernate

I need some tutorials on how to get started with nHibernate and Fluent nHibernate. I'm coming from an Entity Framework background (which seems easier to use). I've tried sites like http://www.summerofnhibernate.com/ to get a grasp on nHibernate…
Shawn Mclean
  • 56,733
  • 95
  • 279
  • 406
10
votes
1 answer

Fluent NHibernate JoinedSubClass is obsolete

I wonder about something. I'm sitting here with a solution there I have 1 superclass that has 2 subclasses and I'm currently mapping this using JoinedSubClass, but I get that this method is obsolete, and says that I should ClassMap and SubClassMap,…
10
votes
1 answer

Mapping multiple properties of a same type with HasMany via automapping

I am trying to map properties of the same type on a OneToMany association. I tried to distinguish with Description but kinda stuck here. public class User { public virtual int UserId { get; set; } public virtual string UserName { get; set;…
Mert
  • 6,432
  • 6
  • 32
  • 68
10
votes
1 answer

many-to-one with multiple columns

I have a legacy data base and a relation one-to-one between two tables. The thing is that relation uses two columns, not one. Is there some way to say in nhibernate that when getting a referenced entity it used two columns in join statement, not…
Sly
  • 15,046
  • 12
  • 60
  • 89
10
votes
3 answers

Fluent NHibernate and PostgreSQL, SchemaMetadataUpdater.QuoteTableAndColumns - System.NotSupportedException: Specified method is not supported

I'm using fluentnhibernate with PostgreSQL. Fluentnhibernate is last version. PosrgreSQL version is 8.4. My code for create ISessionFactory: public static ISessionFactory CreateSessionFactory() { string connectionString =…
Vyacheslav
  • 101
  • 1
  • 3
10
votes
2 answers

How to map IDictionary in Fluent NHibernate

I have an class with an IDictionary on it.
Stu
  • 2,426
  • 2
  • 26
  • 42