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

Fetching records by date with only day part comparison using nhibernate

I would like to fetch all records from particular day, no matter what time is associated with those records. So far I have method like this: public IQueryable QueryByDay(DateTime day) { DateTime from = day.Date; DateTime to =…
0lukasz0
  • 3,155
  • 1
  • 24
  • 40
6
votes
1 answer

How do I setup a ROWVERSION/TIMESTAMP datatype column using FluentMigrator?

I am trying to use the ROWVERSION (or TIMESTAMP) datatype on a SQL Server table for optimistic concurrency control. My table is setup using FluentMigrator and I do not know how to get the datatype I need. According to Microsoft's article on…
BueKoW
  • 926
  • 5
  • 18
  • 33
6
votes
2 answers

Domain Model with Nhibernate design issue

I´m trying to get started in the “DDD with C#” world. I use NHibernate as my ORM tool, thus trying to develop a PI(Persistence Ignorance) model. However, in some of my entities (which are being represented as POCOS) I have business rules in the…
6
votes
3 answers

GroupBy SqlFunction on QueryOver

I have a list of all distinct account name prefixes (a-z) which I acquire using var accounts = this.SessionManager.GetActiveSession().QueryOver(); var q = accounts.Select(Projections.Distinct( Projections.SqlFunction("substring", …
JConstantine
  • 3,980
  • 1
  • 33
  • 46
6
votes
2 answers

Nhibernate Projection over nested nested properties

I have domain class location public abstract class BaseEntity where T: struct { public virtual T Id { get; set; } public virtual bool Equals(BaseEntity other) } public class Location : BaseEntity { …
Techmaster
  • 1,032
  • 2
  • 12
  • 26
6
votes
4 answers

DevExpress XPO vs NHibernate vs Entity Framework: database upgrading issue

What is the best practice for upgrading the database using ORM (DevExpress XPO, NHibernate or MS Entity Framework)? I'm starting a new project and have to pick an ORM. The development process requires of releasing intermediate test builds quite…
Alex Klaus
  • 8,168
  • 8
  • 71
  • 87
6
votes
2 answers

NHibernate - Execute SQL to populate DTO

I have some instances for reporting where executing sprocs is easier and simpler than complicated QueryOver statements. I have a DTO, not an entity, that represents the data returned from the query and want to populate the results of the query into…
Samuel Goldenbaum
  • 18,391
  • 17
  • 66
  • 104
6
votes
1 answer

Duplicates when eager fetching a reference (many-to-one)

First of all, yes, I am using DistinctRootEntityResultTransformer. I have the following (Fluent NHibernate) mapping: public FirstObjectMap() { Id(x => x.Id): HasMany(x => x.SecondItems).KeyColumn("FirstObject_ID"); } public…
6
votes
3 answers

The type initializer for 'NHibernate.Cfg.Configuration' threw an exception

After upgrading from nhibernate 1.0.4.0 to nhibernate 3.3 im encountering the following error when I try to run "Configuration cfg = new Configuration();" System.TypeInitializationException was caught Message="The type initializer for…
ramya
  • 113
  • 2
  • 2
  • 7
6
votes
2 answers

NHibernate Identity fields

Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo algorithm?
user366312
  • 16,949
  • 65
  • 235
  • 452
6
votes
1 answer

Session.Transaction changes after Rollback (NHibernate)

I have the following code (simplified for the sake of discussion). What I don't understand is why the session.Transaction property returns a different transaction after a rollback. For instance, this means that the property…
Lars A. Brekken
  • 24,405
  • 3
  • 25
  • 27
6
votes
3 answers

NHibernate multi query / futures with Oracle

I am trying to use futures in NHibernate 3.2 and Oracle 11gR2. This doesn't seem to be supported although I'm not sure. I found this issue on NHibernate Jira that makes it seem like futures are possible with Oracle. Does anyone know how to get…
Alex
  • 9,250
  • 11
  • 70
  • 81
6
votes
2 answers

Nhibernate - Initialize lists - Best Practice?

I was just wondering about some CodeWarning (ConstructorsShouldNotCallBaseClassVirtualMethods), and if there is a better way to do it. I have a simple log collector class, and I am using NHibernate to retrieve some of the objects. Some times I…
Christian Ruppert
  • 3,749
  • 5
  • 47
  • 72
6
votes
3 answers

NHibernate's Increment Generator - could not fetch initial value

I'm trying to use NHibernate (and FluentNHibernate) over a legacy database. I'm also using SQLite for tests. When I try to create a test for the mappings using FluentNHibernate's PersistenceSpecification, I get the following…
caiokf
  • 344
  • 6
  • 14
5
votes
4 answers

Inserting a record with a Composite Key using NHibernate

I am working with a legacy database that uses composite keys. And I am trying to use NHibernate to insert a new record into the database. NHibernate specifies that I have to create the Id manually, but when I try to insert with this id I get the…
zonkflut
  • 2,929
  • 3
  • 22
  • 25