nhibernate

NHibernate - different behaviour in application and unit test

Code public void SaveProduct(Product product) { using (var session = GetNewSession()) { using(var tran = session.BeginTransaction()) { session.SaveOrUpdate(product); tran.Commit(); } } } Product is an entity with parent/child relati...

Create an instance of ISession per ViewModel

Hello all, here is my problem: I'm building a desktop application, with the following tools: Caliburn Ninject NHibernate All my view models and repositories are instanciated with Ninject. My repositories all need an ISession in their constructor. I'd like to follow ayende's advice concerning the ViewModels: each ViewModel opens a n...

add reference to Silverlight project from other non silverlight project

I have Silverlight application using NHibernate as a ORM. I have projects for Data(mapp and entities), data access and Silverlight. I want to add to SL project reference to data access to execute methods, but SL can only get reference from other SL project. How can I omit it? If I host data access project on WCF I could reference WCF to...

NHibernate View Mapping Question

Consider an application consisting of Employees and Administrators. An employee consists of an EmployeeId, Name and EmailAddress. The employees are stored in a legacy system and are readonly so I have an immutable Employee class mapped to a view (vw_Employee) as follows: [vw_Employee] -> EmployeeID(key), Name, EmailAddress Now for t...

When auto-mapping a collection with Fluent NHibernate, how do you make the child's foreign key to the parent nullable?

If I have a parent class: public class Parent { public Parent() { Children = new List<Child>(); } IList<Child> Children {get; private set;} } and a child class like so: public class Child { public SomeThirdClass Friend {get; set;} } Whenever I let the Fluent NHibernate's automapper hit these guys, it m...

help with second level cache using NHibernate and memcached

How can i read/write to the cache for a periode of time i.e 10 seconds and then commit the changes to the database? ...

How to use UNION in nHibernate?

Hello, I knew nHibernate does not support UNION. But there are some tricks, we can implement the same like : Using raw-sql Using sub-union class I have an old application which is using <join table></join table> Now, I want to implement UNION here. Here are the file(s) in application: file: .hbm.xml <hibernate-mapping xmlns="u...

What are recommended approaches for migrating from 2-tier NHibernate to 3-tier with SOA (Microsoft CRM)?

Given a (current) project that implements a 2-tier architecture with a well-separated on-tier business layer following the typical generic DAO architecture as pioneered by Bill McCafferty on CodeProject and explained briefly in chapter 10 of NHibernate in Action. This project must be moved to do CRUD operations and business logic throug...

ASP.NET MVC2 : Is it possible to make his own model, withou ado.net

Hello everybody For my project, i need to connect to a database who don't support ADO.net by using NHibernate So, is it possible to make my own model who can be usable by the auto-creation of views of visual studio 2010 ? Best regards. ...

NHibernate, subquery to select max value, right query is formed, but doesnt get executed.

IList lFolioHistory; ISession session = NHibernateHelper.GetCurrentSession(); var detq = NHibernate.Criterion.DetachedCriteria.For("e2"); detq.SetProjection(NHibernate.Criterion.Projections.Alias(NHibernate.Criterion.Projections.Max("Foliohistdate"), "maxFoliohistdate")); detq.Add(NHibernate.Criterion.Restrictions.EqPr...

Yet another many-to-many NHibernate question

hey there Trying to implement relatively simple relationship between User and Role. User can be in many roles, same Role can belong to any number of Users. Roles are shared, i.e. all admin Users refer to the very same instance of class Role. User mapping: <class name="User" lazy="false" table="Users"> <id name="Id" type="int"> ...

NHibernate best pratices (Query cache with much static data)

We have a situation, where we feel we do not fully take advantage of NHibernate's capabilities, which reduces performance. The actual situation is reduced to a "blogs with posts" example for this question. A blog site, where each user can have its own blog which has an arbitrary number of posts. Therefore, there is a table for posts def...

How to get list of changed (dirty) entities from Nhibernate session?

I need to write some business logic rigt before flush against all changed entities. One of the solution I've tried is IPreUpdateEventListener. But this event listener already have object denormalized to key-value. I need something before denormalization and even before flush. So the questions is how to get list of changed (diry) entitie...

How to use NHibernate to retrieve elements with a criteria on a List

Hi Folks I'm using NHibernate and I have the two following classes which map my DataBase schema: public class A { public virtual int Id { get; set;} public virtual List<B> MyList { get; set; } } public class B { public virtual int Id { get; set; } public virtual DateTime Date { get; set; } public virtual A FKtoA { ...

Is there a way to use the NHibernate session to figure out if changes need to be written to db?

Hi, I'm using NHibernate here with C#. I have a cache of nhibernate objects that have lazily loaded objects inside of those that might have changes written to them. I need a way to determine if there are changes that need to be saved. It's quite a lot of effort to set flags when one little thing changes and also quite annoying to compar...

NHibernate ISession and automatically flushing/committing transactions in my unit of work.

I have created an IDbContext object that is provided to my IRepository implementations. The DbContext provides a way for my business logic to create, commit and rollback transactions and commits as needed. It also transports my NHibernate ISession, so my NHibernate implementation of IRepository can access it. I am using this setup in a ...

NHibernate: read/write splitting

I would like to connect NHibernate to a MySQL master-slave replication configuration, so I would like to send writes to the master, and reads to the master and slaves. Is this possible? I am also planning on having a load balancer to balance the reads. (ldirectord) ...

'NHibernate.Mapping.Property' is not an attribute class

This code fails to compile with the error 'NHibernate.Mapping.Property' is not an attribute class. Any ideas why? using System; using System.Linq; using DevExpress.Xpo; using System.Collections.Generic; using System.Text; using NHibernate.Mapping; namespace Test { public class User : IdentityItem { public string email; publ...

NHibernate Cacaded delete not working on one-to-many association

Hi, I am trying to delete an object and cascade the delete to the child objects in a one-to-many association. I think that I have done everything correctly for this to work. However, when I run my test, NHibernate attempts to insert a null value into the foreign key column of the child table rather than deleting the items. From my pare...

Finding continuous ranges in a set of numbers

I have a reasonably large set of phone numbers (approximately 2 million) in a database table. These numbers have been inserted in blocks, so there are many continuous ranges of numbers, anything from 10 numbers to 10 thousand in a range. Some of these numbers are in use and are therefore marked as unavailable, the rest are available. Giv...