NHibernate child update options

April 22, 2012 | In Development | No Comments

I was trying to cascade deletes to an object tree, but it was not removing the object entirely, only the key.

In Fluent NHibernate:

.Cascade.All()

The answer is that the type of cascade needs to include ‘delete orphans’, otherwise NHbiernate will leave the record in case something else is using it.

In summary the options available are:

  • None - let the user handle; equivalent to not having  cascade statement;
  • All - when an object is saved, updated or deleted, check the associations and save, update or delete all the objects found;
  • SaveUpdate - when the object is saved or updated check the associated objects and do the same;
  • Delete - when the object is deleted, delete all the associated objects;
  • DeleteOrphan - when the object is deleted, delete all the associated objects, and when an object is removed and not associated with another object (orphaned), also delete it;
  • AllDeleteOrphan - as ‘all’ but combined with ‘delete’orphan’.

Using NuGet with Ninject MVC3

May 7, 2011 | In Development | No Comments

If you have not used NuGet yet I strongly recommend you have a look.  It’s a Visual Studio extension that simply takes the hassle out of having to download, install, reference etc. libraries and third party tools.  It will automatically update everything for you in your project.  Have a look here http://www.nuget.org.

Now I’m a fan of Ninject (http://ninject.org) an inversion of control dependency injection container, and a fan of ASP.NET MVC (http://asp.net), so in order to use Ninject and MVC 3 you can use NuGet to setup it for you.

To do this run the following package install command in the Package Installer:

install-package ninject.mvc3

What’s really neat about NuGet is that it will also install any dependencies, so in this case will also install Ninject itself.

Error finding ‘log4net’ library

February 15, 2011 | In Development | No Comments

When using log4net in a .NET 4 project, when you compile the project you can get an error saying that it cannot find ‘log4net’ or ILog.

The solution seems to be that the framework for the project is set to ‘.NET Framework 4 Client Profile’, while what it needs is ‘.NET Framework 4′.  You can change this in the project properties page.

It seems to be something to do with System.Web, but haven’t narrowed it down more than that.

Next Page »

Login | XFN| WP
Powered by WordPress with cmb-web Theme design by Christian Bridge-Harrington.
Blog feed. Valid XHTML and CSS. ^Top^