fluent-nhibernate

How to map it? HasOne x References

Hi everyones, I need to make a mapping One by One, and I have some doubts. I have this classes: public class DocumentType { public virtual int Id { get; set; } /* othes properties for documenttype */ public virtual DocumentConfiguration Configuration { get; set; } public DocumentType () { } } public class D...

Simplest way of generating new DB tables from Fluent NHibernate?

Given: A DB (containing data), a set of model entity objects, and working NHibernate (fluent) mappings. What is the easiest way to generate the required new DB tables, when new model entities and mappings are added? ...

fluent nhibernate not caching queries in asp.net mvc

I'm using a fluent nhibernate with asp.net mvc and I not seeing anything been cached when making queries against the database. I'm not currently using an L2 cache implementation. Should I see queries being cached without configuring an out of process L2 cache? Mapping are like this: Table("ApplicationCategories"); Not.LazyLoad(); C...

nhibernate fluent repository pattern insert problem

I am trying to use Fluent NHibernate and the repository pattern. I would like my business layer to not be knowledgeable of the data persistence layer. Ideally I would pass in an initialized domain object to the insert method of the repository and all would be well. Where I run into problems is if the object being passed in has a child ...

FluentNHibernate: Not.Nullable() doesn't affect output schema

Hello I'm using fluent nhibernate v. 1.0.0.595. There is a class: public class Weight { public virtual int Id { get; set; } public virtual double Value { get; set; } } I want to map it on the following table: create table [Weight] ( WeightId INT IDENTITY NOT NULL, Weight DOUBLE not null, primary key (WeightId) ) ...

Configuring FluentNHibernate to use multiple databases in .net

I am using c#.net and we are using nhibernate. It was fine until i was connecting to a single database. Now in the same project i am suppose to use multiple database, how can this be achived. Configuration of the nhibernate is lies in web/app.config file. How to specify multiple connection string over there and how to create multiple s...

Delete only reference to child object

I'm running in to a bit of a problem where any attempt to delete just the reference to a child also deletes the child record. My schema looks like this Person Organisation OrganisationContacts : Person OrgId PersonId Role When removing an Organisation i want to only delete the record in OrgnaisationContacts, but not touch the Person...

Many-To-Many Query with Linq-To-NHibernate

Ok guys (and gals), this one has been driving me nuts all night and I'm turning to your collective wisdom for help. I'm using Fluent Nhibernate and Linq-To-NHibernate as my data access story and I have the following simplified DB structure: CREATE TABLE [dbo].[Classes]( [Id] [bigint] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](100) NOT...

Mapping a localized string with NHibernate

Most of our lookup tables have corresponding localization tables. Something like this for example: create table GENDERS ( GENDER_CODE char, DESCRIPTION varchar ) -- Localization table: create table LC_GENDERS ( LOCALE varchar, GENDER_CODE char, DESCRIPTION varchar ) In this example the default (en-US) values are ...

Where to put NHibernate query logic?

I am trying to set up proper domain architecture using Fluent NHibernate and Linq to NHibernate. I have my controllers calling my Repository classes, which do the NHibernate thang under the hood and pass back ICollections of data. This seems to work well because it abstracts the data access and keeps the NHibernate functionality in the...

Combining a one-to-one relationship into one object in Fluent NHibernate

I have a one-to-one relationship in my database, and I'd like to just combine that into one object in Fluent NHibernate. The specific tables I am talking about are the aspnet_Users and aspnet_Membership tables from the default ASP.NET Membership implementation. I'd like to combine those into one simple User object and only get the fiel...

Adding object to child collection causes entire collection to load in Fluent NHibernate.

Hello, I have my Parent object, which contains an ICollection of Children objects. The Children are lazy loaded and I do not need them in the context of my scenario. However, when I try to add a new child object to my Children collection, it kicks off the lazy load and loads all 7000 child records. I assume I am making a newbie mistak...

Is there anything wrong with this many-to-many Fluent Nhibernate mapping?

i have this: <set name="Identities" table="tIdentityGroups" inverse="true" batch-size="10" cascade="none"> <cache usage="read-write" /> <key column="GroupID" /> <many-to-many class="Identity" column="IdentityId" /> </set> and have translated it to this: HasManyToMany<Identity>(x => x.Identities) .Tab...

Problem using VerifyTheMappings in Fluent NHibernate

I'm using Fluent NHibernate to map classes to a database and I'm using PersistenceSpecification.VerifyTheMappings() to verify the mappings in my unit tests. If ClassA has a property of type ClassB and I want to verify the mapping, I first create an instance of ClassB then I try to use it with PersistenceSpecification like this: Class...

FNhibernate, GeneratedBy.HiLo, hibernate_unique_key etc.

Hi, I have started using the s#arp architecture which uses FNhibernate and GeneratedBy.HiLo to generate primary keys (there is also table hibernate_unique_key). Apparently, this is recommended practise and I would like to stick with this. Now to my problem. I have used NHibernate and hbm mapping quite a bit and usually used identity co...

Fluent NHibernate Mapping and Formulas/DatePart

Hi There, i have a very simple table with a Datetime column and i have this mapping in my domain object. MyDate is the name of the datetime column in the DB. public virtual int Day { get; set; } public virtual int Month { get; set; } public virtual int Year { get; set; } public virtual int Hour { get; set; } public virtual int Minutes...

Prevent Nhibernate schemaexport from generating foreign key constraints on has many relationship

I have a mapping like this: HasMany(x => x.Orders).KeyColumn("CustomerID"); Which is causing a constraint like this to be generated by schemaexport: alter table [CustomerOrder] add constraint FK45B3FB85AF01218D foreign key (CustomerID) references [Customer] I have tried adding .NotFound.Ignore() like on a References(...

NHibernate How to specify custom sql type only in production

I am saving binary files into a Sql Server 2005 Db using Fluent NHibernate. However, I am using SQLite to run my (pseudo) Unit Tests. I need to use a custom Sql type for Ms Sql, but it would throw an error on SqlLite. What strategies can I use? This is the Map file: public class BinaryFile { public BinaryFile() { ...

How do I create/use a Fluent NHibernate convention to automap UInt32 properties to an SQL Server 2008 database?

I'm trying to use a convention to map UInt32 properties to a SQL Server 2008 database. I don't seem to be able to create a solution based on existing web sources, due to updates in the way Fluent NHibernate works - i.e. examples are out of date. I'm trying to have NHibernate generate the schema (via ExposeConfiguration). I'm happy to ha...

Help creating a ColumnName Convention using FluentNHibernate

I've been trying to specify a custom naming convention for my database table columns. So far, I have been able to setup a convention for the table's name, but not the actual columns. I've seen a few guides on the internet, but they're not working using the latest Fluent NHibernate (1.0.0 RTM). public class CamelCaseSplitNamingConvention...