fluent-nhibernate

How can I use a composite-id with a class as the id field in fluent nhibernate?

I've got a mapping file like this: <class name="Resource" table="resource" discriminator-value="null"> <composite-id name="Key" class="Models.Bases.ClientKey, Models"> <key-property name="Id" column="ID" type="int"/> <key-property name="SiteId" column="clientID" type="int"/> </composite-id> <property name="Name" ty...

Fluent nHibernate with BindingList<T>

nHibernate is giving the error : Custom type does not implement UserCollectionType: myApp.Domain.OrderLineCollection. BindingList implements IList, so why is nHibernate trying to use UserCollectionType instead of IList? public class OrderHeader { public virtual int OrderHeaderId { get; set; } public virtual string OrderNumber...

nHibernate "HasMany" without explicit FKs

I've got a data model that I'm not sure fluent nHibernate supports - was wondering if anyone could tell me whether it does, and if so, how to do it. The basic structure is: create table Container ( id int identity(1,1) NOT NULL, root_item_id int ) create table ItemRelationship ( id int identity(1, 1) NOT NULL, parent_item_id...

Fluent NHibernate - automatic schema building

Okay, I have a database, but no tables in it. I have some entity classes. I'm trying to setup Fluent NH to do automappings with automatic schema export. First, this is possible, right? Second, if so, what am I doing wrong here: private ISessionFactory CreateSessionFactory() { return Fluently.Configure() .D...

(Fluent) NHibernate mapping for class with calculated properties

I have the a class similar to the following (nb! names have been changed to protect the innocent): public class Person { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual DateTime Birthday { get; set; } public virtual TimeSpan Age { get { return DateTime.Now - this.Birth...

Fluent NHibernate: override derived classes not in the base class auto-mapping

The story: I had class User and class Organization: User. I did not use any mappings for these classes, let FNH do mapping automatically. Then, I added public class OrganizationMap : IAutoMappingOverride<Organization> { public void Override(AutoMap<Organization> mapping) { } } Notice there're no overrides. ...

Help me choose between linq to sql and nhibernate based on the following

Hi, Struggling between choosing linq2sql and nhibernate. Let me give you some insight in the application in point form: this is a asp.net mvc application it will have lots of tables, maybe 50-60 (sql server 2008) i would want all the basic crud logic done for me (which I think nhiberate + repository pattern can give me) i don't have ...

How do I make a self-referencing many-to-many relationship in Fluent NHibernate mapping?

Can someone tell me how to accomplish this mapping using Fluent NHibernate? It's simply an account table with a composite key, that has many child accounts in a conjunction table. Here's the working NHibernate mapping and the create SQL it generates: <?xml version="1.0"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-impo...

Map Composition in Fluent NHibernate

Hi, There are 2 classes: Product and Image. The Product has only one Image. No orphan Images can exist. This represent composition relationship in UML which means: Assigning Product.Image a newImage results in following delete old image; insert new image; link new image to the product. Now I need to map it to the RDBMS...

Reducing logging output from Fluent NHibernate

I have a feeling this is a dumb question I should have been able to find out the answer to myself, but my searches have turned up nothing, so here I am asking the question. I'm using Fluent NHibernate for my project and all is good. Except that Fluent spams the log savagely with all of its mapping info. I'm relatively new to NHibernate ...

ManytoMany Fluent NHibernate Not Saving

This is my mapping public class SubMatterMapping : ClassMapping { public SubMatterMapping() { LazyLoad(); Map(x => x.Description); Map(x => x.SubMatterCount); References(x => x.SubMatterStatus).WithForeignKey().TheColumnNameIs("StatusID").FetchType.Select(); HasManyToMany(x =...

NHibernate component with a one-to-many relation from parent

Say I have a Queue table and a Job table. In the Job table there is a foreign key column QueueId for the Queue table, i.e. Queue.Id <-- Job.QueueId Using Fluent NHibernate it is pretty straightforward to map this to a property in the Queue class, i.e. /* QueueMap */ HasMany(x => x.Jobs) .KeyColumnNames.Add("QueueId"); But ass...

Fluent NHibernate. Auto Mapping and Conventions

Im new to NHibernate, the configuration aspect of it has always seemed overly onerous to me. Yesterday, I came across the Auto Mapping features of Fluent NHibernate and was suitably impressed. To educate myself, I set myself the challenge of attempting the 'Getting Started First Project' (http://wiki.fluentnhibernate.org/show/GettingSta...

How to use fluent nhibernate to map a value type collection?

......... <property name="Title" /> <set name ="Contacts" lazy="false" table ="Ad_Contacts"> <key column="Ad_Id"></key> <element type ="String" column="Contact" not-null="true"></element> </set> ......... HasMany(x => x.Contacts).AsSet() , which is the statement I used for fluent nhibernate mapping. It doesn't work. Contacts is...

Fluent NHibernate / NHibernate Inheritance Question

Possibly a dumb question but I have a number of entities all inheriting from a base entity. The base entity does not have a table in the database. Each entity has its own table and the table definition is exactly the same. Extremely simplified example of the code is below. public abstract class BaseEntity { public virtual string som...

Fluent Nhibernate WrongClassException with Polymorphic Parent

Hello, I have been using joinedsubclass inheritence mapping for a while and decided to switch to table-per-class because it allows more efficient subtype descrimination. However on making the change I now get the below exception. Object with id: 1 was not of the specified subclass: MyModel.FooBase (Discriminator was: '2') Abridged cl...

How do I configure FluentNHibernate to not overwrite an existing SQLite db file?

Here is my configuration: this.factory = Fluently.Configure(). Database(SQLiteConfiguration.Standard.UsingFile("foo.db"). ShowSql()). Mappings(m => m.FluentMappings.AddFromAssemblyOf<Bar>()). ExposeConfiguration(BuildSchema). BuildSessionFactory(); BuildSchema looks like this: private static void BuildSchema(C...

How to add new object to an IList mapped as a one-to-many with NHibernate?

My model contains a class Section which has an ordered list of Statics that are part of this section. Leaving all the other properties out, the implementation of the model looks like this: public class Section { public virtual int Id { get; private set; } public virtual IList<Static> Statics { get; private set; } } public class...

Fluent NHibernate Inheritence Base Class Question

I have a Base Class called User. Teacher and Student derive from User class. There is a table called Users. Users have some common properties which will be used by Teacher and Student classes. The User class mapping looks something like this: public class UserMap : ClassMap<User> { public UserMap() { I...

Custom naming conventions in Fluent NHibernate AutoMapping

Hello, according to this Post it is possible to change the naming convention from "[TableName]_id" to "[TableName]ID". However when I saw the code, I wasn't able to do it with my rather new (about 6 weeks old) version of Fluent NHibernate. Original code: var cfg = new Configuration().Configure(); var persistenceModel = new Persistence...