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
7
votes
3 answers

FluentNHibernate or port to NHibernate mapping by code

I have several projects using NH and FNH to generate the mappings (some Fluent some Automapped). There are still some bugs and missing features i need, but it seems that FNH could die because of mapping-by-code integrated into NHibernate. Question:…
7
votes
1 answer

Multiple levels of inheritance with Fluent NHibernate using discriminators

I'm in the enviable situation of having to integrate with a legacy database, luckily for readonly purposes, and have chosen to use NHibernate. Up until now everything has been great, but I have a new requirement which has me scratching my…
jonnii
  • 28,019
  • 8
  • 80
  • 108
6
votes
1 answer

NHibernate - Force escaping on Table Names

Are there any good examples of how to use this (NHibernate.Criterion.IdentifierEqExpression) online? I couldn't find any. I'm a little confused about what you are supposed to pass into the constructor. I pass in an int32 of 1 and I keep thinking my…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
6
votes
1 answer

adding initial rows into tables using Fluent migrator

Im a classic programmer that is newbie at generics and this is an asp.net MVC5 sample application for learning purposes of integrating authorization (users/roles) using fluent migrator lib. I wantto add some sample datas into tables as they created…
6
votes
1 answer

Invalid index 6 for this SqlParameterCollection with Count= 6

Map Class public class cAdministratorMap : ClassMap { public cAdministratorMap() { Table("Administrators"); CompositeId(c => c.Key) .KeyProperty(x => x.Client_id,…
6
votes
0 answers

How do I get run R-tree index on SQLite database using fluent hibernate interface

Is there any possibility to set up R-tree on SQLite database using Fluent NHibernate? And I read that there is new table created as r-tree index so I will then have table of data and table of index. How will I reach the situation where my query will…
6
votes
3 answers

Is there a Fluent NHibernate Automapping sample project that "just works"?

I just started looking at NHibernate this week, and would love to use the Automapping approach on my current project. I'm working with Fluent NHibernate 1.0.0.594, which I downloaded a few days ago. I found the Examples.FirstProject in the…
Tom Bushell
  • 5,865
  • 4
  • 45
  • 60
6
votes
1 answer

How can I map to a joined subclass with a different column than the id of parent?

I am working with a brownfield database and am trying to configure a subclass map which joins to its subclasses with a column other than that of the specified id. The login table has a primary key column login_sk which I'd like to use as its id. It…
6
votes
2 answers

Fluent NHibernate - mapping a foreign key as a property

I'm looking for a way of adding an association between two entities and having a settable Id for the foreign key. I have searched through previous posts, but the closest I can find is a suggestion to .Load the association - which isn't what I'm…
6
votes
1 answer

Duplicates when eager fetching a reference (many-to-one)

First of all, yes, I am using DistinctRootEntityResultTransformer. I have the following (Fluent NHibernate) mapping: public FirstObjectMap() { Id(x => x.Id): HasMany(x => x.SecondItems).KeyColumn("FirstObject_ID"); } public…
5
votes
3 answers

NHibernate - how to delete an item from many-to-many relationship?

I've following mapping for two tables having a Many-to-Many relationship between them. How do I delete an entry from the mapping table, which is 'ProjectUser' in my case? public ProjectMap() { Id(x => x.Id); Map(x => x.ProjectName); …
5
votes
3 answers

NHibernate.AssertionFailure: null identifier

Before I kick my computer in to next week... I've checked out every other question about this, but none of them have the solution. I've stripped this code right back, but it's still not working. I'm getting this error when saving an object:…
Paul
  • 9,409
  • 13
  • 64
  • 113
5
votes
1 answer

NHibernate Table Per Class loading - wrong type

I have a mapping issue with the table-per-class hierarchy in Fluent/NHibernate. When retrieving the records from the database, I keep getting an error (the Wrong type exception) Object with id: 2445763 was not of the specified subclass: ClassA…
5
votes
2 answers

Invalid index N for this SqlParameterCollection with Count=N only when associated table has null record

I have a rather complex entity which will not save when a particular database table is missing a record. When the record exists the entity saves correctly. When the record does not I receive the exception: Invalid index N for this…
ahsteele
  • 26,243
  • 28
  • 134
  • 248
5
votes
1 answer

Why does AutoMapping from Fluent's NHibernate ignore an enum type?

I have the following enumeration type: public enum EnumType { E1, E2 } used in the following class: public class X { public virtual int? Id { get; set; } public virtual EnumType EnumProperty { get; set; } public virtual string…
BartoszKP
  • 34,786
  • 15
  • 102
  • 130
1
2
3
41 42