nhibernate

Querying unmapped properties in nhibernate

I am working with Linq-To-NHibernate. I need to use some properties that is not mapped to columns. For example Repository<Person> .Find() .Select(p => new PersonModel() { Id = p.Id, FullName= p.FullName,Position = p.Position }); The position is not a mapped property, it contains some logic. I got unmapped property error. Thank...

In nHibernate, how can I change the database connection (different db) dynamically?

Hi, If I want to do vertical partitioning of my db, how could I change the database connection dynamically on a per query basis? i.e. userID > 100000 use db1, otherwise use db0. ...

How to Map Enum in NHibernate to Properly Create DB Field on Schema Export?

I've seen several questions related to properly mapping an enum type using NHibernate. This article by Jeff Palermo showed me how to do that properly by creating a custom type. I use Schema Export to create my DB during my dev cycles, but this method breaks my export statement. Is there a way to specify the type of the column on export?...

Nothing happens on SaveOrUpdate using FluentNHibernate

Nothing happens when updating an entity using the SaveOrUpdate method with FluentNHibernate. Flush does work but I want to use SaveOrUpdate due to existing repository infrastructure. What could be the problem? Configuration: sessionFactory = Fluently.Configure() .Database(MsSqlConfiguration .MsSql2005 .Connectio...

Fluent Nhibernate and Nhibernate 2.1.0.1003

Hi All, Im experiencing some frustration trying to upgrade the nhibernate libraries that Fluent NHibernate uses. Im also using Nhibernate.Linq and am wanting to use NHibernate.Validator, specifically the ValidationDef class. Now Nhibernate.Validator is up to using Nhibernate 2.1.0.1003, and when i try to build FluentNhibernate against...

NHibernate: Criteria expression to retrieve all entities with null count child collection

In nhibernate, I have two classes that are associated with a many-to-one mapping: <class name="Employee" table="Employee"> .. <bag name="orgUnits"> <key column="id" /> <one-to-many name="OrgUnit" class="OrgUnit"> </bag> .. </class> I would like to use a criteria expression to get only Employees where the the collection...

Best practice for Handling NHibernate parent-child collections

So in a typical model where you have a parent that can have many children and a child that can have only one parent, how do you manage the adding of children. I have been using this approach; public class Parent { public Parent() { Children = new List<Child>(); } public IList<Child> Children { get; ...

Fastest way to query for object existence in NHibernate

Hello, I am looking for the fastest way to check for the existence of an object. The scenario is pretty simple, assume a directory tool, which reads the current hard drive. When a directory is found, it should be either created, or, if already present, updated. First lets only focus on the creation part: public static DatabaseDire...

Modelling Collections with associated statistics, and NHibernate.

I am currently attempting to refactor an application that has a lot of places where it displays lists or tables of data, with totals or averages at the end, and percentage changes or cumulative totals with each record. Typically the collection is modelled as a list of objects and the other data is calculated in the aspx code behind (yu...

What are the .net reference implementations of the Unit of Work pattern ?

Possible Duplicates: unit-of-work-pattern-in-net rhinocommons-unitofwork-question-with-asp-net-mvc The Unit of Work pattern is a way to keep in a context to track all the actions on your domain and to apply them all at once when your - possibly - complex logic is done. When used with an ORM (NHibernate for instance), it is cons...

Time and Nhibernate

hello i got an application that uses nhibernate as orm, i need to store data that represents time, whats the best way to do it? nhibenate dont know to convert time field from db to a timespan, only string. ...

NHibernate with Updatable Views

We are working with legacy database where some tables have 8 part composite key and chief architect is suggesting that we create an extension tables with surrogate primary key for each one of the tables in the database, then create a view (SqlServer 2008) and then point NHibernate mapping to these views. Question is what are the pitfalls...

Map a property to the latest entry in NHibernate

Let's say my domain looks like this: I have an object, Vehicle, that has an OdometerReading property. An OdometerReading has the Miles & Date (when it was read). I need to keep a history of all OdometerReadings for the Vehicle in the database, but don't want the entire odometer history to belong to the Vehicle object. What I wou...

Is Hibernate worse than NHibernate?

How does Hibernate compare to NHibernate? I've heard the claim that "Hibernate is much worse than NHibernate, even to the point of not using it (and using JDBC over it)". Can anyone support or refute this? Update - I am not trying to decide between them. Our DAL team decided to use NHibernate for our .Net side, but not use Hibernate on...

NHibernate query for matching all tags

Here are my relevant classes: public class Item { public virtual int Id { get; protected set; } public virtual IList<Tag> Tags { get; set; } } public class Tags { public virtual int Id { get; protected set; } public virtual string Name { get; set; } public virtual IList<Item> Items { get; set; } } These are mapped...

Configuring NCache with nHibernate and Castle ActiveRecord

Hi, We've a relatively mature website using Castle's ActiveRecord for it's persistance pattern (along with nHiberante). We've been using single node caching and so could rely on the built in ASP.Net cache and simply use ActiveRecord's Cache tag on our entities ([ActiveRecord(Cache = CacheEnum.ReadWrite)]). This works fine, and NHProf ha...

Updated Npgsql(1.0 -> 2.05) and got error (ObjectNotFoundException) on NHIbernate

Hello Guys... I updated the Npgsql driver to the last version (2.0.5) and got error in my NHibernate App... Mappings: School mapping : ... References(x => x.City); ... And City Mapping: Id(x => x.ID).GeneratedBy.Assigned(); Map(x => x.Name); References(x => x.Microrregion); Now, when I tried to load a School, I got a NHibernate....

Selecting a joined entity with an ICriteria in NHibernate

Hi, In HQL I can do something like this: select roleHeldByOwner.TargetPerson from Person roleOwner join roleOwner.RolesOnPeople roleHeldByOwner where roleOwner.Id = :roleOwnerId How can I achieve the same thing in a Criteria query? Specifically the selecting of something that isn't the first entity in the From clause. Thanks, Matt ...

Weird MethodNotFound exception when renaming a property - related to asp.net / web forms / fluentnhibernate and visual studio

I have a local website which I run through Visual Studio 2008's internal development web server (through the run / compile button). I have an external library which is referenced on a page of that website and resides inside the web site's "bin" folder. I've recently changed a class' property name inside that library (renaming it, from ...

Castle Project ActiveRecord - can it use stored procedures with SQLServer 2005?

I am new to Castle Project ActiveRecord. I have starting getting my hands dirty and I just seen that It can generate for you the schema, add data, update data to the schema. There are advantages of using stored procedures in SQL Server 2005, one of them being they are precompiled. Is there a way of telling Active Records to use a parti...