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

Enum Type mismatch in Fluent NHibernate (ASP.NET MVC)

Table Model: public class UserOwnerShip { public virtual int Id { get; set; } public virtual User User { get; set; } public virtual City City { get; set; } public virtual Company Company { get; set; } public virtual UserRole…
gandil
  • 5,398
  • 5
  • 24
  • 46
6
votes
1 answer

NHibernate - Query misses the query cache after saving a new entity

I have NHibernate (with NHibernate.Linq and Fluent NHibernate) set up with query caching. Everything works fine until I do a session.Save(new Widget()) (i.e. SQL INSERT). After that point, all queries on that type Widget miss the query cache.…
Joel Verhagen
  • 5,110
  • 4
  • 38
  • 47
6
votes
1 answer

How to use validate nested objects automatically

Say there is a class A that has a reference to class B like this class A { [NotNull] string Alpha; B bObject; } class B { [NotNull] string Beta; } A a = new A(); a.Alpha = "test" a.bObject = new b(); a.bObject.Beta = null; Now…
getit
  • 623
  • 2
  • 8
  • 30
6
votes
4 answers

What ORM can I use for Access 2007 - 2010? I'm after WPF binding to the tables etc

I've a legacy database that all sites have, it describes specific content in a number of catagory/subcatagory/child item format. Until now, adding/editing the content is either manual work in the tables OR raw sql Windows Forms tool (I built when I…
6
votes
2 answers

NHibernate: IUserType not working

I have this class that implements IUserType: public class StringToIntType : IUserType { /// /// mutable object = an object whose state CAN be modified after it is created /// public bool…
cdbeelala89
  • 2,066
  • 3
  • 28
  • 39
6
votes
1 answer

With NHibernate and Transaction do I rollback on commit failure or does it auto rollback on single commit?

I've built the following Dispose method for my Unit Of Work which essentially wraps the active NH session & transaction (transaction set as variable after opening session as to not be replaced if NH session gets new transaction after error) public…
user53791
6
votes
1 answer

Fluent NHibernate mapping nullable enum

I need to map a nullable enum in my class but am getting exceptions. NHibernate.PropertyAccessException: Invalid Cast (check your mapping for property type mismatches); setter of App.Model.Stock ---> System.InvalidCastException: Specified cast is…
bunggo
  • 330
  • 3
  • 13
6
votes
1 answer

How to preserve the columns order when using nHibernate's CreateSQLQuery?

Context I'm creating a web application and one of its features is to allow DB queries via UI. For persistance it uses nHibernate ORM. Below is the repository method which handles the incoming SQL queries: public IList ExecuteSqlQuery(string…
Florin D. Preda
  • 1,358
  • 1
  • 11
  • 25
6
votes
1 answer

NHibernate 2.1: LEFT JOIN on SubQuery with Alias (ICriteria)

I am basically trying to create this query with NHibernate ICriteria interface: SomeTable 1:n AnotherTable SomeTable has columns: PrimaryKey, NonAggregateColumn AnotherTable has columns: PrimaryKey, ForeignKey, AnotherNonAggregate,…
Raif Atef
  • 2,878
  • 1
  • 25
  • 31
6
votes
1 answer

The factory was disposed and can no longer be used. NHibernatefacility

I have been trying for three days to figure out this NHibernatefacility thing with Castle and wcf and it's really getting frustrating. After solving a good dozen of errors, i have come to this one which seems pretty obvious but i can't solve. This…
Pepito Fernandez
  • 2,352
  • 6
  • 32
  • 47
6
votes
1 answer

dll versions displayed in visual studio .Net not reflecting the referenced dll file/product versions

I have a console app c# project that depends on NHibernate 3.3.2 and ShapArch.NHibernate 2.0.4.628 which has been compiled with NHibernate 3.3.1 (as far as I know - I might be wrong, but when I created a 2.0.4 SharpArch project it downloaded NH…
boggy
  • 3,674
  • 3
  • 33
  • 56
6
votes
2 answers

Mapping a foreign key to something other than a primary key

In my database there are tables Assignment and Workplace, conceptually, every assignment takes place at exactly one workplace. The Assignment table contains a column Workplace, which is a foreign key referencing the Workplace table's WorkplaceName…
waldrumpus
  • 2,540
  • 18
  • 44
6
votes
2 answers

Could not create the driver from NHibernate.Driver.NpgsqlDriver

I've inherited a C#/NHibernate/MS SQL Server project and am new to NHibernate. One of the first tasks given to me was to migrate the database from MS SQL Server (2008 R2) to Postgresql 9.2. I'm using the Npgsql 2.0.12 (.net 2.0 version). The…
Woolly
  • 151
  • 1
  • 4
6
votes
1 answer

Nhibernate - Mapping List doesn't update List indexes

I'm having one self-referencing class. A child has a reference to its parent and a parent has a list of children. Since the list of children is ordered, I'm trying to map the relation using NHibernate's . This is my mapping:
Thomas Lundström
  • 1,589
  • 1
  • 13
  • 18
6
votes
3 answers

Checking existence of lazy loaded child without getting/loading in Fluent NHibernate

This should be easy, but I can't seem to figure it out... How can I check if a child on an entity exists without actually getting or fetching it? The child is lazy loaded right now.. so I have two entities: class A { public virtual int Id {…
Justin
  • 1,070
  • 2
  • 12
  • 16