fluent-nhibernate

How to best design the entity data classes for the following SQL Schema?

I have the following database schema: The issue is how to create the entity data class in Nhibernate? Is this better: public class Store { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual IList<Product> Products { get; set; } public virtual IList<Employee> Staff { ge...

NHibernate Table Update Event

I have this table mapping (details don't really matter I think): WithTable("COPACKER_FACILITY"); Id(x => x.FacilityNumber, "FACILITY_NUM").GeneratedBy.Sequence("FACSEQ"); Map(x => x.FacilityName, "FACILITY_NAME").Not.Nullable().Trimmed(); Map(x => x.AddressLine1, "ADDR1").Not.Nullable().Trimmed(); ... WithTable("FACIL_OTH_AUDIT_INFO",...

Fluent NHibernate - How to map the foreign key column as a property

I am sure this is a straightforward question but consider the following: I have a reference between company and sector as follows: public class Company { public Guid ID { get; set; } public Sector Sector { get; set; } public Guid SectorID { get; set; } } public class Sector { public Guid ID { get; set; } public stri...

NHibernate 2 + Fluent Nhibernate medium trust

Will NHibernate 2 and\or Fluent Nhibernate work in a medium trust environment. If not are there any work-arounds? ...

NHibernate.MappingException: Unknown entity class

Hi I am trying to get test running that uses FluentNHibernate to map my entities. I get unknown entity class error. I have a Domain project that has my entities and the mappings in a seperate folder in that project. My test project has the Nhibrenate configuration in the App.Config. Any ideas please??? Malcolm EDIT: I have this m...

Fluent Nhibernate problem (ClassMap)

Hello! I have the following XML (.hbm): <property name="Geometry" column="the_geom"> <type name="NHibernate.Spatial.Type.GeometryType,NHibernate.Spatial"> <param name="subtype">MULTIPOLYGON</param> <param name="srid">-1</param> </type> </property> It´s using Nhibernate Spatial type... How can I map that property...

F#: Best way to de-fluent an API?

I'm extending Fluent NHibernate for better use with F# (namely, quotation support), and want some feedback on de-fluenting the API. F# requires that return values be used, unless they are type unit. So this ends up terminating every line with "|> ignore": type ProductMap() as m = inherit QClassMap<Product>() do let x = Unchecked.def...

FluentNHibernate: Invalid object name on SaveOrUpdate

Hi, I am trying to get FluentNHibernate up and running. When I try to add a entity object to the db I get "invalid object name 'Recipe' error in the inner exception and this the main exception could not insert: [OurRecipes.Domain.Recipe][SQL: INSERT INTO Recipe (EnteredByID, ModifiedOn, Method, PrepTime, CookTime, RecipeTitle) VALUES ...

How to get NHibernate SchemaExport to create SQL Server Timestamp columns?

I'm using the NHibernate HBM2DDL SchemaExport tool to generate my database from my entity objects, and I want to use SQL Server Timestamp columns for optimisitic concurrency. I've added properties to my entity object that look like this: public virtual byte[] Timestamp { get; set; } NHibernate will generate the Timestamp column, but t...

nhibernate: How do I map a component which references an enity?

My db looks somthing like this: MyEntity State ----- ----- id id street name stateId ... zip status ... My Model looks like this: class MyEntity { int id { get; set; } Address location { get; set; } string status { get; set; } // ... } class Address { string street { get; set; ...

(Fluent) NHibernate - Mapping Varchar to Int32

We work with legacy database which are saving integer values to the varchar column. We need to map this column to Int32 property and it works well if data in database column are numeric or NULL. But we have problems if column contains empty string instead of null - nhibernate throws error that it cannot convert it to integer. Is it p...

FluentNHibernate HasMany not filling collection.

Hi, I have a one to many relationship with the following config HasMany(x => x.Staff) .Inverse() .Cascade.All(); But I get a collection failed to initialize error. Dont I have to specify the foreignkey here, examples I found do not???? How does it know which is the foreign key? EDIT: Looking closer at the excep...

should i use NHibernate ?

i'm building a 3 tier wpf application. i heard that nhibernate is best for web applications. i know how to use nhibernate. should i use it or not?? are there any recommended or mappers that will be more suitable? ...

Ignore public/internal fields for NHibernate proxy

I have some entity types that I would like to lazy load. However, they have some internal (assembly) fields they expose, but are not used outside that class. These fields are compiler generated (F#) and I cannot change them. The an example exception is: NHibernate.InvalidProxyTypeException: The following types may not be used as ...

Obscure NHibernate/Fluent NHibernate error.

Hi, I've been encountering the following error when trying to build a session factory: PersistenceTests.Can_Map_Orders_To_Database : Failed System.IndexOutOfRangeException: Index was outside the bounds of the array. at NHibernate.Mapping.Column.set_Name(String value) at NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindColumns(XmlNode ...

bidirectional relationship patterns with nhibernate

In my domain, an Employee and a Department have a one-to-many bidirectional relationship; to let the child Employee synchronize this, I have an 'internal' access field for the Set (Iesi for NHibernate) of Employees that are in the Department, which would otherwise be readonly public. Like so: Department class: protected internal ISet<E...

NHibernate requires events to be virtual?

I'm attempting to map an entity hierarchy using NHibernate almost all of which have events. When attempting to build a session factory however, I get error messages similar to the following: Core.Domain.Entities.Delivery: method remove_Scheduled should be virtual Delivery is an entity in my domain model with an event called Sched...

Fluent NHibernate Component Mapping - String DB Value passed to a factory yields the required object type

Table: CREATE TABLE Instrument ( Id INT IDENTITY , Name VARCHAR(50) , Tenor VARCHAR(10) //... Model: interface ITenor { int Length { get; } string ToString(); } class DayTenor : ITenor { public int Length { get { return 1; } } public overri...

Mapping a ternary association with FluentNHibernate, using IDictionary<TKey,TValue>

I'm trying to map a ternary association using FluentNhibernate. I have 3 tables: TUser(PK int id, string name, ...) TGroup(PK int id, string name, ...) TRole(PK int id, string name, ...) And a 4th one that associates them, representing the ternary association: TUserGroupRole(FK int userid, FK int groupid, FK int roleid) Basicall...

NHibernate component mapping - Null Component

Howdy, I have a mapped entity, Matter, that has a mapped component, Injury. The only property on the Injury is DateOfInjury which is a nullable datetime. When I retrieve the Matter, if the DateOfInjury is null, the component is null. Thus something like this matter.Injury.DateOfInjury will throw. Could someone explain if I am doing ...