fluent-nhibernate

Is it possible to set a SQL server columns' description using a fluent nhibernate map?

I am using my fluent nhibernate mappings to generate my MS SQL Server database. I would like to be able to set a columns' description as part of this generation. ...

dynamic-component fluent automapping

Hi, Does anyone know how can we automatically map dynamic components using Fluent Automapping in NHibernate? I know that we can map normal classes as components, but couldn't figure out how to map dictionaries as dynamic-components using fluent automapping. Thanks ...

Lazy loading is not working for one to many

Any 1-M that use the primary key of the parent table, but any 1-M that uses a different column does not work. It generates the SQL correctly, but put the value of the key into the SQL instead of the column value I want. Example mapping: public TemplateMap() { Table("IMPORT"); LazyLoad(); Id(x => x.Imp...

Help making Fluent NHibernate create an oracle sequence for each table

I am using Fluent NHibernate's (1.0 RTM) automapping feature to create my oracle database schema. My issue is that all the tables are using a single "hibernate-sequence", whereas I would prefer (and my boss would demand) a sequence generator for each table. Any ideas? ...

Moving from NHibernate to FluentNHibernate: assembly error (related to versions)?

Not sure where to start, but I had gotten the most recent version of NHibernate, successfully mapped the most simple of business objects, etc. When trying to move to FluentNHibernate and do the same thing, I got this error message on build: "System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=2.1.0.4...

FluentNHibernate error -- "Invalid object name"

I'm attempting to do the most simple of mappings with FluentNHibernate & Sql2005. Basically, I have a database table called "sv_Categories". I'd like to add a category, setting the ID automatically, and adding the userid and title supplied. Database table layout: CategoryID -- int -- not-null, primary key, auto-incrementing UserID --...

How to map a private identity field in FluentNHibernate?

I'm experimenting with converting my NHibernate mapping files to FluentNHibernate. However, I'm already stuck on my first attempt. Here's a fragment of one XML mapping file: <class name="Contact" table="tblXContacts"> <id name="_id" column="ContactID" unsaved-value="0" access="field"> <generator class="identit...

mapping 'value object' collection in (Fluent) NHibernate

I have the following entity public class Employee { public virtual int Id {get;set;} public virtual ISet<Hour> XboxBreakHours{get;set} public virtual ISet<Hour> CoffeeBreakHours {get;set} } public class Hour { public DateTime Time {get;set;} } (What I want to do here is store information that employee A plays Xbox everyda...

NHibernate single column id that refererences another object

I have a class whose primary key is a single column, which is a reference to another object's single column primary key. The only way I can see to map this in NHibernate is to pretend it's a composite key (even though it's a single column key) and use the key-reference mapping. Is there a more appropriate way? Snippet below: class Comp...

Fluent Nhibernate - Mapping child in parent when Child has reference to parent and not using a list

I have a child object in the database that looks like this: CREATE TABLE Child ( ChildId uniqueidentifier not null, ParentId uniqueidentifier not null ) An then I have a parent like so. CREATE TABLE Parent ( ParentId uniqueidentifier not null ) Now, the problem is that in my Parent class, I have public virtual Child Child { get;...

How to add a WHERE clause on the second table of a 1-to-1 join in Fluent NHibernate?

I'm using a legacy database that was 'future proofed' to keep track of historical changes. It turns out this feature is never used so I want to map the tables into a single entity. My tables are: CodesHistory (CodesHistoryID (pk), CodeID (fk), Text) Codes (CodeID (pk), CodeName) To add an additional level of complexity, these table...

Fluent NHibernate beginner problem: How to convert single column data to custom class?

I am very new to Fluent NHibernate and I have a problem that I cant find the answer to. I have a string column in my database table, containing a mathematical expression i.e: "10 + 15 * 5". On my entity I have a property that I call Formula and this returns a class that contains the mathematical "formula" (not as a string). I beleive t...

Cascading items in a collection of a component

I have a component which contains a collection. I can't seem to get NHibernate to persist items in the collection if I have the collection marked as Inverse. They will persist if I don't have Inverse on the collection, but I get an insert and then an update statement. My mapping is : m => m.Component(x => x.Configuration, c => { c...

How to map an IDictionary<String, CustomCollectionType> in NHibernate

Very close to what I'm trying to do but not quite the answer I think I'm looking for: How to map IDictionary<string, Entity> in Fluent NHibernate I'm trying to implement an IDictionary<String, IList<MyEntity>>and map this collection to the database using NHibernate. I do understand that you cannot map collections of collections directl...

nhibernate/fluenthibernate throws StackOverflowException

Hi there! In my project I am using NHibernate/FluentNHibernate, and I am working with two entities, contracts and services. This is my contract type: [Serializable] public partial class TTLCContract { public virtual long? Id { get; set; } // other properties here public virtual Iesi.Collections.Generic.ISet<TTLCService> Se...

fluent nhibernate - storing and retrieving three classes in/from one table

Noob question. I have this situation where I have these objects: class Address { string Street; string City; ... } class User { string UserID; Address BillingAddress; Address MailingAddress; ... } What is the proper way of storing this data using (fluent) nHibernate? I could use a separate Address table an...

Fluent NHibernate: How to map an entire class as ReadOnly?

I have a few classes that read from very delicate tables, which is why I want them to be used by NHibernate as "ReadOnly". Establishing .ReadOnly() on each field map is really sloppy, and I'm not sure I trust it. How do I setup a class to be entirely readonly, as I can easily do with traditional XML mappings? Edit: The answer does work....

Entity Framework vs. nHibernate for Performance, Learning Curve overall features

I know this has been asked several times and I have read all the posts as well but they all are very old. And considering there have been advancements in versions and releases, I am hoping there might be fresh views. We are building a new application on ASP.NET MVC and need to finalize on an ORM tool. We have never used ORM before and h...

Fluent NHibernate/SQL Server 2008 insert query problem

Hi all, I'm new to Fluent NHibernate and I'm running into a problem. I have a mapping defined as follows: public PersonMapping() { Id(p => p.Id).GeneratedBy.HiLo("1000"); Map(p => p.FirstName).Not.Nullable().Length(50); Map(p => p.MiddleInitial).Nullable().Length(1); Map(p => p.LastName).Not.Null...

converting to Fluent NHibernate sessionmanager

Hello, I am changing my application to use Fluent NHibernate. I have created my Fluent mapping files and have now moved onto configuring my Session Manager. Currently, I use the following code - private ISessionFactory GetSessionFactory() { return (new Configuration()).Configure().BuildSessionFactory(); } Along with my hiberna...