nhibernate

Are there any gotchas when using Castle ActiveRecord/NHibernate with WCF?

The kind of flexibility that Activerecord gives to our DB design, we are looking at it for our DAL and build model around it. We will be creating a WCF service on top of all this. Are there any gotchas or compat issues when using NHibernate based Castle Activerecord? Specially when it comes to the DataContractSerializer that WCF uses. Si...

Fluent nHibernate Configuration

I am trying to configure fluent nHibernate and have this code Assembly mappingAssembly = Assembly.ReflectionOnlyLoadFrom("LibrarySample.Model.dll"); sessionFactory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005 .ConnectionString(c => c .FromAppSetting("ConnectionString")) .ShowSql()) .Mappings(m => ...

Audit Logging Strategies

I am trying to decide on the best method for audit logging within my application. The main reason for the log is reporting the sequence of events (changes). I have a hierarchy of Objects, I need to create reports when something changes on any part of that hierarchy, at a latter date. I think that I have three options: Have a log for...

linq (to nhibernate) where clause on dynamic property in sql

My entity has a property which is derived from other properties public class MyClass { public DateTime Deadline { get; set; } public Severity Severity { return (DateTime.Now - Deadline < new TimeSpan(5, 0, 0, 0)) ? Severity.High : Severity.Low; } } is there a way I can modify the following return repository.Q...

Is it possible to avoid NHibernate.ObjectNotFoundException when there is a foreign key but the referenced row does not exist??

I am using NHibernate to pull some data out of a legacy db, and I have found several cases where there is a foreign key, but the referenced row has been removed. When I make my NHibernate mapping (using Fluent NHibernate like so: References(d => d.Group) .WithColumns("groupId", "dataset") .SetAttribute("lazy", "true"); ) I ge...

Problem with mapping in NHibernate

I've the following class: public class Customer { public virtual int CustomerID { get; protected set; } public virtual string AccountNumber { get; protected set; } public virtual string CustomerType { get; set; } public virtual int TerritoryID { get; set; } public virtual SalesTerritory Territory { get; protected set...

In Memory Database

I'm using SqlServer to drive a WPF application, I'm currently using NHibernate and pre-read all the data so it's cached for performance reasons. That works for a single client app, but I was wondering if there's an in memory database that I could use so I can share the information across multiple apps on the same machine. Ideally this wo...

Linq to NHibernate

I have been looking around for some example projects or tutorials on Linq to Nhibernate. Does anyone know of any good ones? ...

What is the best .NET web development framework?

I'm looking for a framework to simplify the creation of a website with social networking features and plenty of custom functionality. I'm quite keen to use an ORM like nHibernate or similar for data access. Would DotNetNuke be a good choice? Or are there other options which are better. Added: I'm quite keen not to have to reinvent the...

Memory leak when using time in NHibernate SQL query

I use NHibernate in my ASP.NET application to connect to an MS SQL Server 2005 database. In some cases I need to write my own SQL queries. However, I noticed that the SQL server thread leaks about 50 KB of memory every time I execute the following piece of code: NHibernate.ISession session = NHibernateSessionManager.Instance.GetSession(...

How to configure fluent nHibernate with MySQL

I'm trying to configure nHibernate to use a MySql database. I found examples for mssql and sqlite but none for mysql. So, how do I change this so it uses mysql: Fluently.Configure().Database( MsSqlConfiguration.MsSql2005.ConnectionString( c => c.FromConnectionStringWithKey("ConnectionString") ) ) .Map...

Data Auditing in NHibernate using events

I'm revisiting and re-implementing the code that caused me to ask this question about data auditing in NHibernate. However this time, I want go with Sean Carpenter's suggestion and implement the ISaveOrUpdateEventListener (new in NHibernate 2.x) I want to add a row in a database for each change to each property with the old value and t...

Nhibernate - query with join table without relationship

Hi all: I was wondering if anyone has tried to do this in NHibernate. I have the following tables (simpify version). CITY: city (varchar2) (PK) province (varchar2) (PK) CITY_TL: city (varchar2) (PK) province (varchar2) (PK) lang (char (2)) (PK) LOCATION: location (varchar2) (PK) some other column. As you can see, there are no relat...

NHibernate logs and executes a query twice in a row

I am using: NHibernate, NHibernate.Linq and Fluent NHibernate on SQL Server Express 2008. I am selecting an entity using a predicate on a referenced property (many-one mapping). I have fetch=join, unique=true, lazy-load=false. I enabled the log4net log and when any such query executes it logs two identical SQL queries. Running the query ...

Fluent NHibernate objectified relationship mapping

Hi there! Looking for an answer on how to configure NHibernate to support my scenario, an many-to-many map with an objectified relation. I have a colection of Person:s with relations to other Person:s. Each of the relations have an attribute specifying what type of relation they have. In an RDB this is done by using a many-to-many tabl...

strange linq to nhibernate issue, Invalid cast from 'System.Int32'

Calling Get in the following code works fine: public class ContractService : IContractService { private readonly IRepository<Contract> repository; public ContractService(IRepository<Contract> repository) { this.repository = repository; } public Contract Get(int contractId) { return repository.Query()....

NHibernate thread safety with session

I've been using NHibernate for a while now and have found from time to time that if I try to request two pages simultaniously (or as close as I can) it will occasionally error. So I assumed that it was because my Session management was not thread safe. I thought it was my class so I tried to use a different method from this blog post h...

Dealing with constraint violations from the DB in NHibernate

I have what I think is a rather common use case for NHibernate. I create an entity and try to save it using ISession.Save() followed by a Transaction.Commit(). At this point, I expect violations of things like unique/primary key constraints to come up to me as exceptions. What I'm seeing, however, is just a GenericADOException. This does...

Is it possible to use Rhino.Commons.HttpModules.UnitOfWorkApplication in ASP.NET 3.5 (not MVC)?

I tried to find tutorials/articles on using UnitOfWorkApplication in ASP.NET (not MVC). But all information I can find is about how to use it in ASP.NET MVC. Does it mean that it is not possible to use Rhino.Commons.HttpModules.UnitOfWorkApplication in our old webform applications? I run into the problem that I am using repository inh...

NHibernate - is there any point in setting length attribute for properties/columns?

typically definition of property/column looks like this: <property name="DocumentSummary" column="DocumentSummary" length="100" type="String"> <column name="DocumentSummary" /> </property> I was assuming that NHibernate will validate data using length attribute before inserting/updating a row. Unfortunately it seems to be invalid a...