nhibernate

NHibernate -- How to fake one side of a many-to-many normalization

Hi, I have the following two tables: Package id ClientPackage id clientNumber packageId The thing is that I do not have a Client table in this database (it resides in another database). Is there a way that I can create a Client mapping to a Client model which just consist of distinct "clientNumber" from the ClientPackage table whil...

sp_executesql causing my query to be very slow

I am having some issues when running sp_executesql on a database table. I am using an ORM (NHibernate) that generates a SQL query that queries one table in this case. This table has about 7 million records in it and is highly indexed. When I run the query that the ORM spits out without the sp_executesql, it runs very quickly and pro...

Nhibernate Criteria Subqueries and Between Expressions

I am using looking to use a sub query in Nhibernate Criteria to check on the visibility of a row. I have created a subquery in sql that looks like this select * from Visibility as b where **ProductID = a.id** and SiteId in (129) and ( Hide = 1 and ( ((StartDate < GETDATE()) and (EndDate is null)) or ((EndDate > GETDATE()) ...

ASP.NET + Nhibernate object rebind to session

Hi, guys I want to store my object in ASP.NET Session. This object has some lazy loaded properties. When I do postback to my page and get my object from Session, this properties throw LazyInitializationException. Can I rebind this object to newly creates Nhibernate Session to retrieve this properties or I have to create Session and get ...

How to handle a large ammount of mapping files in nHibernate

Hello, we're working on a large windows forms .net application with a very large database. currently we're reaching 400 tables and business objects but thats maybe 1/4 of the whole application. My question now is, how to handle this large ammount of mapping files with nhibernate with performance and memory usage in mind. The business ...

NHibernate - Querying from a collection of Value Types (non-Entity) to solve Select N+1

I have an entity that represents a Tweet from Twitter like so: public class Tweet { public virtual long Id { get; set; } public virtual string Username { get; set; } public virtual string Message { get; set; } // other properties (snip)... public virtual ISet<long> VoterIds { get; protected set; } } I'm trying to...

Fluent NHibernate : How to map a 'Foreign Key' column in the mapping class

I'm starting to develop with Fluent NHiberate, and I was wondering how I create a defined 'Foreign Key' relationship in my Mapping class. Here's my class. These classes are a one-to-one with associated tables. public class Song { public virtual int SongID{ get; private set; } //Primary Key public virtual int SongArtistID { get...

NHibernate Duplicate class/entity mapping problem

I've have started my foray into C#.NET and NHibernate and I'm finally stuck on an exception I can't seem to figure out, and Google isn't helping. I'm getting a NHibernate.DuplicateMappingException : Duplicate class/entity mapping on my Parent class. Below is my mapping file for the Parent class, and the Youth class that uses the Parent...

NHibernate with TransactionScope

I found when i different Database session factory in single transactionscope, it will failed. for example: 1) this will work if mutiple session factory points to the same db. Transacton 1 & Transaction 2 are for the same db. using (var scope = new TransactionScope()) { //transaction 1 using (var session = AdPubSessionConfig....

Implementing Nhibernate one to many mapping

Hi, I have a class School and another class Teachers. now every school can contain m Teachers and one Teacher may be part of more than one school. But in the Teachers class I dont want a property that tells me which Schools a teacher is part of. Thus, public class School { public virtual int Id {get;set;} public virtual string Name {g...

NHibernate 3 Alpha - proxyfactory.factory_class?

Hi, Im playing around with NHibernate 3 alpha but struggling to set up my SessionFactory. I have the following: var config = new Configuration().Configure(); _sessionFactory = config.BuildSessionFactory(); However, in the provided dlls with the 3 alpha download there are no provided proxy factory classes. Ie NHibernate.ByteCode.Ca...

How to properly manage NHibernate eager loading?

Currently I'm writing strategies for various purposes. Like this one: namespace x.Persistence{ using Domain; using NHibernate.Linq; public class ApplicationDefaultEagerLoading :IEagerLoadingStrategy<Application>{ public virtual INHibernateQueryable<Application> Attach(INHibernateQueryable<Application> q){ q.E...

Loading presentation models directly from database

I'm working on a 2-tier application where WinForms client makes direct calls to the database. In one of the scenarios I need to display a list of Customer entities to a user. The problem is that Customer entity contains a lot of properties (some quite heavy) and I need only two of them - first and last names. So to improve performance an...

Putting forward a solution to replace Typed datasets

Hi all, A project I am currently employed with will have some time soon to improve and specialise a product that is currently in use. We may have about 4 man weeks spare in which we could replace the typed datasets that are in use. The project is currently written in Vb.Net and we will definitely not have time to replace this code with...

Cannot set a default Nhibernate isolation level (eg via mapping)

This has been a problem that has existed on 3 projects for me. I have tried the following: <property name="connection.isolation">ReadCommitted</property> Set in hibernate.cfg.xml Using fluent nhiberate: MsSqlConfiguration.MsSql2008.IsolationLevel(IsolationLevel.ReadCommitted); Set in global.asax.cs I have always been forced to s...

Can we make use of the Sharp Architecture in a web application, without MVC?

Hi, I am a newbie to NHibernate. Just was thinking whether we can make use of the Sharp Architecture in a web application, without MVC? Thanks. ...

NHibernate slow startup, conditional loading of HBMs and "Association references unmapped class"

Background We have several projects / applications running off the same model. They all have their own unique entities / tables, but also share 1 specific, common entity / table. I.e. Entities required by application A, will never be required by application B, except for the common table, and vice versa. Now the common table has relatio...

NHibernate 'touches' my native ISQLQuery

In the application I'm developing, I am using NHibernate as ORM. My app has to support SQL Server, and MS Access (I'm using the NHibernate JetDriver). Now, the thing is that I have a certain query which I cannot achieve using HQL or the ICriteria API; so, I'm using an ISQLQuery for that one. Now, what bothers me, is that it seems that ...

Multiple ClassMaps classes in NHibernate

Is this possible in fluent nhibernate having multiple mappings for one table? Lets suppose i have a Users table. Once i want it to be apped exactly like in file UserMap1.cs, and some times I would rather prefer mapping from UserMap2.cs. I don't need to switch configurations while app is running. I just have to choose a proper one at th...

Nhibernate Query to compare if item present in list

I want to write a nhibernate query to get all employees who are in the given list of departments. The senario is the employee class has the department class property.the department class has the department name in it besides other properties.I have a list of department names with me and i want all employees who belong to that departm...