fluent-nhibernate

NHibernate Ordering more than 2 joined fields of a class.

Hi guys, I would like to ask on how you do ordering on an object with 2 properties that are basically joined from 2 entities. Lets say "ClassA" has a property named ClassB and ClassC which are also classes themselves. ClassB has a property named Name and ClassC also has a property named Name. Now, since ClassB and ClassC are both proper...

How do I override the automapping for a composite Id, one to many relationship with fluent nhibernate?

I'm polling mulitple systems (domains) for security info so I'm dealing domainUsers and their roles. I've got my entities setup as show below, but I'm having trouble setting up the domainUser.HasMany relationship in the AutoMapper override. You'll notice that I don't have domainUser.DomainUserId and role.RoleId which make this much m...

nHibernate Many-to-Many query using Criteria API

Hello, Before asking I have looked at all relevant posts on this topic I have also read this blog post: http://ayende.com/Blog/archive/2007/12/23/NHiberante-Querying-Many-To-Many-associations-using-the-Criteria-API.aspx I have Teams and I have Members, there is many-to-many relationship between them Basically: Member -> MemberTeam <-...

fluent-nHibernate Order of Saving

My business object scenario is a class A that contains two references to instances of class B. There are corresponding tables for these classes. Table A has two foreign key link fields to table B. This database structure is set in stone and simply cannot change. I wish to use fluent-nHibernate to save at the class A level and achieve d...

Fluent Nhibernate : could not resolve property

I have a problem with Fluent Nhibernate: the error is "Could not resolve Property MailHeader of class MailHeader. The problem is related to the collections inside the entity "MailHeader", if i remove the collections the exception disappear, but i want these collections! Thank's in advance. The Entities involved are: public class M...

Fluent Nhibernate and Dynamic Table Name

Hi, I've got a parent and child object. Depending on a value in the parent object changes the table for the child object. So for example if the parent object had a reference "01" then it will look in the following table "Child01" whereas if the reference was "02" then it would look in the table "Child02". All the child tables are the sa...

Many to many as map in fluent Nhibernate

Is there a way to map a many-to-many relationship using Fluent NHibernate to a dictionary? Say I have the following (totally just made up) tables: Person ( Id INT, Name NVARCHAR(MAX) ) Address ( Id INT, StreetAddress NVARCHAR(MAX) ) PersonAddresses ( PersonId INT, AddressId INT, AddressType NVARCHAR(MAX...

How to add extra field in the ManyToMany generated table with FluentNHibernate

I have 2 entities Users and Colors. One user may be associated with multiple colors, and one color may be associated with multiple users. I use FluentNHibernate autopersistence model to generate the database. Now I have to add to the generated table UserToColor(UserId,ColorId) also an extra field 'CreatedOn', how can I accomplish and is...

Unexpected row count in Nhibernate when deleting parent records with associated child records

Hi, I have a parent table, Orders and a child table, [Order Details], I have setup the fluent mappings as - (In the parent Order class) HasMany<OrderDetails> (x => x.Details).KeyColumn("OrderId").Cascade.AllDeleteOrphan().Inverse(); (In the child [Order Details] class) References(x => x.ParentOrder).Column("OrderId").Not.Nullable(...

Fluent NHibernate automapper: skip an intermediate class w/ table-per-subclass

I'm using the Fluent NHibernate mapper with table-per-subclass to map the following structure: public abstract class A { // properties here } public abstract class B : A { // methods here } public class C : B { // properties here } My database only has tables to represent class A and class C. Class B exists only in my mo...

How to map an interface in nhibernate?

I'm using two class NiceCustomer & RoughCustomer which implment the interface ICustomer. The ICustomer has four properties. They are: 1) Property Id() As Integer 2) Property Name() As String 3) Property IsNiceCustomer() As Boolean 4) ReadOnly Property AddressFullText() As String I don't know how to map the interface ICustomer, to the d...

Fluent NHibernate, dynamically change Table of mapping?

Hello, with fluent nhibernate, is there a way to dynamically switch the table of a mapping at runtime? For example: public class XYClassMap : ClassMap<XY> { public XYClassMap( ) { Table("XYTable"); Id(d => d.Id).GeneratedBy.Identity(); Map(d => d.Value); (...) Given that there are multiple plugins, each of them ...

Automapping inheritance: How to add Discriminator convention for base class

By implementing ISubclassConvention, I can change the Discriminator Value for the subclasses in my class hierarchy. I'm now looking for a way to set the Discriminator Value for my base classes as well. Is there a way to change it with a convention override or do I have to add a manual mapping for my hierarchy? (The IClassConvention prov...

Can I make a Fluent NHibernate foreign key convention which includes parent key name?

I have a database schema where the convention for a foreign key's name is: ForeignTable.Name + ForeignTable.PrimaryKeyName So, for a Child table referencing a Parent table with a primary key column named Key, the foreign key will look like ParentKey. Is there a way to create this convention in my Fluent NHibernate mapping? Currently...

FluentNHibernate / NHibernate Legacy Mapping problem

Given the following Tables and classes.... I want to know how to Map class Bs reference to A. It doesn't have a direct reference in table B, but comes from A having a reference to it. B only ever has 1 A that will have a reference to it. Can it be done? :) table A int id int bID table B int id class A { virtual int id { get;...

configure Fluent NHibernate mapping to allow INSERT only?

I'm moving a project from SubSonic to NHibernate and am using Fluent NHibernate to perform all of our mapping. Our db schema is pretty straight forward and most of our cases appear thus far to be well illustrated by different blog posts and sample code that's available. One thing that I'm unable to figure out however is the ability t...

getdate() through fluent nhibernate

Hi, I want to insert a record through fluent, where a column need to have the value of getdate() sql function. How to do this in a single fluent save function? Thanks, ...

How do a case-insenstive Where clause in LINQ-to-NHibernate with the Oracle provider?

For example, given the following code, how is it possible to make the string comparison case-insensitive? var query = from employeeGroup in _session.Linq<EmployeeGroup>() from employee in employeeGroup.Employee where employee.UserName == username select employeeGroup.Em...

Using Time columns with NHibernate, Fluent NHibernate and SQL Server 2008

Hello, I have a table with a time column in my SQL Server 2008 database. The property of the object I'm trying to map to is a TimeSpan. How can i tell FluentNHibernate to use the TimeAsTimeSpan NHibernate type, so that I don't have cast problems? ...

IndexOutOfRangeException Deep in the bowels of NHibernate

I have the following mappings: public class SecurityMap : ClassMap<Security> { public SecurityMap() { Table("Security"); CompositeId().KeyProperty(k => k.Id, "SecurityId").KeyProperty(k => k.EndDate); Map(x => x.LastUpdateUser); References(x => x.Company).Columns("Compa...