fluent-nhibernate

Fluent NHibernate Default Conventions

I'm trying to find a resource that shows what default conventions Fluent NHibernate uses with no custom (user) conventions applied. Thanks! ...

How to rename a column/proprety within fluent NHibernate?

Say I already have a Table: Customer First Last Thus I would have an object with properties such as: Customer.First Customer.Last If I wanted to refactor the code so that I rename the properties: Customer.FirstName Customer.LastName Is there a way to indicate to NHibernate to update First to FirstName and so on? I already know ho...

FluentNHibernate Lookup Table

This is possibly an easy one that I can't seem to get past. I've created a "Product" class which has a list of "Accessories". Each "Accessory" is just another product referenced by a lookup table. Table setup: Product ------- ProductID int Name varchar(200) AccessoryProduct ---------------- ID int ParentProductID int ChildProductID i...

NHibernate Naming Conventions - Eliminate Keyword Conficts

How do I escape keyword conflicts when NHibernate generates my column names using FluentNHibernate? NHibernate generated this for me and "Key" is a conflict. create table Setting ( Key NVARCHAR(MAX) not null, Value NVARCHAR(MAX) null, primary key (Key) ) ...

Fluent NHibernate and the repository pattern

Is this a good guide if I want to implement the repository pattern in my asp.net mvc application? ...

How to create NHibernate Criteria for Map/Dictionary associations

Hi all, I have a Fluent NHibernate mapping like this. public PersonMap() { Table("PERSON"); Map(x => x.FirstName) .Not.Nullable(); Map(x => x.LastName) .Not.Nullable(); HasMany(x => x.Ids) .AsMap<string>("id_type") .Cascade.SaveUpdate(); } So I could do something like this. Person p = new Person(); p.Ids["id1"...

NHibernate.Spatial and Sql 2008 Geography type - How to configure

I am trying to use Nhibernate with the Sql 2008 Geography type and am having difficulty. I am using Fluent Nhibernate to configure which I am fairly new to so that may be the problem as well. First, the class I am trying to persist looks something like: public class LocationLog : FluentNHibernate.Data.Entity { public virtual new int...

Quoting table names with fluent mapping

I have an Order entity in my domain and this name results in erroneous sql statements. I want to quote the table name and don't know how to do it with fluent configuration. Should I add a convention? ...

Is it possible to use both automapping and schema generation with Fluent NHibernate?

I'm using the following: Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString)) .Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Incident>() .Where(t => t.Namespace.StartsWith("EDA.DomainModel.POCO")))) .ExposeConfiguration(BuildSchema) .BuildSessionFac...

Mapping nested components in Fluent NHibernate

Hi all, I have a 'User' Entity that contains an 'Address' Value Object. I have this mapping ok using FNH's Component concept. However, the Address VO also contains a Country which is another value object. I had assumed that this should be just nested as another component, but this doesn't seem to work. Can anyone tell me how I shoul...

FluentNHibernate mapping to a view

I have a many to many relationship between entities and there is a table view acting as a lookup table defining the relationship. I'm curious how to map to a view as opposed to a table within a database. ie, Table mapping: public SomeMap() { Id(...)//set Id and other mapped properties HasManyToMany(x => x.Items) .Table("S...

Parent save doesn't cascade to children of same abstract in FNH

I am using AutoMapping in FNH 1.0 (with Tom Cabanski's modified #arch from 9/2009) to persist a parent-child relationship. The parent and child, Managers and Employees, are both of type User. Managers has a collection of DirectReports of IList because a Manager can have another manager as a direct report. I have a test where I instant...

Fluent NHibernate HasManyToMany only works on first load

This is a weird one for me. I have a simple domain with 2 entities Company and Carrier. They have a m:m relation via another table. I set up my Fluent mappings as so public partial class Carrier { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual IList<Company> Companie...

Id property not populated

I have an identity mapping like so: Id(x => x.GuidId).Column("GuidId") .GeneratedBy.GuidComb().UnsavedValue(Guid.Empty); When I retrieve an object from the database, the GuidId property of my object is Guid.Empty, not the actual Guid (the property in the class is of type System.Guid). However, all of the other properties in the o...

Fluent NHibernate HasMany Collection Problems

Update: It appears that changing my mapping from Cascade.All() to Cascade.AllDeleteOrphan() fixes most of my issues. I still have to explicitly set the Company property on the OperatingState, which seems unnecessary as it's being added to the Company entity, but at least I can work with that during an update. I still need to test that wi...

Hibernate complex Mappings

We use a pesonal design to store modified rows. For the data we need to keep, we use 2 tables; the first with fields that don't change, the second uses soft delete. +----------+ +---------------+ | TableBase| | Table | +==========+ +===============+ | Id | | TableId | | FieldA | | Id | +--------...

Is it possible to use NHibernate without altering a DDD model that is part of a framework

I dig a lot of things about the DDD approach (Ubiquitous language, Aggregates, Repositories, etc.) and I think that, contrary to what I read a lot, entities should have behavior rather then being agnostic. All examples I see tend to present entities with virtual automatic properties and an empty constructor (protected or worst, public) a...

Fluent NHibernate Automap does not take into account IList<T> collections as indexed

I am using automap to map a domain model (simplified version): public class AppUser : Entity { [Required] public virtual string NickName { get; set; } [Required] [DataType(DataType.Password)] public virtual string PassKey { get; set; } [Required] [DataType(DataType.EmailAddress)] public virtual string E...

How to map Type with Nhibernate (and Fluent NHibernate)

Let's say I have something similar to this : public class DataType { //For NHibernate private DataType(){} public DataType(string name, Type type, string defaultValue) { Name = name; TypeOfContent = type; DefaultInvariantStringValue = defaultValue; } public string Name { get; set; } ...

Select n+1 problem

Foo has Title. Bar references Foo. I have a collection with Bars. I need a collection with Foo.Title. If i have 10 bars in collection, i'll call db 10 times. bars.Select(x=>x.Foo.Title) At the moment this (using NHibernate Linq and i don't want to drop it) retrieves Bar collection. var q = from b in Session.Linq<Bar>() ...