How to delete child object in NHibernate?

You are getting the first error because, when you remove the items from the collection, NHibernate’s default mode of operation is to simply break the association. In the database, NHibernate tries to set the foreign key column on the child row to null. Since you do not allow nulls in that column, SQL Server raises … Read more

Polymorphism: Is ORM entity a Domain Entity or Data Entity?

I’m not entirely sure what you are asking regarding LINQ to SQL, but it’s certainly not the wrong approach to manually create you domain objects. You won’t get properly encapsulated domain objects if you rely on them being code generated. You have got yourself in a muddle regarding the factory pattern. As mouters has pointed … Read more

How to create NHibernate HasManyToMany relation

In this case the answer is pretty simple. Do not use many-to-many. Use pairing object. Exactly for the reasons you’ve mentioned: Extend the pairing object with more properties: Check here 24. Best Practices, a cite: Don’t use exotic association mappings. Good usecases for a real many-to-many associations are rare. Most of the time you need … Read more

How to partially project a child object with many fields in nHibernate

We can indeed use custom transformer. There is one, which I am using for a really very very deep projections (inlcuding dynamic objects – 5.1.13. component, dynamic-component) DeepTransformer<TEntity> Take it (if needed adjust it) and your final query could be like this // just the last lines are different var query = session.QueryOver<CourseItem>() .JoinAlias(c => … Read more

Syntax to define a NHibernate Filter with Fluent Nhibernate?

If you build Fluent from source, there is now support for filters. You use them like this: First create a class inheriting from FluentNHibernate.Mapping.FilterDefinition: using FluentNHibernate.Mapping; namespace PonyApp.FluentFilters { public class PonyConditionFilter : FilterDefinition { public PonyConditionFilter() { WithName(“PonyConditionFilter”) .AddParameter(“condition”,NHibernate.NHibernateUtil.String); } } } In your ClassMap for your class, use the ApplyFilter method: namespace PonyApp.Entities.Mappings … Read more