fluent-nhibernate

Fluent-nhibernate: discriminate objects to load the hierrachy correctly

Update Well, as i was told by Stuart Charles and James Gregory, my model was weird enough to begin with. Apparently double-way references between classes while discriminating between the different kinds of relations isn't done, and apparently for a very good reason. I tore the model down, changed it to a different one using HasManyToMa...

Filtering NHibernate Hierarchy using link tables

Hi, Let's say I have a simple parent->child class structure as shown below Public Class Parent Public ParentID As Integer Public Children As IList(Of Child) End Class Public Class Child Public ChildID As Integer Public Parent As Parent End Class These are mapped to two tables using Fluent NHibernate. No problem. I now have ...

FluentNHibernate and Enums

I have an enum called Permissions. A user can be assigned permissions, or permissions can be asigned to a role and the user can be given a role. User and Role both have a property like this: public virtual IList<Permission> Permissions { get; set; } I want to use an enum for Permissions so in my code I can do things like public sta...

Fluent-NHibernate and persisting DateTime automatically

I'm using S#arpArchitecture (ASP.NET MVC and Fluent NHibernate). I have an entity as follows: public class User : Entity { public User(){} public User(string firstName, string lastName) { FirstName = firstName; LastName = lastName; } public virtual string FirstName { get; set; } public virtual st...

Fluent NHibernate entity HasMany collections of different subclass types

So everything is working well with the basic discriminator mapping. I can interact directly with entities A and B without any problems. public class BaseType {} public class EntityA : BaseType {} public class EntityB : BaseType {} This maps without drama in the BaseType mapping as DiscriminateSubClassesOnColumn<string>("Type") ...

Mapping complicated references in NHibernate

I am trying to build the following association in NHibernate (the base Entity class contains an Id property, it and the attributes are from S#arp Architecture) public class Terminal : Entity { public virtual string Name { get; set; } } public class Order : Entity { [NotNull] public virtual Terminal Terminal { get; set; } } ...

FluentNHibernate set default column value for a bool

How to set with FluentNHibernate the default value of 1 or 0 for a BIT column of the table generated from my entity for the field of type bool. I think it doesn't matter but in any case the database is sqlserver2005. ...

NHibernate's Increment Generator - could not fetch initial value

I'm trying to use NHibernate (and FluentNHibernate) over a legacy database. I'm also using SQLite for tests. When I try to create a test for the mappings using FluentNHibernate's PersistenceSpecification, I get the following exception: NHibernate.Exceptions.GenericADOException : could not fetch initial value for increment generator I'...

Problem with JoinedSubClassPart in Fluent NHibernate.

Hello, I seem to be having trouble modeling inherited classes using JoinedSubClassPart in Fluent NHibernate (release 524). I have seen other posts indicating that the approach I am using (see below) should work, yet at runtime I get the following exception (thrown by ImappingPart.PositionOnDocument method of JoinedSubClassPart): XunitE...

Abort due to constraint violation columns GroupId, idx are not unique

I'm using FluentNHibernate and have done a many-to-many mapping but when I try to save my entity I get the following error: NHibernate.Exceptions.GenericADOException: NHibernate.Exceptions.GenericADOException : could not insert collection: [Test.Entities.Recipient.Groups#b6815d34-f436-4142-9b8e-1bfcbf25509e][SQL: SQL not available] ----...

Fluent NHibernate column name conventions

Hi! I want to create a convention for column names using Fluent NHibernate auto mapping. There is a blog entry that states that property conventions can be set like this: ConventionBuilder.Property.When( x => x.Property.PropertyType == typeof(int), x => x.ColumnName(x.Property.Name + "Num") ) But the problem is, that x only has a...

Fluent NHibernate - Relationship to UserName Field in aspnet_Users field

Our relationships with the aspnet membership provider tables all reference the UserName field instead of the UserId field because we hate dealing with guids. But now I'm having troubles setting up a relationship between my orders table the aspnet_users table. Here are the mappings with unimportant fields taken out: public class Aspnet_U...

Parent-child tree hierarchy with NHibernate

I have a Group. That group can contain groups and this needs to be mapped with NHibernate. I have done this before but this time I got an existing database that does not really store the data like I would like it too. The database looks like this: Groups Id Groups_Link ParentId ChildId I have no clue about how to map this? Edit: ...

How would I map this in nHibernate?

Trying to wrap my head around nHibernate, curiuos how this scenerio would be handled: Post (postID, title, content, dateCreated) Category (categoryID, name, postCount) post_to_categories (postID, categoryID) If I create a Post, it should insert into Post, insert into post_to_categories and update the postCount in Category. I am plan...

How do you map an entity -> interface relationship using Fluent NHibernate?

given the following class definition: public class Order { public IProduct Product {get;set;} } I have this (fluent) mapping References(x=>x.Product, "ProductId"); And get this exception: An association from the table Orders refers to an unmapped class, which makes sense because it doesn't know what implementation I will pass to ...

NHibernate Mapping Question

I have tried various approaches to mapping the following structure, but I finally admit that after a day of not getting very far, I need some help. So the question is, how would you guys go about mapping something like this. The schema is not fixed at this point. public abstract class BaseObject { public virtual int Id { get; set; ...

The type initializer for 'NHibernate.Cfg.Configuration' threw an exception.

I am using FluentNHibernate and during the configuration phase I am getting the following error: Here is the configuration: public static ISessionFactory CreateSessionFactory() { return Fluently.Configure().Database( MsSqlConfiguration.MsSql2000.ConnectionString( ...

Fluent nhibernate hasmanytomany & adding it..

i have used fluent nhibernate for 3projects so i know the basics but i havent used the hasManyToMany yet. i have found documents that show me how to mapp it so i guess that is ok. my question about that is what sould use the hasManyToMany in its mapping and what should i put in the other? let me know if im unclear in my explaining and if...

Is fluent NHibernate ready for production code?

As the title says, I'm wondering if I should avoid using fluent nhibernate for production code, or if it's mature enough to just "dive in"? :) ...

Date Filtered Collections without Functions

Hi, I have an entity similar to the below: public class Entity { public List<DateItem> PastDates { get; set; } public List<DateItem> FutureDates { get; set; } } public class DateItem { public DateTime Date { get; set; } /* * Other Properties * */ } Where PastDates and FutureDates are both mapped to the same...