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

nHibernate, No row with the given identifier exists

I have a mapping along the lines of this.
Craig
  • 36,306
  • 34
  • 114
  • 197
51
votes
4 answers

How to get a distinct result with nHibernate and QueryOver API?

I have this Repository method public IList ListMessagesBy(string text, IList tags, int pageIndex, out int count, out int pageSize) { pageSize = 10; var likeString = string.Format("%{0}%", text); var…
Anders
  • 17,306
  • 10
  • 76
  • 144
51
votes
3 answers

queryover and (x like 'a' or y like 'a')

Hi Is there any elegant way of combining 'like' and 'or' when i'm using queryover API? for 'like' there is something like: query.WhereRestrictionOn(x=>x.Code).IsLike(codePart) for 'or' i can do something like: query.Where( x=>x.Code == codePart…
buddy
  • 725
  • 1
  • 6
  • 9
50
votes
4 answers

Using MiniProfiler's database profiling with NHibernate

What's the simplest way to use MiniProfiler's database profiling with NHibernate? In order for the profiler to work, I need to wrap the DbConnection that NHibernate uses in a ProfiledDbConnection. I'm not too familiar with the internals of…
Brant Bobby
  • 14,956
  • 14
  • 78
  • 115
50
votes
2 answers

DTO naming conventions , modeling and inheritance

We are building a web app using AngularJS , C# , ASP.Net Web API and Fluent NHibernate. We have decided to use DTOs to transfer data to the presentation layer ( angular views). I had a few doubts regarding the general structuring and naming of…
Sennin
  • 1,001
  • 2
  • 10
  • 17
46
votes
4 answers

What is NHibernate?

As a followup to my previous question. I am an ASP.NET Programmer, and am wondering how NHibernate would help me get my job done easier and more quickly than it would otherwise. Pretend I know nothing about NHibernate. What is it, and what can it…
Meetu Choudhary
  • 1,373
  • 4
  • 14
  • 26
46
votes
2 answers

Criteria.DISTINCT_ROOT_ENTITY vs Projections.distinct

I am pretty new to Hibernate. I found out that we can get distinct result using following two different ways. Could any one tell me what is the difference between them? When to use one over…
user3123690
  • 1,053
  • 5
  • 17
  • 27
46
votes
8 answers

What exactly is "persistence ignorance"?

Persistence ignorance is typically defined as the ability to persist & retrieve standard .NET objects (or POCOs if you really insist on giving them a name). And a seemingly well accepted definition of a standard .NET object is: "...ordinary classes…
Greg Beech
  • 133,383
  • 43
  • 204
  • 250
45
votes
4 answers

Linq for NHibernate and fetch mode of eager loading

Is there a way to set the fetchmode to eager for more than one object using linq for nhibernate. There seems to be an expand method which only allows me to set one object. However I need to set it for more than one object. Is this possible? Thanks
NabilS
  • 1,421
  • 1
  • 19
  • 31
44
votes
4 answers

Tradeoffs using NHibernate 3.0 QueryOver or LINQ provider

I have not found a clear comparison of what is supported with the NHibernate 3.0 LINQ Provider compared to using the QueryOver syntax. From the surface, it seems like two large efforts into two very similar things. What are the key trade offs to…
dotjosh
  • 615
  • 7
  • 11
44
votes
1 answer

Fluent NHibernate: How to create one-to-many bidirectional mapping?

Basic question: How to I create a bidirectional one-to-many map in Fluent NHibernate? Details: I have a parent object with many children. In my case, it is meaningless for the child to not have a parent, so in the database, I would like the foreign…
Nathan
  • 10,593
  • 10
  • 63
  • 87
43
votes
10 answers

How do I view the SQL that is generated by nHibernate?

How do I view the SQL that is generated by nHibernate? version 1.2
Larry Foulkrod
  • 2,254
  • 3
  • 23
  • 25
42
votes
5 answers

What should be the lifetime of an NHibernate session?

I'm new to NHibernate, and have seen some issues when closing sessions prematurely. I've solved this temporarily by reusing sessions instead of opening a session per transaction. However, I was under the impression that opening sessions each time…
stiank81
  • 25,418
  • 43
  • 131
  • 202
41
votes
5 answers

The length of the string value exceeds the length configured in the mapping/parameter

I am trying to insert some very long text into a string prop - it worked perfectly fine with LinqToSql, now I have switched over to NHibernate and want to save the same entity, but nHibernate throws the above exception. How can I fix…
Haroon
  • 3,402
  • 6
  • 43
  • 74
40
votes
1 answer

How can I recreate this complex SQL Query using NHibernate QueryOver?

Imagine the following (simplified) database layout: We have many "holiday" records that relate to going to a particular Accommodation on a certain date etc. I would like to pull from the database the "best" holiday going to each accommodation (i.e.…
Chris Haines
  • 6,445
  • 5
  • 49
  • 62