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 Mapping Help static view referencing with compositeID

Afternoon all. I'm trying to create a mapping for a flight segment database where at the bottom of the mapping tree a FlightSegment references an origin and destination table with a compositeID consisting of a three letter code and a Boolean…
Mr Harno
  • 308
  • 1
  • 7
0
votes
1 answer

Fluent nHibernate reference by Id (not by object)

I have a class User, which is in the core module of the system: public class User { public virtual int Id {get; set;} public virtual string Name {get; set; } } I have also a class Company, which is in another module of the system and…
0
votes
1 answer

Fluent many-to-many relationship not working

I'm using the Fluent automapper to create a configuration for a code-first NHibernate project (MySql config) and I'm having a problem implementing efficient many-to-many relationships. As an example, let's say I want a table of Stores and a table of…
0
votes
0 answers

Fluent nHibernate: How to set up id convention so that override works on a table with a different id

Weird case with a legacy database: Most tables have the same named field for the primary key, but I have one table that has a different primary key but also has that named field. When I override the automap for this table it uses the convention not…
Malcolm
  • 1,239
  • 1
  • 14
  • 25
0
votes
1 answer

NHibernate Fluent Mapping results in Invalid index n for this SqlParameterCollection with Count=n

I have a class TrainingSpecialty which is mapped as follows: public TrainingSpecialityMap() { Table("TrainingSpecialty"); Id(o => o.Id).GeneratedBy.Native(); …
0
votes
1 answer

FluentNHibernate.Cfg.FluentConfigurationException

Just some background: it was working code in Production since 2013. Recently added DB password encrypt/decrypt logic in code - compiled code using VS2010 - it's working fine in test but not in Production. I am assuming it has something to do with…
0
votes
1 answer

NHibernate.AspNet.Identity FluentNhibernate - how do I add a custom object to my ApplicationUSer?

I am very, very new to Nhibernate and I am learning on the go (painfully). I am trying to use NHibernate with Asp .NET Identity 2.0 and set my own store. However, I am having issues - Though I understand mappings between entities, I can't seem to…
0
votes
1 answer

Fluent Nhibernate loading not falling back on lazy loading? (grandchild entities)

When querying nhibernate, I'm seeing some odd behavior When I write a query like this Repository.QueryOver() .Fetch(x => x.Child1).Eager .Fetch(x => x.child2).Eager It will eagerly grab child1 and child2 entities, but there are…
0
votes
2 answers

NHibernate specific mapping ("select using grand-parent")

I have such domain structure (example, pseudo code): class Room { Id: long Shelves: list of Shelf } class Shelf { Id: long Room: Room class (room_id column) Books: list of Book } class Book { Id: long (id column) Shelf: Shelf…
0
votes
1 answer

Fluent Nhiberante sub class same table as class

I have two classes: class User { public int Id { get;set; } public string Name { get; set; } } class VerifiedUser : User { public ICollection { get; set; } } I would like NHibernate to treat VerifiedUser and User as the same…
Jake Rote
  • 2,177
  • 3
  • 16
  • 41
0
votes
1 answer

How to map a reference of a CompositeId using Fluent NHibernate

I have three classes Product, Stock, StockId. Stock has a composite Id of Token and InternalCode, these two properties are encapsulated in a new class StockID. My classes definitions are: public class Producto { public virtual long Id { get;…
0
votes
1 answer

NHibernate Many to Many Mapping Update Association Table

I am trying to setup a many-to-many mappings using NHibernate 4 and Fluent Nhibernate 2. It is a simple User and Role relationship. One user may have many roles and one role may have many users. Below is the structure. User public User() { Id =…
0
votes
1 answer

Nhibernate 'different object with the same identifier value' issue

I have a scheduled process that updates a User entity. This User entity has a ManyToMany relationship with a Roles object. public class UserMappingOverride : IAutoMappingOverride { public void Override(AutoMapping mapping) { …
0
votes
1 answer

Fluent NHibernate: Referencing Another Entity on Multiple Key Columns For Both Parent and Child

I am trying to figure out a way to reference one entity from another using non-primary keys for both the referenced and referencing entities. I have the following: public class UserContact { public virtual ulong ContactId { get; set;} public…
0
votes
1 answer

Fluent NHibernate one to many am i doing it right?

Have Books class. public class Books { public virtual int Id { get; set; } public virtual string Title { get; set; } public virtual string Category { get; set; } public virtual string ISBN { get; set; } public virtual string…