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
6
votes
3 answers

NHibernate Linq in read-only mode

Is it possible to set read-only mode on entities that are loaded using NHibernate's Linq provider? For example, the following can be done with Session.QueryOver (and I believe with Criteria as well): Session.QueryOver(Of Foo)().ReadOnly() Is there…
DanP
  • 6,310
  • 4
  • 40
  • 68
6
votes
2 answers

Prevent NHibernate mapping property to a proxy

I am searching around for a solution to my problem but all I get is the reasons this does happen as opposed to preventing if from happening. I have a class, WorkflowActivityInstance which has a collection of WorkflowActivityInstanceTransitions which…
Program.X
  • 7,250
  • 12
  • 49
  • 83
6
votes
3 answers

Join between two non-key fields

I'm working on putting together a simple POC app using Fluent NHibernate to attempt to show that it can do everything our current hand-rolled data access tool and so much more. One of the fringe cases that my boss is worried about is the ability to…
Hamman359
  • 1,052
  • 2
  • 14
  • 27
6
votes
1 answer

Automapping inheritance with Fluent nhibernate

I have this situation: public namespace ANamespace { public abstract class ABase:IABase { //properties } public abstract class A : ABase { //properties } public class A1 : A { //properties …
Athina
  • 533
  • 5
  • 20
6
votes
3 answers

NHibernate mapping an entity without a primary key

My Entity has no primary key for some reasons: public partial class VehicleLocation { public virtual string UserCode { get; set; } public virtual string DateTime { get; set; } public virtual string Device { get; set; } public virtual…
Stacked
  • 6,892
  • 7
  • 57
  • 73
6
votes
6 answers

Nhibernate QueryOver don't get latest database changes

I am trying get a record updated from database with QueryOver. My code initially creates an entity and saves in database, then the same record is updated on database externally( from other program, manually or the same program running in other…
Carlos
  • 456
  • 2
  • 7
  • 21
6
votes
1 answer

Caching SessionFactory and Configuration for multiple databases with NHibernate

Some questions here in StackOverflow about NHibernate and multiple databases (dynamically connected), address me to believe that the best solution would be to keep a cache of SessionFactory (per database) and a cache to Configuration, to build…
Luciano
  • 2,695
  • 6
  • 38
  • 53
6
votes
4 answers

Validation Block vs Nhibernate.Validator

I am looking for validation framework and while I am already using NHibernate I am thinking of using NHibernate.validator from contrib project however I also look at MS Validation Block which seem to be robust but i am not yet get into detail of…
c.sokun
  • 1,622
  • 4
  • 25
  • 40
6
votes
3 answers

Select all rows with distinct column value using LINQ

I have a database with 4 fields that looks something like this: ID DeviceId Location Date 1 A ... 2 2 A ... 1 3 B ... 2 For each…
dansv130
  • 317
  • 1
  • 3
  • 12
6
votes
1 answer

Select n+1 problem

Foo has Title. Bar references Foo. I have a collection with Bars. I need a collection with Foo.Title. If i have 10 bars in collection, i'll call db 10 times. bars.Select(x=>x.Foo.Title) At the moment this (using NHibernate Linq and i don't want…
6
votes
2 answers

How to integrate NHibernate with Lucene.Net

This is getting quite annoying. Trying to integrate Lucene.Net search with NHibernate and i found only some information from year 07. Is there a nice up to date tutorial for this? Where to start, what to download etc.? Is there a way how to set…
Arnis Lapsa
  • 45,880
  • 29
  • 115
  • 195
6
votes
1 answer

How to set the timeout on a NHibernate transaction

I need a lot of DB processing done in a single transaction, including some processing using NHibernate. To make everything work in the same transaction, I'm using NHibernate's Session to start it, and enlist the the commands for the other work in…
k.c.
  • 1,755
  • 1
  • 29
  • 53
6
votes
1 answer

NHibernate mapping for SQL Server 2008 Hierarchy Data Type

Just wondering what the best mapping pattern is for NHibernate (latest release) with SQL Server 2008 and the hierarchy data type. Thanks
merbla
  • 537
  • 6
  • 14
6
votes
3 answers

Fluent NHibernate does not create IN part of WHERE clause

I have Fluent NHibernate Linq queries where I check values based on run time arrays. A basic example would be something like: var array = [1,2,3,4,5,6]; using (var session = SessionProvider.SessionFactory.OpenSession()) { return…
BlackSpy
  • 5,563
  • 5
  • 29
  • 38
6
votes
3 answers

"Session is Closed!" - NHibernate

This is in a web application environment: An initial request is able to successfully complete, however any additional requests return a "Session is Closed" response from the NHibernate framework. I'm using a HttpModule approach with the following…
Alexis Abril
  • 6,389
  • 6
  • 33
  • 53