fluent-nhibernate

Fluent nHibernate - How to map a non-key column on a junction table?

Taking an example that is provided on the Fluent nHibernate website, I need to extend it slightly: I need to add a 'Quantity' column to the StoreProduct table. How would I map this using nHibernate? An example mapping is provided for the given scenario above, but I'm not sure how I would get the Quantity column to map to a property o...

Anyone know of any decent resources on Stored Procedures for Fluent Nhibernate 1.1

A recent release of Fluent Nhibernate (1.1) now supports stored procedures. I was wondering if anyone out there has found any good blog articles on how to do this! I am not asking about using classic hbm mappings instead which these questions previously asked: http://stackoverflow.com/questions/296732/does-fluent-nhibernate-support-map...

NHibernate Bi-directional ManyToMany Relationship Caching Issue

I got issue with bi-directional ManyToMany relationship caching First side mapping : HasManyToMany(x => x.Jobs) .Table("ProfileSuggestStoryJob") .AsSet() .Cascade.None() .ParentKeyColumn("ProfileSuggestStoryId") .ChildKeyColumn("JobId") .Cache.ReadWrite(); ...

Inspect Mapping-Relation

I have a working project with fluent-nhibernate and SQL server 2005. There are several objects which are all nested / related to eachother. The user is sometimes not sure if he deletes the right object, therefore I would like to inspect the mapping (rather than implementing a special delete scenario) for the object and it's related obje...

getting started with Fluent nHibernate and asp.net MVC..

I thought of using Fluent nhibernate for data access with my asp.net mvc web application...Any good article that describes about the setup of Fluent nHibernate with asp.net MVC web application... ...

setting up Fluent NHibernate with asp.net mvc...

I am in search of a tutorial which leads through the setup of Fluent Nhibernate in an asp.net mvc web application... Any good tutorial.... ...

Is it possible to unit test methods that rely on NHibernate Detached Criteria?

I have tried to use Moq to unit test a method on a repository that uses the DetachedCriteria class. But I come up against a problem whereby I cannot actually mock the internal Criteria object that is built inside. Is there any way to mock detached criteria? Test Method [Test] [Category("UnitTest")] public void F...

Fluent nhibernate - Design issue

What would be the best way to implement fluent-nhibernate regarding project architecture? I have two projects at the moment one for the domain layer and the other is the persistance layer. My problem is that when trying to configure nhibernate I get a circular reference. The domain references the persistance layer but how do I get the...

Help Fluent NHibernate Mapping a Generic Class

Hi, I'm hoping somebody can help me with this, I'm trying to write the mapping classes for a class that is subclassed into a generic class. Its easier to descibe with code, so here is my model... public abstract class TagBase { public virtual int Id { get; private set; } public virtual TagTypeEnum TagType { get; set; } publ...

Fluent Nhibernate mapping related items

I am trying to relate 2 items. I have a table that is simply an Id field, and then 2 columns for the Item Id's to relate. I want it to be a 2 way relationship - that is, if the items appear twice in the table, I only want one relationship connection back. So, here's my item: public class Item { public virtual Guid ItemId {get; set;...

How to order a HasMany collection by a child property with Fluent NHibernate mapping

I am using Fluent NHibernate to map the following classes: public abstract class DomainObject { public virtual int Id { get; protected internal set; } } public class Attribute { public virtual string Name { get; set; } } public class AttributeRule { public virtual Attribute Attribute { get; set; } public virtual Statio...

NHibernate class referencing discriminator based subclass

I have a generic class Lookup which contains code/value properties. The table PK is category/code. There are subclasses for each category of lookup, and I've set the discriminator column in the base class and its value in the subclass. See example below (only key pieces shown): public class Lookup { public string Category; public s...

Fluent Nhibernate Mapping Single class on two database tables

Hi guys, I am having problems with Mapping. I have two tables in my database as follows: Employee and EmployeeManagers Employee EmployeeId int Name nvarchar EmployeeManagers EmployeeIdFk int ManagerIdFk int So the employee can have 0 or more Managers. A manager itself is also an Employee. I have the following class to represent t...

SqlLite/Fluent NHibernate integration test harness initialization not repeatable after large data session

In one of my main data integration test harnesses I create and use Fluent NHibernate's SingleConnectionSessionSourceForSQLiteInMemoryTesting, to get a fresh session for each test. After each test, I close the connection, session, and session factory, and throw out the nested StructureMap container they came from. This works for almost ...

Mapping One-to-One subclass in Fluent NHibernate

I have the following database structure: Event table Id - Guid (PK) Name - NVarChar Description - NVarChar SpecialEvent table Id - Guid (PK) StartDate - DateTime EndDate - DateTime I have an abstract Event class, and a SpecialEvent class that inherits from it. Eventually I will have a RecurringEvent class which will inherit from the E...

Fluent NHibernate: Foreign Key violation or Null values.

Hey guys, I am having some real issues with mapping using fluent nhibernate. I realise there are MANY posts both on this site and many others focusing on specific types of mapping but as of yet, I have not found a solution that solves my issue. Here is what I have: namespace MyProject.Models.Entites { public class Project { ...

Fluent NHibernate: Example of a one-to-many relationship on an abstract class of a table-per-subclass implementation

Hi All, I've been trying for ages to find an example (because I can't get it to work myself) of the correct mapping for a one-to-many relationship on an abstract class of a table-per-subclass implementation, in fluent nHibernate. An example below: I'm looking to map the list of Fines on the Debt abstract base class to the Fine class. ...

NHibernate DuplicateMappingException when mapping abstract class and subclass

I have an abstract class, and subclasses of this, and I want to map this to my database using NHibernate. I'm using Fluent, and read on the wiki how to do the mapping. But when I add the mapping of the subclass an NHibernate.DuplicateMappingException is thrown when it is mapping. Why? Here are my (simplified) classes: public abstract...

nhibernate fluent bool to smallint mapping

In my application I have a bool property named DisplayIndicator. In the database (DB2) it's correspondence is DISPL_IND column of type smallint. The correspondence is the following: [DisplayINdicator=True, DISPL_IND=1] and [DisplayINdicator=False, DISPL_IND=0] Is it possible to map using nhibernate fluence the bool property to smallint?...

Fluent Nhibernate - Mapping two entities to same table

Hi, I'm trying to map two domain entities to the same table. We're doing a smart entity for our domain model, so we have the concept of an Editable Address and a readonly Address. I have both mapped using Classmaps, and everything seems to go fine until we try to export the schema using the SchemaExport class from NHibernate. It erro...