Questions tagged [nhibernate]

NHibernate is an open source object-relational mapper (ORM) for the .NET framework.

NHibernate is an open source object-relational mapper (ORM) for the .NET framework.

It started as a .NET port of the popular Java ORM Hibernate.

Installation

Installing NHibernate can most easily be done using its NuGet package:

Install-Package NHibernate 

Resources

17517 questions
5
votes
1 answer

OneToOne mapping by code nhibernate 3.2

I'm trying to upgrade a project and use the build in code mapper. I have 2 entities: public class Person { public virtual int Id { get; set; } public virtual User User { get; set; } } public class User { public virtual int Id { get; set; } …
Bas
  • 678
  • 6
  • 10
5
votes
2 answers

How to add Filter definitions with Nhibernate 3.2 mapping by code?

The ModelInspector doesn't seem to provide the means to define Filter definitions . Any ideas/Workarounds? I need to generate the following with mappings by code:
Newbie
  • 7,031
  • 9
  • 60
  • 85
5
votes
2 answers

Fluent Nhibernate inner join

I have 3 tables (Master, Imagen, Linea) were: Master public virtual int Id { get; private set; } public virtual Imagen imagen { get; set; } Imagen public virtual int Id { get; private set; } public virtual Linea linea { get; set; } Linea public…
lloiacono
  • 4,714
  • 2
  • 30
  • 46
5
votes
3 answers

How to ignore mapping of property using mapping by code "Conventions"

Is there any way to avoid a property from being mapped with NHibernate 3.2 using mapping by code conventions? By default, all properties are mapped.
Newbie
  • 7,031
  • 9
  • 60
  • 85
5
votes
1 answer

NHibernate Table Per Class loading - wrong type

I have a mapping issue with the table-per-class hierarchy in Fluent/NHibernate. When retrieving the records from the database, I keep getting an error (the Wrong type exception) Object with id: 2445763 was not of the specified subclass: ClassA…
5
votes
1 answer

NHibernate TooManyRowsAffectedException while trying to delete multiple objects

Basically I'm getting this exception while trying to delete a collection of entities with nHibernate. Below is my code public void DeleteAll(IList entities) { using(var tx = session.BeginTransaction()) { try …
Duy
  • 1,332
  • 1
  • 10
  • 19
5
votes
2 answers

NHibernate Inherited Class but no need to persist

I have a class, Order, which I persist to a database using NHibernate. There is a folder futher down in the web application that contains an object that inherits from Order, for our purposes, we can call it CustomOrder. I use CustomOrder to place…
Josh
  • 10,352
  • 12
  • 58
  • 109
5
votes
1 answer

Using NHibernate and Mono.Data.SQLite

I read and implemented Trying to using Nhibernate with Mono & SQLite - can't find System.Data.SQLite However, as the last comment there states this seems not to work with NHibernate 3.1 The error is HibernateException: The IDbCommand and…
Nils
  • 9,682
  • 6
  • 46
  • 72
5
votes
2 answers

Proper Guid Mapping. Nhibernate

I use an abstract Entity class which contains a Guid: public abstract class Entity { public /*virtual*/ Guid Id { get; set; } } Suppose I also have a class like: public class Post : Entity { public String Title { get; set; } public…
lexeme
  • 2,915
  • 10
  • 60
  • 125
5
votes
2 answers

Invalid index N for this SqlParameterCollection with Count=N only when associated table has null record

I have a rather complex entity which will not save when a particular database table is missing a record. When the record exists the entity saves correctly. When the record does not I receive the exception: Invalid index N for this…
ahsteele
  • 26,243
  • 28
  • 134
  • 248
5
votes
3 answers

from domain model to transaction script

The new place I started at is just starting to develop a completely new product from scratch. They are going transaction script in application services, completely dumb entities, and a hand rolled DAL with stored procedures (the argument is that…
maciek
  • 661
  • 4
  • 10
5
votes
4 answers

How to enumerate column names with NHibernate?

I've got a class with a bunch of [ColumnName("foo")] NHibernate attributes. Is there an easy way to ask NHibernate to list all of the ColumnNames for a given class? It sounds like it should be really easy but I'm just not seeing any kind of…
Ken
  • 2,651
  • 3
  • 19
  • 17
5
votes
1 answer

Could not resolve property in QueryOver

I have a method by QueryOver in Nhibernate3.1 var q = SessionInstance.QueryOver(). Where(person=>person.PersonIdentity.FirstName.IsLike(firstName,MatchMode.Anywhere)); return q.List(); Now i have a runtime error by this…
Ehsan
  • 3,431
  • 8
  • 50
  • 70
5
votes
2 answers

prevent unnecessary cross joins in count query of generated sql code

I am using this query: return from oi in NHibernateSession.Current.Query() select new BlaViewModel { ... NoPublications = oi.Publications.Count(), ... }; BlaInteraction contains an IList of publications (i.e. entities). To…
cs0815
  • 16,751
  • 45
  • 136
  • 299
5
votes
3 answers

ADO.NET Entity Framework and NHibernate - when to use one over the other

I am working in a Microsoft .NET shop where it is okay to use NHibernate or ADO.NET EF. What guidance should we be using about when you should choose one over the other? For example, it seems like when writing a Silverlight app the EF -to-> ADO.NET…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466