nhibernate

Connection nHibernate to Oracle Issues

I am trying to connect to an Oracle Database using nHibernate. I can connect using the .Net driver: <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property> However I would prefer to use the OracleDataClientDriver that ships with Oracle (or nHibernate? I forget). Anyway I was using the instructions ...

Nhibernate and Lotus Notes via ODBC

I have to import data from a Lotus Notes database via ODBC. The source data are all varchar fields while some columns actually contain dates and numbers. I mapped those colums with NHibernate to the appropriate types which works for loading but not for comparing (using criteria, e.g. Restrictions.Eq("StoreId", 123)). Whenever I execute ...

NHibernate context sessions, ASP.NET & threading hodgepodge

NHibernate.Context.WebSessionContext, otherwise known as web session context, plays nicely with ASP.NET, but only up to a point. As soon as I spin up a new thread, it is no longer able to retrieve current session from a HttpContext since there's actually no HttpContext for the said thread. How do you make all this play nicely together? ...

When to commit NHibernate transactions in ASP.NET MVC 2 application?

First, some background: I'm new to ASP.NET MVC 2 and NHibernate. I'm starting my first application and I want to use NHibernate, because I come from JSP + Struts 1 + Hibernate web applications. No one seems to be talking about this, so I guess it must be pretty obvious. Still I scratch my head because I can't find a solution that accomp...

How do I use NHibernate criteria queries to load associations based on additional conditions

Let's say I have a Cat that has two properties: FavoriteKitten SecondFavoriteKitten These kittens are discriminated by their Rank. When loading a Cat, I want the kitten with the rank of "1" to be FavoriteKitten, and the kitten with the rank of "2" to be SecondFavoriteKitten. The underlying database looks like: table Cat ----------...

Looking for guidance on embedded .NET database (such as db4o, NHibernate, or RavenDB)

I have an object model that I want to store using an embedded database. I have so far been looking at db4o, NHibernate to SQLCE (w/ linq), and RavenDB. This would be used in a desktop C# application. The key features I am looking to leverage are: Linq or similar for queries (no SQL or HQL), Embedded data engine, pocos, poco first model,...

NHibernate Linq - how to create a where statement with IS NOT NULL

hi, how can i achieve this query with Nhibernate Linq? var l = session.CreateQuery("from Auswahl a where a.Returnkey is not null").List<Auswahl>(); i tried this but it always returns an empty list. var l = session.Linq<Auswahl>() .Where(item => !String.IsNullOrEmpty(item.Returnkey)) .Select(item ...

How get correct Exception from ADO.NET about foreign key violation

I would like to get correct Exception from ADO.NET about foreign key violation. Is there a way to do that? I am using try to catch ADO.Exception and check it message text for 'foreign'. So, if there is 'foreign' text in exception text, it is a violation and I can alert. Is it the right way to do or any other method? try{ base.De...

nhibernate 2.0 Efficient Data Paging DataList Control and ObjectDataSource

Hi How would I do what Scott has done in one call using nHibernate 2 ObjectDataSource http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx below is my Data access method public IList GetListOfUser(int rows, int pageIndex) { IList userList = null; using (ITransaction tx = _session.BeginTransaction(...

NHibernate - Delete Not Peristing in the Database

Hi, i'm trying to remove an item from a one to many list and have it persist in the database. Here are the entities i have defined: public class SpecialOffer { public virtual int SpecialOfferID { get; set; } public virtual string Title { get; set; } public virtual IList<SpecialOfferType> Types { get; private set; } pub...

nHibernate and Oracle Mapping Issue

I am using nHibernate with Oracle, using Oracle's ODP implementation. http://tiredblogger.wordpress.com/2008/11/07/using-oracle-odp-with-nhibernate-from-a-c-class-library/ This is pretty much working but then I got this error: Unable to cast object of type 'Oracle.DataAccess.Client.OracleConnection' to type 'System.Data.Common.DbCon...

Creating entities from stored procedures which have dynamic sql

I have a stored procedure which uses a couple of tables and creates a cross-tab result set. For creating the cross-tab result set I am using CASE statements which are dynamically generated on basis of records in a table. Is it possible to generate an entity from this SP using ADO.NET Entity framework? Cuz each time I try Get Column Info...

How to use NHibernate with asp.net 3.5

Hi, I want to use NHibernate with Asp.net 3.5 but i don't know how to use it.I search on Google but couldn't find the complete explanation about why to use NHibernate,Advantages of using it and integration with Asp.net projects.Please Help me. ...

Session Per ViewModel in Desktop Application with Repository

I have been writing a WPF DESKTOP application using NHibernate, WPF, Prism and Unity Container but have a problem in terms of Session Management in Services / Repositories and how to do it cleanly through dependency injection using Unity. Having read Building A Desktop To Do-Application With NHibernate I now have a Session Per ViewModel...

Add SQL query options to NHibernate query

I'm working with some code that generates ICriteria queries for NHibernate. They get executed using ActiveRecord and ActiveRecordMediator.FindAll() For certain queries, I need to optimise them by adding on an OPTION (HASH JOIN) hint at the end of the SELECT statement. Is there a quick way I can do this? I don't want to rewrite the qu...

I cannot figure out what I'm doing wrong with this basic NHibernate query...

Okay, I have a class, Company public class Company { public virtual int Id { get; set; } public virtual IList<Role> Roles { get; set; } } And another class, Role public class Role { public virtual int Id { get; set; } public virtual Company Company { get; set; } public virtual RoleLevel RoleLevel { get; set; } } ...

Preventing NHibernate foreign key creation for <any> mapping

Is there a way from preventing SchemaExport from generating a foreign key constraint on mapping type? I saw a similar question about mapping, but unfortunately that wont do for . I couldn't find answer to this in NHibernate reference, but maybe someone knows a trick? I'd like to avoid removing constraint afterwards. ...

SQL to NHibernate Criteria Query

Hi, I'm using Sharp Architecture for an MVC application and I'm trying to generate a nhibernate criterion query for the following SQL: select top 10 p.* from Tab1 p join Tab2 v on p.Id = v.Tab1Fk join Tab3 sbu on v.Id = sbu.Tab2Fk where sbu.DateTime >= 12/12/2002 00:00:00 ...

NHibernate Session Management w/ Ninject

Is this really all that I have to do to achieve session per request with Ninject? public class WebModule : NinjectModule { public override void Load() { Bind<ISession>().ToMethod(x => MvcApplication.SessionFactory.OpenSession()).InRequestScope(); } } Global.asax: public class MvcApplication...

A different object with same identifier was already associated with the session error

Scenario: I have a customer object with lazy loading enabled. I use that throughout the program to call a list of customer for a listbox. It has relationships to the Division_Customer_Rel, Division_Email_Rel and Email_Address objects. All off the relationships have Lazy = true, Cascade = ManyRelationCascadeEnum.AllDeleteOrphan, Inverse =...