Hi everyone,
I'm using NHibernate + Castle.Windsor to add some behaviour to my entities. This means that NHibernate creates entities through Windsor. This means that I must have a default empty constructor so Windsor will be able to instantiate my entities. I don't like this for many reasons, the main one being that I dislike to have objects in an unstable state.
Is there any way I can instantiate an entity without a public parameterless constructor?
More info: I tried using a custom Activator for my entities but that doesn't work since Windsor throws an exception when it detects that there's no way to resolve dependencies, so it blows before using my activator.
Some code:
public class Product
{
public string Name { get; set; }
public Product(string name)
{
Name = name;
}
protected Product() { }
}
Let's suppose I have the above entity: If I try to resolve that entity through Windsor it throws an exception telling me that there are some dependencies that Product is waiting for some dependencies that weren't registered. If I use NHibernate alone, everything works correctly. So, basically I'm trying to emulate NHibernate behaviour in that scenario while resolving my entities through Windsor.
Thanks in advance,
Jorge Vargas.