nhibernate

Avoid first level cache for an entity in NHibernate?

I have an entity which is updated externally (using triggers, stored procedures). This means the entity can change without my knowledge in the same session, and it is required for me that I always perform a database hit, and never use the entity from the first level cache. Is this possible using NHibernate (or actually, Castle ActiveRec...

NHibernate: Map a property of type IList<DateTime>

Using NHibernate, is there a quick way to map the following class: public class Office { public virtual Guid Id { get; set; } public virtual IList<DateTime> Holidays { get; set; } } ...to the tables: table Office { Guid Id } table OfficeHolidays { Guid OfficeId, DateTime Holiday } ...

How does NHibernate 3 solve the QueryOver<> syntax?

I'm curious on how the NHibernate team has solved the QueryOver syntax, so that it works with intellisense and validation at compile time? According to http://nhforge.org/blogs/nhibernate/archive/2009/12/17/queryover-in-nh-3-0.aspx they make use of extension methods and lambda expressions, but I've tried looking through the source but i...

Setting Boundfield.Datafield property to nested/linked table

Hi, I have a situation where I'd like to set a BoundField.DataField property to a nested table. The page is loading an nHibernate object (a HotSpot) which as a sub-object (a Link). The datasource for the grid in this case is the HotSpot object and I can bind to its properties without problem. However I need also to access some of the ...

Use Linq and lambda to flatten a list

Hi there I have a class. public class MedicalRequest { private int id private IList<MedicalDays> Days private string MedicalUser ... } and another public class MedicalDays { private int id; private DateTime? day private MedicalRequest request ... } I have the MedicalUser so I'm able to select an I...

NHibernate "Could not find a part of the path" problem.

I'm trying to use NHibernate with my project, I've generated NHibernate class and xml file using NGen. After that, I try to test my application but when I run to second line of this code. var configuration = new Configuration(); configuration.Configure(); It show error message like below. Could not find a part of the path 'D:\App\...

Readonly collection properties that NHibernate can work with

Hi all My domain classes have collections that look like this: private List<Foo> _foos = new List<Foo>(); public virtual ReadOnlyCollection<Foo> Foos { get { return _foos.AsReadOnly(); } } This gives me readonly collections that can be modified from within the class (i.e. by using the field _foos). This collection is mapped as follo...

NHibernate error (Cannot insert duplicate key with unique index)

Hello guys... My Class Client : public class Client : Entity { public Client() { ListClientObjectX = new List<ClientObjectX>(); } public virtual IList<ClientObjectX> ListClientObjectX { get; set; } ... } My Class ClientObjectX public class ClientObjectX: Entity { public ClientObjectX() ...

Using NHibernate to Index Large Amounts of Data in Lucene.Net

We are using Nhibernate as our data access layer. We have a table of 1.7 million records which we need to index one by one through Lucene for our search. As we run the console app we wrote to build our index, it starts off fast, but as it goes through the items, it progressively gets slower and slower. Our First iteration was to just ...

ERROR: Loading object was of wrong class

Hi All, I have an MVC/Nhibernate app that is giving me the below. [WrongClassException: Object with id: f7eab616-76b2-4602-8643-b4466e91a33f was not of the specified subclass: AgileThought.ERP.Domain.CRM.Client (loading object was of wrong class [AgileThought.ERP.Domain.HR.SalesRepresentative])] NHibernate.Loader.Loader.Instanc...

Fluent nHibernate using AsList() returns null objects depending on the SortOrder

In a project I am working on, we are using tabs. These tabs have content. Multiple content objects can be on a tab. So we could have a 'car' tab, and that car tab may display a sedan content object, a suv content object and a truck content object. The user could also specify that it contains more or less of these objects and order them h...

How to don incremental multi user updates with NHibernate

Hello, I use nhibernate as my orm and i am trying to implement something that looks straightforward but has become unneccessarily difficult. It concerns how to implement concurrent updates to an entity where it is expected that the entity will be updated simultaneously by more than one user in a multiuser scenario. The entity is an acc...

After calling NHibernate.Initialize(proxyObject) I'm getting wrong objectType

Hi all. I have object hierarchy Parent->Child (Lazy loading is set to true by default) Now I'm loading all Parent objects from database. All child object will have the type ChildProxyGUID. then I write the IList<Parent> parentList = NHibernateHelper.List<Parent>(); foreach(Parent parent in parentList) { if(!NHibernateUtil.IsInitiali...

NHibernate - how to handle user sessions

I guess what I'm after here is a quick example of how to do this. I've got fluent nhibernate working fine. I can create new records with no problem, and read in existing records no problem. The issue I'm having is with the asp.net user session and how I handle the fact that I want to keep that around between page loads, and I want to wri...

NUnit Assert.AreEqual(object a, object b) false negative?

I can't understand why NUnit Assert.AreEqual is failing. var dataService = new DataService(db); dataService.Set("Tests", "circle1", circle); var circleData = dataService.Get("Tests", "circle1"); Assert.IsNotNull(circleData); var circleCopy = circleData.Get(); Assert.AreEqual(circle, circleCopy); Using NHibernate (storing serialized da...

NHibernate - how to query against subclass properties while returning the super class?

Using NHibernate; is it possible to query against a super class while performing restrictions at the subclass level? For example (appologies for the psuedo-code): Class A Property Prop1 End Class Class B Inherits Class A Property Prop2 End Class Class C Inherits Class A Property Prop3 End Class How would I perform a ...

Spring.NET NHibernate cannot commit changes to database

I use Spring.net 1.3 and NHibernate 2.0, develop web applications. One of my applications cannot change data, and no exceptions throwed. I checked the log file, It seems that NHibernate can not generate UPDATE,INSERT,DELETE sql. Another application use the same database with same mapping files works fine. What's wrong with it? Did I ...

Creation of mapping Entities for NHibernate having multiple databases with different servers

I'm looking for some suggestion. We have server setup as below for 3 applications interacting together. 1) Application A with Database A 2) Application B with Database B 3) Application C with Database C Use Case: User's from application A submits some requests which is then sent to application B or C for approval. User's from applicat...

Nhibernate: Batching and StatelessSession

Hi. I was trying around with just setting the batch value in the config file, and I see that there's a visible benefit in using it, as in inserting 25000 entries takes less time then without batching. My question is, what are the counter indication, or the dangers of using batching? As I see it I only see benefits in setting a batch val...

Count projection from criterion

I'm trying to write a query that takes a criterion and returns a count projection, this is what i'm using at the moment but it's really inefficient, why ideas on how I can replace this? /// <summary> Each criteria contributes one row </summary> private IProjection AsCount( ICriterion criterion ) { if (criterion == n...