fluent-nhibernate

Convert Stored Procs using Fluent N Hibernate

Can u send me a sample of how to convert stored procedures having left/outer joins , nested querries , udfs to equilavent fulent n hibernate code . All the examples given are simple scenarios but i need to have a sample of a complicated scenario . thanks ...

How to Map Two Tables To One Class in Fluent NHibernate

I am having a problem with fluent nhiberbate mapping two tables to one class. I have the following database schema: TABLE dbo.LocationName ( LocationId INT PRIMARY KEY, LanguageId INT PRIMARY KEY, Name VARCHAR(200) ) TABLE dbo.Language ( LanguageId INT PRIMARY KEY, Locale CHAR(5) ) And want to build the following class def...

Fluent NHibernate Mapping - Saving Child object

I'm having a problem with Fluent NHibernate mappings, I think, and can't quite get past how I should be setting the mapping to avoid an issue. I have a business object (literally, a "business"), and a review object. Each Business can have multiple reviews that are created on a page in the UI. The business is a property of the Review, ...

How to map blog archive using NHibernate

I would like to format a blog archive like below given Year=2008 and Month=2 (February): 2009 2008 March February Article C Article B Article A January 2007 I have the following classes: public class BlogArchive { public int Year { get; set; } public int Month { get; set; } public List<BlogYear> Years { get; set; } }...

Fluent NHibernate: Prevent class from being mapped

Hi, I am sure it is a piece of cake, but I can't find it using google. I need to EXCLUDE a single class from mapping. My current configuration is: return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.Is(@"Data Source=PC\SQLEXPRESS;......"))) .Mappings(m => ...

1 table = 1 class + 1 one of 2 abstract class

Hi I have two tables which looks something like this Table Queue int ID; string Name; int MessageID; string To string From string Topic string Email Table Message int ID int MessageType This is a rather simplified version, but what we did in the classes was to create 1 class named class Queue int ID string Name Message...

Private property mapping with fluent nhibernate

Hi, I am getting exception mapping a private property.This is the situation: I have this in Entity.cs: privat int m_Inactive; and in EntityMap.cs I have : Map(x => Reveal.Property("m_Inactive")).ColumnName ("INACTIVE"); But I get this error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of a...

Error with hilo in NHibernate - "could not read a hi value - you need to populate the table"

I've genereated a schema for my (SQL 2005) db using SchemaExport, and it's created a table CREATE TABLE [dbo].[hibernate_unique_key]( [next_hi] [int] NULL ) ON [PRIMARY] When I try to add an entity, I get the error "could not read a hi value - you need to populate the table". What am I meant to do? edit: I've inserted a 1 into th...

Collection not populated with Fluent NHibernate

I am having an odd error when using Fluent NHibernate. I have an entity object called Module that is my "aggregate root" if you will. I created and tested my mappings for the Module class and the various related classes and tried creating a Module with all of its fields filled out and saving it. This worked correctly. My problem is w...

Issues when trying to remove the connection between two objects in a many-to-many relationship

Hi I have two entities: Group and ContactInfo. These are connected with a many-to-many relationship (mapped using Fluent NHibernate). I'm not able to remove a "ContactInfo" from a Group. The join-table is not updated. (It is when inserting new elements) My code (excerpt): public class GroupMap : ClassMap<Group> { public GroupMap(...

How can I make NHibernate aware of a first-class "Null Object", without database persistence?

I would like to make use of the Null Object pattern in my domain, but I don't want to have records in my database that relate to it - I would prefer it if NHibernate were able to map a SQL null value to my Null object, and vice versa. Is this possible (using Fluent NHibernate for mappings) P.S. This seems like it is a fairly common iss...

How to map this model

Hello: A TimeSheetActivity class has a collection of Allocations. An Allocation is a value object (immutable) looking something like this: public class Allocation : ValueObject { public virtual StaffMember StaffMember { get; private set; } public virtual TimeSheetActivity Activity { get; private set; } public virtual DateTi...

Using Fluent NHibernate Auto Mapping to map IDs of type object from base Entity class

In the project I'm working on now, we have base Entity class that looks like this: public abstract class Entity<T> where T : Entity<T> { public virtual object Id { get; protected set } // Equals, GetHashCode overrides, etc... } Most classes inheriting from Entity should map Id to int column in SQL Server database, but at l...

How do I get fluent nhibernate to create a varbinary(max) field in sql server

Hi, How can I get fluent nhibernate to create a varbinary field in a sql server 2005 table that uses a field size of varbinary(max)? At the moment I always get a default of varbinary(8000), which isn't big enough as i'm going to be storing image files. I've tried using CAstle.ActiveRecord but havent had any success yet. [ActiveRecord...

NHibernate mapping: UserTypes with many-to-one

New to NHibernate and learning it as we are modifying an existing solution to use this ORM. Ideally, the storage structure and object classes need to stay the same, so Ive come across one or two mapping problems. One class 'Money' has a value and currency. The value is a double and the currency is a foreign key to a list table of curren...

Fluent NHibernate - How to use/map a database view to populate a contained collection?

I have these classes: public class FloorFill { protected FloorFill(){} public virtual ProductCatalog Catalog { get; set; } public virtual Inventory BatchedItem { get; set; } public virtual Transaction Batch { get; set; } public virtual int ItemReference { get; set; } public virtual IList<InventoryLocation> Backst...

filtering infrastructure for fluentnhibernate over 3 tiers application

hello, i have a 3 tier app that needs to be capable of doing data filtering according to user requests, i'm working with fluentnhibernate to manage the crud of my entities. my question is how can i pass the filter from the client to the server (over wcf). the filter classes of fn is not serializable. any solution? ...

NHibernate with models having properties that are classes

I'm using FluentNHibernate but NHibernate XML will do. Say I have this model public User { public User() { ProfilePicture = new Picture(); } public Guid Id { get; private set; } public Picture ProfilePicture { get; set; } } public Picture { int width; int height; } How do I tell NHibernate how to ...

Using sharp architecture and subclassing entity

I've been trying to use #harp architecture and Fluent-NHibernate. I am trying to sublass off of SharpArch.Core.DomainModel.Entity since I have some entities in my domain model that must have a unique name. public abstract class UniqueNamedEntity : Entity { protected UniqueNamedEntity() { } protected UniqueNamedEntity(stri...

Fluent NHibernate with Castle Facility Naming Strategy

I have Fluent NHiberate with the Castle Facility up and running. However, how do you set the NamingStrategy? I tried with the Configuration object, with no luck. Does my naming strategy need to be registered in my Windsor container? ...