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
2
votes
1 answer

Using fluent NHibernate to map a read only sql view

I am trying to get Fluent Nhibernate to Automap read-only views that do not have a primary or composite key specified. It seems like it is possible as the API document for ClassMap exposes a default constructor for…
2
votes
1 answer

How to implement .ChildWhere() mapping with many-to-many relation in NH 3.2

I have following FNH mapping: public class ItemMap : ClassMap { public ItemMap () { this.HasManyToMany(a => a.ChildItems).ChildWhere("IsDeleted = 0").AsSet(); } } Result hbm file is:
2
votes
1 answer

Fluent Nhibernate mapping to join by two non primary key columns

I was wondering is there a way to join two tables with two non primary key columns without creating a view? I have a table called 'Make' with columns of 'Name' and 'Year' that I want to join with another table called 'Style' with columns 'MakeName'…
2
votes
2 answers

Issue with basic relationships in Fluent NHibernate C#

I cannot find an example on this. I'm trying to get a basic understanding of Fluent NHibernate but resources seem quite scarce in terms of proper tutorials. I have a test class like this: public class User { public virtual long ID { get; set; } …
chemicalNova
  • 831
  • 5
  • 12
2
votes
1 answer

Invalid index 1 for this SqlParameterCollection with Count=1

What I have noticed is that the in Ncv the Report field that i am referencing is not generated. Below is the error I am receiving. Here is what my domain looks like and the error i receive is Invalid index 1 for this SqlParameterCollection with…
2
votes
1 answer

Custom Fluent NHibernate maps not working with AutoMapping

I'm having an issue with Fluent NHibernate AutoPersistenceModelGenerator. It doesn't want to pick up custom maps. Using Sharp Architecture 2.0, Fluent NHibernate 1.2 and NHibernate 3.1. My current relevant configuration is as follows: public…
2
votes
2 answers

composite Key and inheritance

i have the following classes and mappings abstract class BaseClass { public virtual int Keypart1 { get; set; } public virtual int Keypart2 { get; set; } // overridden Equals() and GetHashCode() } class InheritingClass :…
2
votes
0 answers

Are there examples of SPROC mappings and usage with Fluent NHibernate?

I'm looking for an example of how I would/should use the SqlUpdate, SqlDelete, and SqlInsert parts of Fluent NHibernate in my mappings. I have a standard public class MyObjectMap : ClassMap { public MyObjectMap() { …
2
votes
1 answer

Fluent NHibernate: how to map the where clause filter on a ManyToMany

I'm having an issue with persisting a field which is in my were clause on a ManyToMany releationship, but doesn't explicityly exist on the class mapping. Hard to explain but its the "is_expred" field in the below classes and mappings. I have the…
2
votes
0 answers

fluent nhibernate map hasmany using propertyref without fetch.join

I am using Nhibernate 3.2, along with a build of FluentNhibernate compatible with NH 3.2 and I have come to map a legacy part of my system. I believe it is possible to do what I require, but need some assistance in mapping it correctly. I have a…
Mark H
  • 707
  • 1
  • 11
  • 21
2
votes
1 answer

Fluent Nhibernate, Struggling With One-to-many Relationships

The follow exception is always be throwed: could not initialize a collection: [FatorM.Sieq.Model.Entities.Culto.Ofertas#4][SQL: SELECT ofertas0_.Culto_Id as Culto3_1_, ofertas0_.Id as Id1_, ofertas0_.Id as Id9_0_, ofertas0_1_.Anonimo as…
2
votes
1 answer

Insert nested object via JSON using web api with NHibernate

I'm writing an application that consist of a ReadAPI and a WriteAPI. The read API contains the domain classes, and uses EF CORE code first to generate the SQL DB, and to read from it. The write API uses NHibernate to write to the database that is…
2
votes
1 answer

NHibernate JOIN mapping fails when the mapped field is moved to a base class

Having two model classes with many common fields, I decided to create a base class and both of them to inherit from it. The existent model classes already came with map classes. All the common fields which are now inherited in the child classes…
2
votes
2 answers

Exception on mapping On-To-Many in one table. Could not find property nor field X in class Y

I try to create a tree in single table using Fluent Nhibernate. Table must look like this: Model class: public class Category { public virtual int CategoryId { get; set; } public virtual string CategoryName { get; set; } public virtual…
user6408649
  • 1,227
  • 3
  • 16
  • 40
2
votes
1 answer

Is it possible to use NHibernate with just Dataset in c#

Sorry, if this is silly question. Is it possible to use NHibernate with just Dataset in c#? I mean I don't intend to have any database but will update my other application upon events triggered over datatables or datarows. I want to have hibernate…