nhibernate

NHibernate + Cannot insert the value NULL into...

I've got a MS-SQL database with a table created with this code CREATE TABLE [dbo].[portfoliomanager]( [idPortfolioManager] [int] NOT NULL PRIMARY KEY IDENTITY, [name] [varchar](45) NULL ) so that idPortfolioManager is my primary key and also auto-incrementing. Now on my Windows WPF application I'm using NHibernate to help with adding...

NHibernate select most recent record that meets criteria

Last night I started working on an NHibernate provider. I'm creating a criteria that several records will match, however I only want to return the most recent record (the record with the largest Id). I thought UniqueResult() would do this it cannot be used if a list would be returned otherwise. I could theoretically select the full li...

NHibernate select grows exponentially slow

My problem is that NHibernate gets exponentially slow when fetching records from the database. I had a request to basically pull all the data from a very large database to be used in a report. I figured, well since I can't get all the records in one shot because the recordset is so large, i thought try breaking it up. Basically I'm ite...

NHibernate Design For WinForms

How should I have the NHibernate Session Factory and the sessions for a WinForms application? Should the SessionFactory be a singleton? Or can I create it every time? What about sessions and transactions? Any help would be appreciated. Thanks ...

Sync two SqlExpress using NHibernate

Hello, I am creating a simple project management system which uses NHibernate for object storage. The underlying database is SQL express (at least currently for development). The client runs on either the desktop or laptop. I know I could use web-services and store the DB only on the desktop, but this would force the desktop to be avai...

LINQ to NHibernate can't get to children's children

I have entity A which has an IList of B called Bs and B has an IList of C called Cs. I want to search for all A's which have at least 5 C's in them. So I went and wrote using (var s = this._sessionFactory.OpenSession()) { IQueryable<A> q = s.Linq<A>(); // some code... if (range.Min.HasValue) q = ...

n-tiered architecture with Silverlight, WCF and nHibernate

Dear All! I try to set-up a clean and flexbible application-framework for data-centric applications with silverlight-only UI. I want to have a strict seperation of concerns, and want to be as flexible as possible (e.g. exchange the ORM later) while still reducing the amount of code. It took me weeks to figure out an appropriate archite...

NHibernate : Count childrens' children

I have an entity type A. Which has many B's. The B entity has many C's. I need to count how many C's does an A entity have. How can this be done using NHibernate Criteria API? Using LINQ to NHibernate I was unable to get results since it throws an exception (see this question) ...

Association class in NHibernate

Hi, i want to map two classes m:n associated using NHibernate. NH would map a simple m:n association in a link table with foreign key constraints to the entity tables. Now I want to attach more attributes to the association as seen on this example: (and I want NHibernate to store these attributes in the link table) This UML diagram s...

Is Lazy Loading really bad?

I hear a lot about performance problems about lazy loading, no matter if at NHibernate, Linq.... The problem is N+1 selects. Example, I want all posts and its users, at foreach I lazy Load Users, them I need one select for posts, plus N select for each user. Lazy Loading: 1 - select ....from post N - select ....from user The "good" ap...

NHibernate: Many-to-One - *Must* You Load the Parent Object?

Assume the following entity classes: public class Player { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual Team Team { get; set; } } public class Team { public virtual int ID { get; set; } public virtual string City { get; set; } public virtual string Nickname { get; set; } } Assume t...

Storing a collection in SQL

[pre-able] In my www.twipler.com project I want to allow people to link Twitter accounts. This will be achieved by having them login, selecting "link account" and then logging in again. This will effectively give me UserId-1 and UserId-2. Now I want to allow the user to login with either UserId-1 or UserId-2 credentials and then retreive...

LINQ TO Nhibernate Count

I am trying to use LINQ to Nhibernate to get a count on a table in my database. However, the code I am running is pulling back all of the records in the table versus running select count() from table. Here's my code- public int GetTotalCount(Func<T, bool> where) { IQueryable<T> queryable = this._sessionManager.GetCurrentS...

NHibernate: Table Per Subclass Mapping and the New Keyword

I'm trying to use NHibernate to map a table per subclass inheritance structure that looks something like this: public class BaseClass { public virtual IColllection<BaseClassCollection> Collection { get; set; } } public class ChildClass : BaseClass { public new virtual ICollection<ChildClassCollection> Collection { get; set; } }...

NHibernate Bi-Directional one-to-one mapping problem.

While trying to create a Bi-directional one-to-one mapping in NHibernate, I found that, I am unable to have the Reference of the objects recursively. For example: suppose I have one-to-one relationships between Person and Address. then after executing the following code, class Person { ... ... public Address Address { get;set;...

How do I map Join tables with fluent auto mapping?

Here are my classes: public abstract class TypeBase { public virtual int? Id { get; set; } public virtual string Name { get; set; } } // various other classes extend TypeBase the same way public class Color : TypeBase { } public class Template { public virtual int? Id { get; set; } public virtual IList<Style...

Problems with NHibernate DefaultUpdateEventListener and events

I have a problem with the DefaultUpdateEventListener in NHibernate. I will update 2 objects and then i commit the session. The first object didn't come into the listener and the second object comes there. So i checked with reflector to check what the problem is First NHibernate will call the PerformSaveOrUpdate in the DefeultSaveOrUpd...

nhibernate custom collection handling

Hello I have a working one to many relationship (NOT bbidirectional) where Resource has a set of many Allocations implented as shown below. The domain needs to do more with the collection of allocations that just manage it with AddAllocation, RemoveAllocation, etc. So from an object perspective, I'd like to put that extra logic that is ...

NHibernate - Conversion failed when converting datetime from binary/varbinary string

Note, this is some ancient NHibernate installation! I have the following NHibernate class: [Serializable] [Class(Table = "SomeEvents")] public class SomeEvent { [Property(Column="processDate")] public DateTime? ProcessDate { get; set; } } When trying to update some events like: using (ISession session = FDK_Hibernate_Manager....

NHibernate: Unable to cast PersistentBag...

This question was asked back in October (unable-to-cast-object-of-type-nhibernate-collection-generic-persistentgenericbag). Basically, I have a POCO that has a one-to-many relationship modeled by a List<ChildType>. When you try to get it/save it in NHibernate you get a type cast exception saying it's trying to cast from NHibernate.Colle...