Friday, November 02, 2007

Once upon a time there was a ^GENERIC^

Man ! how many times did you hear me say "I'm love the Generic so MUCH". Not only it elegant but it really got it gold purpose of code reduction. Let look back at my previous solution on ActiveRecord Type Hierarchy and see how generic could help me:
[ActiveRecord("List_Lookups",
DiscriminatorColumn = "Type",
DiscriminatorType = "String",
DiscriminatorValue = "NA")]
public class Lookup: ActiveRecordBase where T: class
{
.... some code ...
}
and now for derived class DeleteAll(), FindAll() etc are just ready to be use isn't that cool?
[ActiveRecord(DiscriminatorValue = "PTL")]
public class ProjectTypeList: Lookup
{
.. zero code ;)
}
Now I am ready to focus on another matter ;)

By the way x1r0k3wl's comment come to rescue.