Questions tagged [fluent-nhibernate-mapping]

Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents (.hbm.xml files), Fluent NHibernate lets you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Resources

626 questions
0
votes
1 answer

Fluid NHibernate, Custom Types and Id mapping

I have an object in C# that I want to use as a primary key in a database that auto-increments when new objects are added. The object is basically a wrapper of a ulong value that uses some bits of the value for additional hints. I want to store it…
0
votes
1 answer

Fluent NHibernate - Mapping tables which reference an ID from a lookup table

Supposed I have 4 tables defined as follows: Projects: [ Project_Id, Project_Name ] Vendors: [ Vendor_Id, Vendor_Name ] Project_Vendors: [ Project_Vendor_Id, Vendor_Id, Project_Id ] Payments: [ Payment_Id, Project_Vendor_Id, Payment_Amount ] The…
0
votes
1 answer

Fluent NHibernate - How to map to table which has reference to a lookup table

I have 4 tables defined below: Projects: Project_Id Project_Name Vendors: Vendor_Id Vendor_Name Project_Vendors: Project_Vendor_Id Project_Id Vendor_Id Project_Vendor_Payments: Payment_Id Project_Vendor_Id …
0
votes
1 answer

Fluent NHibernate - how to specify sequence name for Id with GeneratedBy.Native()

I use Fluent NHibernate and I need to use GeneratedBy.Native() for Id generation to support Oracle,DB2 and MSSQL databases. If I try to run it like this on Oracle and insert new record to the table I get: Could not execute query: select…
0
votes
3 answers

fluent nhibernate polymorphism. how to check for type of class

I have an Icon which has a Content (one to one) relationship. public class Icon { public virtual Content Content {get; set;} } By default, it is lazy loaded which is what I want. However, at some point in the code, I need to check what kind of…
0
votes
0 answers

Cannot Delete Entities with Multiple References

Morning All, I have a number of entities, Car and Van, each of them having a list of Driver. For example, public class Car : Entity { public virtual string Name { get; set; } public virtual IList Drivers { get; set; } } If add the…
Richard Tasker
  • 244
  • 2
  • 12
0
votes
1 answer

FluentNHibernate mapping to existing table without normalization

I have existing table in my db and need create a domain for it to work with existing data. I have next tables…
Akim Khalilov
  • 1,019
  • 4
  • 16
  • 31
0
votes
1 answer

Fetch Only the distinct records -Fluent Nhibernate Mapping

I have two tables Table A: Id | Attachment_id 1 | 123 Table B: Id | doc_name |Attachment_id | version 1 | sab.txt | 123 | 1 2 | sab.txt | 123 | 2 When i upload a file with same name and content it is saved with increasing…
0
votes
1 answer

FluentNHibernate - Map Foreign Key As Primary Key

Hi I'm trying to migrate a database to ORM, and found a problem. The database was created with the concept of inheritance, where there is a parent table and several child tables who inherit their properties. To facilitate querys with INNER JOIN, all…
Raphael Basso
  • 137
  • 1
  • 1
  • 6
0
votes
1 answer

Mapping to a different view based on child type

So i have a situation where i have common base type but i need to map to a different view based on the child type. It looks like i can use a generic mapping class to handle the…
Ryan Burnham
  • 2,619
  • 3
  • 27
  • 43
0
votes
1 answer

FluentNHibernate: Id Column Name Ignored

FluentNHibernate: 1.3.0.733 NHibernate: 3.3.1.4000 I'm trying to set the column name of the Id column, but it seems to be ignored. Edit: Found solution. Property redeclaration (new-modifier) was the problem (see answer). I'm using AutoMapping…
0
votes
1 answer

fluent mappings error with incorrect foreign key

My fluent mappings are: HasOne(x => x.User).ForeignKey("fOM_User_Id").Cascade.None(); My class is: public class OrganizationMember { public virtual int MemberId { get; set; } public virtual int…
Haroon
  • 3,402
  • 6
  • 43
  • 74
0
votes
1 answer

Many To Many Mapping with Attribute - Primary key is Foreign Keys

I am having trouble mapping my many to many with a attribute relationship. Much like the problem here fluent nhibernate - Many to Many mapping with attribute But I do not have a Primary Key on my middle class, instead it is made up of the IDs of…
Steve
  • 2,971
  • 7
  • 38
  • 63
0
votes
2 answers

How to map IDictionary?

How do I map Dictionaries with FluentNHibernate? IDictionary and.. IDictionary ? like: public class SomeClass { public int Id {get;set;} public IDictionary Dictionary2 {get;set;} public…
bretddog
  • 5,411
  • 11
  • 63
  • 111
0
votes
1 answer

Fluent NHibernate Self Reference Table With Composite Key

I just want to know if this is possible to do with fluent nhibernate. I got a self reference table in my database. Table Service { int Season (PK) (FK) int Service_No (PK) int ParentService_No (FK) } The table has a composite key as Season and…
user1494907
  • 77
  • 1
  • 1
  • 4