Why I like NHibernate Generics
Because I wrote it, of course J
Beside this, there is the nice part about smart collection
and references that can save me quite a bit of code. Take this example:
RuleBase rule =
RulesTree.SelectedNode.Tag as
RuleBase;
if(RulesTree.SelectedNode.Parent==null)//top Rule
{
customer.Rules.Remove(rule);
}
else
{
ContainerRule parent =
RulesTree.SelectedNode.Parent.Tag as
ContainerRule;
parent.Children.Remove(rule);
}
I started to write this code, but soon realized that because
I used NHibernate Generics’ smart collection, I could do this instead:
RuleBase rule =
RulesTree.SelectedNode.Tag as
RuleBase;
rule.Customer = null;
rule.Parent = null;
This is much simpler, in my opinion, and it has the same
affect.
Comments
Comment preview