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

Nhibernate.Linq: Restricting query results with Where(Expression>)

I query my Database using NHibernate. Now I need to restrict the data being selected using a Predicate. So far I found out (Google driven development at its best) that something like this is possible using Expressions and NHibernate.Linq. Here's…
Sebastian Edelmeier
  • 4,095
  • 3
  • 39
  • 60
5
votes
1 answer

Fluent NHibernate: mapping a dictionary of lists

I have a DB with the following tables: Roles: [Id, Name, ...] Permissions: [Id, Name, ...] MetaDataDefinitions: [Id, Name, ...] RolePermissions: [Id, RoleId, PermissionId, MetaDataDefinitionId] POCO classes are: class Role { public Role() { …
5
votes
5 answers

NHibernate "null identifier" exception after inserting an entity

I'm having trouble saving an entity into an SQL Server 2005 database. I'm using NHibernate 2.0.0.3002 for my persistence layer. The mapping is typical, with an integer ID, as follows
gilles27
  • 2,221
  • 6
  • 23
  • 37
5
votes
3 answers

Why would I use the Unit of Work pattern on top of an NHibernate session?

When would I write a UoW implementation on top of what is already provided by NHibernate? Any real world examples?
ng5000
  • 12,330
  • 10
  • 51
  • 64
5
votes
2 answers

How to Delete in a many to many relationship?

I have a many to many relationship: Product has many Categories and Category has Many Products. Say I have Shopping Category Food Category Product A - Shopping Category, Food Category Product B - Shopping Category Now I delete Shopping…
5
votes
1 answer

How to use string keys in (fluent) NHibernate

I am working with brownfield database that uses strings as primary keys. Using Fluent NHibernate with Sqlite (in-memory provider for unit testing) and SQL Server 2005. I have the following entity: public class Entity { public virtual DateTime…
the_joric
  • 11,986
  • 6
  • 36
  • 57
5
votes
1 answer

Restriction on collection with disjunction using NHibernate QueryOver

Hi all NHibernate gurus ! Given these two classes : public class User { long Id; string Name; } public class Project { long Id; User Owner; IList Managers; ... } I would like to do a query using QueryOver (not using…
Chris
  • 61
  • 5
5
votes
1 answer

Quartz.NET, NH ISession & Ninject Scope

I'm trying to implement a service that will run jobs based on Quartz.Net. The jobs may have dependencies like IRepository<> and the repository implementation will have a NHibernate ISession injected into it. (Quartz will be hosted in a Windows…
Mike Rowley
  • 908
  • 9
  • 20
5
votes
2 answers

Creating a Linq expression dynamically containing a subquery

I recently stumpled upon the problem to dynamically create Linq expressions during runtime. Most examples I found deal with the rather simple task of just comparing one property of a given database entity with a single parameter. Like so: …
UnclePaul
  • 515
  • 5
  • 17
5
votes
1 answer

Querying unmapped properties in nhibernate

I am working with Linq-To-NHibernate. I need to use some properties that is not mapped to columns. For example Repository .Find() .Select(p => new PersonModel() { Id = p.Id, FullName= p.FullName,Position = p.Position }); The position…
user39880
5
votes
3 answers

Will nHibernate ShowSql have any effect on a live system?

I've configured nHibernate to output its SQL statements to the Visual Studio output window using the following configuration code: var configuration = Fluently.Configure(cfg) .Database( …
kasey
  • 553
  • 7
  • 21
5
votes
2 answers

Linq To Sql surprisingly fast retreving data. Is it normal that it is 10x faster than ADO?

I'm currently learning Linq to Sql and Im very surprised by the performance of selecting data. I'm retreving joined data from few tables. I select about 40k of rows. Mapping this data to objects using ADO times about 35s, using NHbiernate times…
Piotr Czarnecki
  • 1,688
  • 3
  • 14
  • 22
5
votes
3 answers

NHibernate - how to delete an item from many-to-many relationship?

I've following mapping for two tables having a Many-to-Many relationship between them. How do I delete an entry from the mapping table, which is 'ProjectUser' in my case? public ProjectMap() { Id(x => x.Id); Map(x => x.ProjectName); …
5
votes
2 answers

nhibernate Linq

I am using the old linq provider for nHibernate and waiting patiently for the new one to come out. I am sure it will save me much pain. Anyway, I have a problem with the code below as it generates a "Object reference not set to an instance of an…
Craig
  • 36,306
  • 34
  • 114
  • 197
5
votes
3 answers

How to make Nhibernate generate table with Text field instead of nvarchar(255)

I'm trying to make NHibernate generate my schema/SQL 2008, and using the mapping below it keeps wanting to create an nvarchar(255) column instead of text...any ideas?
Webjedi
  • 4,677
  • 7
  • 42
  • 59