fluent-nhibernate

NHibernate & Fluent: Mapping Enum Bitmasks, but storing as items in another table

Hi all, I have a class called User. User can have one or more roles, defined in an bitmask enum. The user has a Role property that i can use via: user.Roles = Roles.User | Roles.Other; In the database I have a Users table and a User_Roles table. For every role that a user has, i want to store it in the Users_Roles table with the Use...

Fluent NHibernate: testing collection mapping with CheckList

Hello guys. I've used Fluent NH in some projects but I'm having some problems with using the PersistenceSpecification class for testing a collection mapping. Here's the code for my classes (I'm just putting here the collection definition): public class Ocorrencia : EntityWithAction, IHasAssignedId<Int32> { private IList<Interve...

Unusual? HasManyToMany NHibernate Mapping

Database Strucutre: Shows ID Name Genres ID Name ShowsGenres ShowsID GenresID Above is my Database I am trying to figure out how to map this properly. My Show object is like this: public class Show { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual IList<Genre> Genres { get; se...

Nested Maps in Fluent NHibernate

I have a database table with Sqlite structure: CREATE TABLE Cashflows ( Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Fund_Id INTEGER NOT NULL, CashflowDate DATETIME NOT NULL, CashflowType INTEGER NOT NULL, CashflowValue DOUBLE NOT NULL ); Fund_Id is just a standard reference to the Fund table. In Fluent NHiberna...

Fluent NHibernate Mapping - Composite Key

Hi, I'm trying to map the following tables/entities in FNH and seem to be getting nowhere fast! **Tables** Contacts ID (PK - int - generated) ... PhoneTypes ID (PK - varchar - assigned) (e.g. MOBILE, FAX) ContactPhones ContactRefId (PK - FK to Contacts) PhoneTypeRefId (PK - FK to PhoneTypes) ... (I should...

Fluent Nhibernate System.ApplicationException : For property ‘Id’ expected ‘1’ of type ‘System.Int32’ but got ‘2’ of type ‘System.Int32’

Hi I am writing unit tests for fluent Nhibernate, when I run the test in isloation it passes, but when I run multiple tests. or run the test more than once it starts failing with the message below System.ApplicationException : For property 'Id' expected '1' of type 'System.Int32' but got '2' of type 'System.Int32' [TextFixture] public v...

sql connection timeout

hello, i have my server written with structure map and fluent nhibernate, when i run my server from my pc and direct him to the db on another server i get a sqlexception that tells me that the timeout expired this is the message : Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not resp...

Mapping a primary key of type binary(16)

I have a legacy schema that contains tables with composite keys where some of the keys are of type binary(16) -- its a MD5 hash of the other columns. I am having trouble finding the right way to map this structure. The first thing I tried was to simply use byte[] as my domain type, which NHibernate quickly dismissed since byte[] does not...

Fluent nHibernate - DiscriminateSubClassesOnColumn with multiple tables?

I've been trying to wrap my head around subclasses and joined subclasses in Fluent nHibernate for a few days now without making any sort of headway. I've looked at the wiki but it doesn't seem to give me enough information, and googling returns me old results that uses depreciated code or are seemingly unrelated. I just want a simple...

NHibernate - Select query in Formula attribute of Property element is not working....

I am new to NHibernate. I am using following property elements in my hbm file... <property name="CountryId" length="4" /> <property name="CountryForCustomer" formula="(SELECT * FROM SystemCountry WHERE SystemCountry.CountryId = CountryId)" /> Here I am trying to g...

Fluent NHibernate: How to map an IList<Dictionary<string, string>>

I would like to have a structure like this: Mapping class int ID {get;set;} IList<KeyValuePair<string,string>> Criteria {get;set;} Criteria class int ID {get;set;} int MappingID {get;set;} string FirstCriterion {get;set;} string SecondCriterion {get;set;} (int index {get;set;}) How can I get this keyvaluepair mapped? I tried with Ha...

Is it a good idea to test for id value while testing Fluent NHibernate mappings?

I'm working on tests for my Fluent NHibernate mappings, and my question is - is it a good idea to test for id value if Id column is represented by identity in Sql Server? Since it changes after each insert, how can I possibly do it? new PersistenceSpecification<Product>(session) .CheckProperty(p => p.Id, 1) ...

Using Fluent-NHibernate with tables in different database schemas

I have a database that I'm running several applications from. I like to separate the tables by creating a schema for each application. For my newest application I'm using FluentNHibernate. Seems like I have most of the plumbing correct but when I try to query one of my tables it can not find my table. I ran query analyzer and saw the sch...

Fluent nhibernate automapping collection

Hi, I am trying to map my collections with FNHib automapping. The problems that I want to solve are: 1) I want all my collections in the project to be mapped via private field. How can I say that globally? 2) Is there any way to automap bidirectional relationship without explicitly overriding each of my entities. class OrganizationEnt...

SetCacheable throws IndexOutOfBoundsException

I have following query in NHibernate where the result is a list of DTO's, not entities: var result = query //.SetCacheable(true) .SetResultTransformer(new MyDTOTransformer()) .List<DTO>(); This works with SetCacheable in comment but it throws an IndexOutOfBoundsException when I set SetCa...

How to generate hbm.xml file from FluentNHibernate

I'm trying to follow this tutorial but instead of generating the expected hbm.xml files with my mappings in it generates simple .cs class for my entities like for example: public class ProductMap : ClassMap<Product> But I already defined those myself in code. I'm after the .hbm.xml which I can use in standard NHibernate at this time. ...

What options are available for a vb.net developer when using Fluent NHibernate?

I've been using c# for the past year and I enjoy the power you get with Fluent NHibernate. One question that I get from friends is "nice but how can vb.net programmers use this?" So for example- the below is a c# mapping class. How would someone do this with vb.net? public class PostMap : ClassMap<post> { public PostMap() { Table("Po...

Parent - Child relationships in NHibernate

I want to be able to create a parent object with children and let the parent handle the update, saves and deletes. My map classes. ParentMap Id(x => x.Id, "ID").GeneratedBy.Identity(); Map(x => x.Name); HasMany(x => x.Children) .KeyColumn("ParentID") .Inverse() ....

Fluent NHibernate misplaced duplicate field

I think I'm misunderstanding something about how this works. This is my fluent mapping: public class FunctionInfoMap : ClassMap<FunctionInfo> { public FunctionInfoMap() { Id(x => x.Id); Map(x => x.Name); Map(x => x.Signature); Map(x => x.IsNative); Map(x => x.ClassId); References(x => x.Class, "ClassId"); HasMa...

fluent nhibernate table column type mapping

hi there, i've been working with fluent nhibernate for a couple of months and i think it's a very flexible tool (even if 'tool' is maybe incorrect term) :) i've to work on a new project and i'm still considering using fluent nhibernate solution to map my db on a repository layer. The matter is that, for some reason i really don't unders...