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

Invalid index for this SqlParameterCollection with Count

I need access to the ApplicationID property of the parent class in order to run an Nhibernate query. Running a test for this query in NUnit causes it to fail as such: …
Seraph812
  • 397
  • 3
  • 7
  • 17
3
votes
2 answers

Casting a member access func from Func to Func

I'm trying to creating a dynamic base mapping with fluent nhibernate. What I'm doing is checking in by a BaseMap< T > : ClassMap< T > if for example: (typeof(ICategorizedEntity).IsAssignableFrom(typeof(T))) If so, I wanna map a…
Adam Tal
  • 5,911
  • 4
  • 29
  • 49
3
votes
1 answer

Fluent nHIbernated - HasMany relationship in same table

I'm creating a model for a website top-menu structure - I have a MenuObject model: public class MenuObject { public virtual int Id { get; set; } public virtual string Title { get; set; } public virtual List Children { get;…
3
votes
2 answers

Overriding FluentNHibernate DefaultCascade for many types at once

I have an abstract entity base class defined like this: public abstract class SessionItem : Entity { public virtual Session Session { get; set; } } In addition, I'm using auto mapping: private AutoPersistenceModel CreateAutomappings() { …
3
votes
3 answers

NHibernate - mapping two collections of the same type to database

NHibernate mapping question. I have an entity called User and an entity called Menu. User contains two collections of menus. public class User { public List History {get; set;} public List Favourites {get; set;} } public class…
3
votes
2 answers

Class map setting with Fluent NHibernate

I'm new to using NHibernate and I struggled to find clear examples online of how to create a ClassMap for a stored procedure without using XML for the mappings. I recently got this working using the Fluent interfaces and wanted to share what I've…
3
votes
1 answer

How do I tell Fluent NHibernate to ignore specific properties without automapping?

I am using Fluent NHibernate to map out an existing database. For this reason - automapping isn't an option for me. How do I tell NHibernate not to map certain properties? Many of them are read-only, and the others do not need to be persisted for…
3
votes
1 answer

Mapping clobs using Fluent NHibernate, Oracle 10g and OracleClientConfiguration.Oracle10

I've been trying to map a clob field using Fluent NHibernate 1.2.0.712 against Oracle 10g. I'm using System.Data provider as it's available by default and was trying to avoid adding reference to ODP.Net due to previous client issues. However, when…
3
votes
1 answer

Fluent NHibernate - Mapping List to ordered child table

I'm refactoring a fluent nHibernate mapping, and I can't seem to figure this one out. I want to remap a property with type List to a child table, but using a single HasMany if possible. Right now we have: Map(x => x.DecimalList); Which…
Alex Moore
  • 3,415
  • 1
  • 23
  • 39
3
votes
2 answers

Nhibernate Has Many Insert generates extra Update (no Inverse)

I have a Parent class with two lists of Child classes public class Parent { ... public virtual ICollection Foo{ get; set; } public virtual ICollection Bar{ get; set; } } public class Foo { …
3
votes
1 answer

Is this Fluent NHibernate mapping test a false positive?

I changed my mapping test to use the overload .VerifyTheMappings(TEntity first), and suddenly my test just passes. I haven't used that overload before, and since I'm not really sure how it works, I'm worried I'm getting a false positive. I'm…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
3
votes
1 answer

Fluent Nhibernate error Foreign Key

I know that this issue has some questions about it, but I can't find the right answer, so please let me ask this question to see if someone could give me the right answer I have the following scheme for my DB (tables an dsimplified to focus on the…
a.ras2002
  • 385
  • 2
  • 7
  • 21
3
votes
1 answer

Fluent nhibernate map multiple tables

I have an UserEntity that mapped like and got Cannot simultaneously fetch multiple bags. error public UserEntityMap : ClassMap { //Other properties HasMany(x => x.Addresses).KeyColumn("User_id").Fetch.Join(); HasMany(x =>…
3
votes
1 answer

How to reference parent entity in the same table with fluent nhibernate auto mappings?

I am trying to use FluentNHibernate AutoMappings to create an entity with reference to its parent. I was able to do this with help of ClassMap<>, but now I want to move everything to AutoMappings. I have a table with the following schema: CREATE…
3
votes
1 answer

fluent nhibernate mappings that save in both directions

I want to be able to do the following: var child = new Child { Name = "foo", Parent = new Parent { Name = "bar" } }; session.Save(child); OR var parent = new Parent { Name = "foo", Children = new List { new Child { Name = "bar"…