nhibernate

How do I select a Random Row using NHibernate's ICriteria API?

Can I select a random row using NHibernate's ICriteria API? ...

NHibernate DetachedCriteria - how to use something like Oracle's NVL on outer-joined set

I'd like to create DetachedCriteria which would perform something similar to the following SQL code: select * FROM PRICELIST pl LEFT OUTER JOIN PRICELISTDURATIONSHIFT sh ON sh.PRICELISTID = pl.ID WHERE sh.CUSTOMERID = :cust AND nvl(sh.DATEFROM, pl.DATEFROM) <= :dt ORDER BY nvl(sh.DATEFROM, pl.DATEFROM) DESC I'm able to left-outer-jo...

nhibernate: How do I map a component which references an enity?

My db looks somthing like this: MyEntity State ----- ----- id id street name stateId ... zip status ... My Model looks like this: class MyEntity { int id { get; set; } Address location { get; set; } string status { get; set; } // ... } class Address { string street { get; set; ...

NHibernate SchemaExport failing to drop a table .... sometimes

I'm using NHibernate for the DAL of my application, and in particlular NHibernate's SchemaExport function to drop/recreate my database schema before the execution of unit tests. The issue I'm having is that when I run the unit tests and execute SchemaExport one of my tables fails to drop every second time. This would indicate to me that ...

nHibernate Mapping Issue - Cannot Delete members of a collection

Ok. So the situation is: Parent Class which has an IDictionary of Child Classes. I wish these child classes to be deleted when the parent class is. This works fine. I also wish to be able to delete members of the child class individually, and this does NOT work. So my Question is; Why can I not delete these child members? The error ...

ADO.NET Entity Framework and NHibernate - when to use one over the other

I am working in a Microsoft .NET shop where it is okay to use NHibernate or ADO.NET EF. What guidance should we be using about when you should choose one over the other? For example, it seems like when writing a Silverlight app the EF -to-> ADO.NET Data Services -to-> Silverlight would offer a productivity boost, and provide you with a ...

Lightspeed vs NHibernate

What is the experience with LightSpeed? The comparison provided by Mindscape doesn't say too much about NHibernate. Lightspeed seems flexible, but I don't see much about performance. How well does Lightspeed perform? Also are there any drawbacks to using Lightspeed? ...

CodeSmith template for NHibernate multiple databases

Is there any codesmith template for NHibernate that handles multiple databases connection? ...

(Fluent) NHibernate - Mapping Varchar to Int32

We work with legacy database which are saving integer values to the varchar column. We need to map this column to Int32 property and it works well if data in database column are numeric or NULL. But we have problems if column contains empty string instead of null - nhibernate throws error that it cannot convert it to integer. Is it p...

how to do constructor injection when mapping a class as component in nhibernate?

For mapping component in nhibernate , is there a way in the hmb file we can indicate a overlaoded constructor to be used instead of default one. In below mapping nHibernate will use the default constructor of MyClass when reading data from database - I am wondering if we can instruct nhibernate to use a overloaded constructor instead ? ...

NHibernate: Return A Constant In HQL

I need to return a constant from an HQL query in NHIbernate SELECT new NDI.SomeQueryItem(user, account, " + someNumber + ") FROM NDI.SomeObject object I am trying for something like above. I've tried this: SELECT new NDI.SomeQueryItem(user, account, :someNumber) FROM NDI.SomeObject object And then later: .SetParameter("someNumb...

Determine if an entity field changed in NHibernate

I have a call that needs to determine if a field has changed. But calling get using that entities id returns the same entity not the prior version. Entity e = Dao.Get(id); //At this point e.Field is X e.Field = y; Dao.Save(e); Entity Dao.Get(Guid id) { return Session.Get(id); } Entity Dao.Save(Entity e) { Entity olde = Session...

Handling NHibernate Exceptions

What's the best practice for handling exceptions in NHibernate? I've got a SubjectRepository with the following: public void Add(Subject subject) { using (ISession session = HibernateUtil.CurrentSession) using (ITransaction transaction = session.BeginTransaction()) { session.Save(subject); ...

Data Structures in ORMs

Hi, How do you map rudimentary data structures (e.g. Tree, Dictionary) in an ORM such as NHibernate. ...

should i use NHibernate ?

i'm building a 3 tier wpf application. i heard that nhibernate is best for web applications. i know how to use nhibernate. should i use it or not?? are there any recommended or mappers that will be more suitable? ...

Usage of ORMs like NHibernate when there are many associations - performance concerns

I have created an application (a web-based application) which now has a large number of associations. Simply put, an Account: has many Users has Settings has many Projects Similarly a Project: has many Items A User: has many Tasks And so on, with loads more associations. Nothing particularly unusual about that I hope. I chose...

Is it possible to do Standard Deviation in NHibernate?

Is it possible to calculate Standard Deviation with NHibernate? I'm using the Microsoft SQL Server 2005 Dialect. I can't find any examples of this anywhere. Please help. thanks! ...

Fetch Tags and Tag count using HQL on SQL Server 2008

I'm implementing tagging on a particular entity, using NHibernate on SQL Server 2008. The structure I have now is, simplifying, like this: public class Entity { public Guid Id { get; set; } } public class Tag { public Guid Id { get; set; } public string Name { get; set; } } public class TagAssoc { public Tag LinkedTag ...

Ignore public/internal fields for NHibernate proxy

I have some entity types that I would like to lazy load. However, they have some internal (assembly) fields they expose, but are not used outside that class. These fields are compiler generated (F#) and I cannot change them. The an example exception is: NHibernate.InvalidProxyTypeException: The following types may not be used as ...

NHibernate Error on session.Save

Hi, I have an MVC app using NHibernate. I created a model and tried to insert data into the db for the first time with NHibernate, so please go easy. I get this error on the session.Save(object); IndexOutOfRangeException was unhandled by user code Invalid index 8 for this SqlParameterCollection with Count=8. When I look at the data...