nhibernate-mapping

Fluent NHibernate Automapper maps Enum to nvarchar(255) and not int?

Why are enums mapped as strings and not as ints when using automapper in Fluent NHibernate? ...

T-SQL CONVERT() Equivalent in NHibernate Mappings for VARBINARY to VARCHAR

I'm building an ASP.NET web application using NHibernate and a legacy database. In that database are fields of HTML stored as VARBINARY(MAX). The existing queries cast that data using CONVERT(VARCHAR(MAX), mainText). How can I do the same using NHibernate's HBM mapping? ...

NHibernate Populating Child Collection from Stored Procedure

I have an entity class that looks like : public class MyEntity { public virtual int Id { get; set; } public virtual ICollection<MyOtherEntity> MyOtherEntities { get; set; } } I have a stored procedure in my database that returns MyEntity objects joined with MyOtherEntity objects. I'd like to map this like: <sql-query name="My...

Cannot use Guid Identity in fluentnhibernate

I have the following mapping: public class MyClassMap : ClassMap<MyClass> { public MyClasseMap() { Table("TABLE_NAME"); Id(x => x.Id).Column("TR_ID"); } } When I try to retrieve all the entities using criteria objects I get the following: System.FormatException : Guid should contain 32 digits with 4 dashes...

NHibernate: Same class for multiple tables

Hi all, I have a file attachment class (FileAttachment) which is used in several other classes. e.g. An article contains multiple attachments. A category contains multiple attachments. These attachments are actually the same FileAttachment class but for obvious reason they are persisted in different tables. e.g. file attachment for an ...

NHibernate property formula filter error

I am using NHibernate 2.1. I am trying to use a filter in a property formula, but am getting the following error: filter-def for filter named 'SiteFilter' was never used to filter classes nor collections. Here is my mapping file: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="D...

NHibernate: How to Correctly Model This Schema

I have these related tables in my database: table [Files]: FileID FileName ------ -------- 1 /data/foo.jpeg 2 /data/bar.gif table [Attachments]: FileID DocumentID Caption ------ ---------- ------- 1 10 Foo is awesome. 1 20 Foo is horrible. 2 10 ...

FluentNhibernate Intermediary Table

If we consider this example But now quantity is a Value Object instead of a primitive type: public class LineItem { public Quantity Quantity { get; set; } public Product Product { get; set; } } instead of: public class LineItem { public int Quantity { get; set; } public Product Product { get; set; } } how could i map...

Problem with FluentNhbernate Mapping

Hi, I am new to all the OOP and ORM stuff, so i would appreciate your help... I have a Team Class: public class Team : IEntity<Team> { public virtual int ID { get; private set; } public virtual string Code{ get; private set; } public virtual TeamWorker TeamLeader { get; private set; } public virtual IEnumerable<TeamW...

Nhibernate: join tables and get single column from other table

Hi, I have the following tables: create table Users( Id uniqueidentifier primary key, InfoId uniqueidentifier not null unique, Password nvarchar(255) not null ) Create table UserInfo( Id uniqueidentifier primary key, Company nvarchar(255) not null, ContactPerson nvarchar(255) not null ) And InfoId is a foreign key referencing ...

Many to one mapping problem with NHibernate

Firstly I am relatively new to NHibernate. Got two tables on TaxMapping and Address. A single TaxMapping must have one address and one address can belong to more than one Tax Mapping. They are linked through foreign key TaxMapping hbm <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespa...

FluentNHibernate HasManyToMany Conditional Mappings

Is there a way that I filter out rows in a HasManyToMany mapping? I have three tables (legacy, not able to change them) Service, Resource and ResourceService. The ResourceService allows multiple resources to link to multiple services but it also has an "Active" column. On my Resource domain object I've mapped the services linked to the...

Fluent nHibernate Abstract class (non) Mapping problem

I have a base class, which has 2 derived class. Each derived class has a mapping file (they base class has non and it's abstract) Each derived class has an object that points to itself (which is defined in the base class); class Base { Base myManager; } class Derived1 : Base { } Class Derived2 : Base { } for each derived class ...

Receiving Index Out of Range with NHibernate

I'm hoping that someone can help me with this issue. I've been racking my brain and my project is due very soon. Thank You in advance. I'm receiving an index out of range exception when inserting a new record. After searching endlessly for information, it was suggested that the number of column values in my mapping do not match that in ...

NHibernate explicit fluent column mapping

I have a set of fluent object mappings that looks like this: public class UserMap : ClassMap<User> { public UserMap() { Map(x => x.Id); Map(x => x.Status); } } public class SpecialUserMap : SubClassMap<SpecialUser> { public SpecialUserMap() { Map(x => x.Property); } } public class Direct...

Using a Join and Component together in Fluent NHibernate Mapping throws "Could not find a getter for property exception"

Using a Join and Component together in Fluent NHibernate Mapping throws "Could not find a getter for property exception". This is my C# code using FluentNHibernate.Mapping; namespace FnhTest { public class CustomerMap : ClassMap<Customer> { public CustomerMap() { Id(x => x.Id).GeneratedBy.Identity(); ...

Implementing one-to-many mapping using NHibernate.Mapping.Attributes with composite keys

I've seen a few examples of how to write an hbm mapping file that has composite keys and implements a one-to-many relationship but I haven't seen a good example of how to do it with NHibernate.Mapping.Attributes. So, upon trying this 100 different ways I'm receiving an error: {"The element 'bag' in namespace 'urn:nhibernate-mapping-2.2'...

mapping article and category entity to my article_category table

So I have 2 entities: Article Category And I have a table that relates the articleID and categoryID: articles_categories -articleID -categoryID I am using xml for my mappings, what should I do here? I want to be able to query for all articles in a given category. ...

Nhibernate entity with multiple Many-To-Many lists of the same type?

Does anybody know how I would map an entity with two many-to-many collections of the same child type. My database structure is this.... The "normal" relationship will be.... tbl_Parent col_Parent_ID tbl_Parent_Child_Xref col_Parent_ID col_Child_ID tbl_Child col_Child_ID The alternative relationship is... tbl_Parent ...

Particular mapping on related tables

I have this domain problem: one table with this column "id,name,cubicleId" and another table with "id,date,name,numbers" the actual key to connect the two table is secondtable.name=firsttable.cubicle.name+"_"+firsttable.name actually the two tables are not related because my domain problem is "I want to get the single row with maximum ...