fluent-nhibernate

Inherited fluent nhibenate mapping issue

I have an interesting issue today!! Basically I have two classes. public class A : B { public virtual new ISet<DifferentItem> Items {get;set;} } public class B { public virtual int Id {get;set;} public virtual ISet<Item> Items {get;set;} } The subclass A hides the base class B property, Items and replaces it with a new proper...

Fluent NHibernate Mapping Issues

Orders Table Id(x => x.ID, "ID"); ... HasMany<OrdersLineItems>(x => x.LineItems).KeyColumn("ID").Inverse().Cascade.All(); OrdersLineItems Table Id(x => x.ID, "ID"); ... References(x => x.Orders, "OrdersID").ForeignKey("ID"); I am trying to set up a mapping where the ID from the Orders Table is referenced in OrdersID within OrdersLin...

Fluent NHibernate: Entity from one table, but reference will map to another tables?

Given the following tables: Product ----------- ProductId : int (PK) ProductVersion : int ProductHistory ----------- ProductId : int (PK) ProductVersion : int (PK) Item ----------- ItemId : int (PK) ProductId : int (FK) -- ProductId + ProductVersion relates to ProductHistory ProductVersion : int (FK) And the following cl...

Fluent NHibernate join table mapping

Reverse engineering an existing database to map with N-Hibernate using Fluent N-Hibernate. How can I map this? Address table Id Address1 Address2 Person table Id First Last Types Id TypeName PersonAddress table (A person can have home, business etc addresses) Id PersonId (Id from person table) AddressId (Id from addre...

Fluent-NHibernate: How does one translate composite-element tag to fnh?

How do we express this in FNH? <class name="Order" .... > .... <set name="PurchasedItems" table="purchase_items" lazy="true"> <key column="order_id"> <composite-element class="Purchase"> <property name="PurchaseDate"/> <property name="Price"/> <property name="Quantity"/> <many-to-one name="Item" c...

Fluent NHibernate SchemaExport to SQLite not pluralizing Table Names

I am using SQLite as my db during development, and I want to postpone actually creating a final database until my domains are fully mapped. So I have this in my Global.asax.cs file: private void InitializeNHibernateSession() { Configuration cfg = NHibernateSession.Init( webSessionStorage, ...

Fluent NHibernate: Mapping a column with a different name

Let's say I have a table: Project Id Title ProjectManagerId ContactId ProjectManagerId and ContactId are both id's from a table named Person: Person PersonId Firstname Lastname How can I map these two columns to create a person object? (either using automapping or fluent's normal mapping). Thanks ...

How to configure cache regions in fluent nhibernate and syscache2

Hi, I've been trying to implement cache regions with fluent nhibernate and I've done the following so far: Setup caching in Fluently.Configure():   private static ISessionFactory CreateSessionFactory() { string csStringName = Environment.MachineName; var nhibConfigProps = new Dictionary<string, string>(); ...

Math operations in nHibernate Criteria Query

Dear All, I am having troubles with a nHibernate query. I have a db which stores vehicle info, and the user is able to search the db by make, model, type and production dates. Make, model & type search is fine, works a treat, it is the productions dates I am having issues with. So here goes... The dates are stored as ints (StartMonth...

One-to-one Mapping issue with NHibernate/Fluent: Foreign Key not updateing

Summary: Parent and Child class. One to one relationship between the Parent and Child. Parent has a FK property which references the primary key of the Child. Code as follows: public class NHTestParent { public virtual Guid NHTestParentId { get; set; } public virtual Guid ChildId { get { return ChildR...

Fluent Nhibernate external configuration

Hi! All examples of fluent nhibernate make such(or similar) call: c.AddMappingsFromAssembly(typeof(Product).Assembly); I don't want tu use "typeof(Product).Assembly" as i don't want to have reference to my domain project here ("Procuct" class). In ordinary NHibernate I would just create hbm.xml files and make following entry in web.co...

Manually setting the ID

I have a Users table where the "ID" field is a GUID field. Using ASPNET I am creating a user account and getting the GUID back. I am trying to create associated records in my tables with that GUID as the main ID. The problem I am running into is that when I manually set Users.ID NHibernate tries to do an Update, not an Insert. I see ...

INamingStrategy being ignored by (Fluent) NHibernate?

I am trying to write a naming strategy for NHibernate that will prefix table names based on what assembly the poco is defined in. Right now my strategy is just trying to append any prefix at all to the tables just to prove I have things wired up right. The problem that I am encountering is that I am able to create my INamingStrategy ...

Fluent NHibermate and Polymorphism and a Newbie!

I'm a fluent nhibernate newbie and I'm struggling mapping a hierarchy of polymorhophic objects. I've produced the following Model that recreates the essence of what I'm doing in my real application. I have a ProductList and several specialised type of products; public class MyProductList { public virtual int Id { get; set; } pu...

Fluent Nhibernate HasMany

I am having a gap in understanding and I would appreciate any help. When I create a HasMany relationship using a list, nhibernate creates an "index" column on my child table. If I query the table using a join, it crashes with "Null Index on collection" What I am not understanding is -- how is this "index" column managed/populated? M...

Fluent NHibernate automap a HasManyToMany using a generic type

I have a bunch of domain entities that can be keyword tagged (a Tag is also an entity.) I want to do a normal many-to-many (Tag -> TagReview <- Review) table relationship but I don't want to have to create a new concrete relationship on both the Entity and Tag every single time I add a new entity. I was hoping to do a generic based Ta...

Parent reference in automapped component in Fluent NHibernate

In Fluent NHibernate, given an automapped component, is there a convention for setting up a parent reference back to the "holder" of the component? By having for example a property named Parent or something like that? I can't seem to find any information about how to do it or issues about it. ...

Fluent NHibernate - Mapping a dictionary of component/value type objects as a HasMany

I have a class, Item that has many Rates. They are keyed by an enum, RateType. public class Item { int Id {get;set;} IDictionary<RateType, Rate> Rates {get;set;} // some other stuff } public class Rate { RateType Type {get;set;} decimal Amount {get;set;} decimal Quantity {get;set;} } I am overriding my mappin...

Nhibernate: Stop it from joining to a table that is not needed

I have two tables (tbArea, tbPost) that relate to the following classes. class Area { int ID string Name ... } class Post { int ID string Title Area Area ... } These two classes map up with Fluent Nhibernate. Below is the post mapping. public class PostMapping : ClassMap<Post> { public PostMapping() ...

Problem using FluentNHibernate, SQLite and Enums

I have a Sharp Architecture based app using Fluent NHibernate with Automapping. I have the following Enum: public enum Topics { AdditionSubtraction = 1, MultiplicationDivision = 2, DecimalsFractions = 3 } and the following Class: public class Strategy : BaseEntity { public virtua...