nhibernate

How to add NHibernate XML schema to Visual Studio?

I'm learning NHibernate and I added <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> to App.config. Visual Studio reported a message: Could not find schema information for the element 'urn:nhibernate-configuration-2.2:hibernate-configuration'. I know this is not a problem, but if VS knew the schema, IntelliSense w...

Why NHibernate fails to lazy load depending on SetMaxResults argument?

Hi, we have one to many to one relationship which we are trying to implement in NHibernate. This is a rephrase of my colleague's question. There is Block with a collection of GroupPartnerInterests every of which has a Company. Following test method passes with SetMaxResults(3) but fails with SetMaxResults(5). Exception is NHiberna...

Query many-to-many without selecting all objects using Criteria API

I have a many-to-many relationship between Project and Site. I am trying to retrieve a list of Sites for a project using the Criteria API. I've got this working but the query also selects all of the columns for the associated Projects, which I don't want. I wrote what I thought was an equivalent query using HQL and it only selects the Si...

Unable to figure out how to do Joins within IQueryable

Here is what I am trying: IQueryable query = this.MyRepository.GetShippingCollection(); IList<SomeListType> myList = query.Where(x => x.Settings .Where(y => y.SelectorID.Equals(5)) .Count() > 0) .OrderBy(x => x.Order) ...

Nhibernate doesnot load primary key value

hello, I'm using Nhibernate version 2.2 for mapping classes to tables in my project. following is my class file and mapping file public abstract class BasicUser { public virtual int RowID { get; set; } public virtual string DisplayName { get; set; } public BasicUser() { } } <class name="BasicUser" table="...

NHibernate - Paging with ICriteria and optional ICriteria calls

I want to do something like this... return GetSession() .ToPagedList<Employee>(page, pageSize, x=> x.SetFetchMode(DomainModelHelper.GetAssociationEntityNameAsPlural<Team>(), FetchMode.Eager)); But I don't know how to pass this Func<ICriteria,ICriteria> into the ISession or ICriteria. I have a standard paging ext...

Can Identity Generators be used for other columns with NHibernate

I'm creating an invoicing feature and I want to use a counter for the invoice number, but instead of writing an implementation I was wondering if it is possible to use an existing identity generator in NHibernate for this property? ...

NHibernate: map multiple columns into a single collection

Suppose I have a table: ID(pk) | HOME_EMAIL | WORK_EMAIL | OTHER_EMAIL ------------------------------------------------- and the .NET classes class A { int id; List<MyEmail> emails; } class MyEmail { string email; } I suppose there's no way to map those (multiple) columns into a single collection in NHibernate, or is ...

NHIbernate & Rhino-Security does not save unless I call session.Flush()

Hello, I am having an issue using nHibernate and Rhino.Security. After struggling for hours to get the right config setup, I finally got the code to run without any errors. However, no entries are being saved to the database unless I call session.Flush(). Looking at various examples on the net; I should not have to call flush. Here’s ...

Mysql, NHibernate and visual studio 2008 configuration

Hi, I am a beginer with visual studio 2008 (C#), mysql and NHibernate. I have problems with mysql connector as I don't know how to add reference to it. In my project I have: /lib/mysql-connector-net-6.1.4-src/ (downloaded from http://dev.mysql.com/downloads/mirror.php?id=387799#mirrors) Now I right click on my project -> addReferenc...

Fluent NHibernate one-to-one mapping with synthetic keys

Hello all, I have two tables tblPart ( partId, subpartId UNIQUE NULL ) tblSubpart ( subpartId ) So I can only have zero or one subPart associated with the part at the same time. I'm trying to map this as ClassMap<Part> { HasOne(x=>x.Subpart); } and the convention rewrites the foreign key so it uses subpartId ins...

NHibernate deployment on IIS7 problem

Hello, This might be quite common but I'm having an issue with nhibernate on iis7 my webservice works fine on visual studio 2008 default webserver but not on iis7. I've tried moving the httpmodule config section into the webserver/module section and I've also tried leaving the module config inside system.web/httpModules and switching th...

NHibernate ISessionFactory breaks my assembly, why?

When I have the following bit of code in my C# Class Library, it totally breaks the library for everything else. namespace DesktopOCA.Infastructure { public class NHibernateHelper { private static ISessionFactory _sessionFactory; } } For example this is also in that project: namespace DesktopOCA.Infastructure { ...

avg aggregate function in HQL causing trouble in NHibernate, what is wrong with my query?

Hi, Having trouble with an HQL query. If I remove the avg(..) from it it will return all of the empty weights, so the trouble is with the avg function. It seems clear in the Nhibernate docs that I can perform an aggregate function on the select item like this. Is my problem something to do with query.ToList not liking to return a list of...

NHibernate: Find dirty collections

I know how to find dirty properties using NHibernate, but it doesn't seem to work for collections (i.e. to find out if items have been added or removed from a collection). Anyone know how? ...

Fluent Nhibernate - dont understand the generated Sql from NHibernate

hi, i created the following mappings with fluent nhibernate: public class AuswahlMap : ClassMap<Auswahl> { public AuswahlMap() { Table("AUSWAHL"); Id(x => x.Id,"ID") .GeneratedBy.Sequence("SEQ_AUSWAHL"); Map(x => x.Programm).Not.Nullable();; Map(x => x.Variante); Map(x => x...

Nhibernate Criteria/SQL Query problem

Hi I have a querry that returns a large number of rows. I want to know if there is a way to decrease query time without changing the results. One smsblast contains multiple smsresponses and smsresponse contains multiple smsstatuses. Variables status = int smsBlastId = int var queryStatus = DetachedCriteria.For<SmsStatus>() .Add(Re...

Fluent HNibernate Mapping Property Issue

Hi, i have two entities one called User and another called Membership which has a one to many mapping from User to Membership. I need to add a property on my User entity called CurrentMembership which gets the latest Membership row (ordered by the property DateAdded on the Membership Entity). I'd appreciate it if someone could show me ...

NHibernate - missing dll's

This call // this._cfg is an NHibernate Configuration instance this._sessionFactory = this._cfg.BuildSessionFactory(); Gives me this exception at runtime (NOT at compile time). Could not load file or assembly 'NHibernate.ByteCode.Castle' or one of its dependencies. The system cannot find the file specified.":"NHibernate.ByteCode.Castl...

How to get mapping for key-property in NHibernate?

Hi, I'm trying to load nhibernate mapping for POCO classes at runtime with following lines: var persistentClass = NHibernateHelper.Configuration.GetClassMapping( type ); var property = persistentClass.GetProperty( propertyName ); It works fine except it fails on property GroupId on a class with following mapping: <class name="GroupP...