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

NHibernate ConventionModelMapper; What is the difference between IsRootEntity & IsEntity

I'm playing around with Sharp Architecture Lite, which emphasizes convention over configuration, and trying to understand how the NHibernate ConventionModelMapper works. Specifically, I can't tell the difference between the IsRootEntity & IsEntity…
6
votes
1 answer

How can I map to a joined subclass with a different column than the id of parent?

I am working with a brownfield database and am trying to configure a subclass map which joins to its subclasses with a column other than that of the specified id. The login table has a primary key column login_sk which I'd like to use as its id. It…
6
votes
2 answers

NHibernate - Union three QueryOvers

Hi StackOverflow users, I ran into this problem I have three QueryOvers and each of them returns a list of candidate ids that I then use to bring those candidates. For this I wrote the following code. private IQueryOver
Adi Nistor
  • 112
  • 1
  • 6
6
votes
1 answer

MVVM / NHibernate - How to do dynamic model validation?

I'm building a C# WPF application using the MVVM pattern. I have repository classes that use NHibernate to persist my domain model. My model consists of a larger tree structure (Recipes containing Operations containing Phases). Operations and phases…
kroimon
  • 2,062
  • 3
  • 19
  • 23
6
votes
1 answer

How do I do a String.IsNullOrEmpty() test in an NHibernate Queryover where clause?

I hit a situation today where a field in our legacy db that should never be empty... was empty. I am using NHibernate 3.2 against this database and the queries that are affected are written in QueryOver. My current query is this return Session …
NYCChris
  • 649
  • 5
  • 13
6
votes
1 answer

Should NHibernate clear distributed 2nd Level Cache on ISessionFactory.Dispose?

I'm working on a CacheProvider for Redis. I've stumbled upon something quite curious about the pre-built NHibernate Cache Providers. When in a distributed environment, I'd expect each web server to share the same NHibernate cache. Therefore, if one…
TheCloudlessSky
  • 18,608
  • 15
  • 75
  • 116
6
votes
5 answers

Partially Populate Child Collection with NHibernate

I've been struggling with this for a while, and can't seem to figure it out... I've got a BlogPost class, which has a collection of Comments, and each of the comments has a DatePosted field. What I need to do is query for a BlogPost and return it…
Chris Browne
6
votes
3 answers

How to filter IEnumerable based on an entity input parameter

I'm using now Entity framework- but it's a problem "shared" between all ORM's and even IEnumerable. Let's say I have a method in MVC looks like this: [HttpPost] public ActionResult Foo(FooModel model) { var context = new Context(); -- The EF…
gdoron
  • 147,333
  • 58
  • 291
  • 367
6
votes
2 answers

nhibernate deadlocks

I'm using the following code in an ASP.NET page to create a record, then count the records to make sure I haven't exceeded a set limit and rollback the transaction if I have. using (var session = NhibernateHelper.OpenSession()) using (var…
Chris
  • 27,596
  • 25
  • 124
  • 225
6
votes
4 answers

Linq, Expressions, NHibernate and Like comparison

I am trying to do a like comparison based on an outside parameter (passed by a search form) that determines type of comparison ("%string" or "string%" or "%string%") I was thinking in the following direction: query = query.Where( …
Miha Necak
6
votes
1 answer

NHibernate: SQL query results mapping

I have a problem with a SQL query results in NHibernate 3.1.0.4000 (I'm using MS SQL Server 2005 database). I have two tables: Adverts and Investments, which are mapped to entities: Advert and Investment. Adverts are connected with Investments via…
Sebastian
  • 3,764
  • 21
  • 28
6
votes
6 answers

NHibernate - AddEntity and AddJoin problem

I am using NHibernate with a SQL query to populate some entity objects. I have an Item object which references a User object (to indicate the owner of the Item) class Item { public User User; } My SQL query is (it's actually more complicated, which…
Mark Sherretta
  • 10,160
  • 4
  • 37
  • 42
6
votes
5 answers

nHibernate and SQL Server 2012 LocalDB

Is it possible to use LocalDB databases with NHibernate? If yes, what should be installed/configured? Currently when trying to use connection string like Data Source=(LocalDb)\v11.0;Initial Catalog=tst1;Integrated Security=SSPI when creating…
Shaddix
  • 5,901
  • 8
  • 45
  • 86
6
votes
1 answer

NHibernate Overcoming NotSupportedException

Does anyone know of any way to overcome NotSupportedException? I have a method against a User: public virtual bool IsAbove(User otherUser) { return HeirarchyString.StartsWith(otherUser.HeirarchyString); } And I want to…
Jordan Wallwork
  • 3,116
  • 2
  • 24
  • 49
6
votes
3 answers

Database Generated Date on Insert with NHibernate

I am a newbie with NHibernate, so please bear with me. Let's imagine, i have a property for CreatedDate, and i wanted it to be filled with the sql server datetime value. The possible solution that i found out is, to mark this property as…
Daniel Mahadi
  • 848
  • 1
  • 10
  • 14