- ActiveRecord and ASP.NET 2.0 [Ayende ]
- Projection Using ActiveRecord's ImportAttribute and HQL's new Clause [Ken Egozi]
Edit: I shouldn't have missed, exploring test case
Castle.ActiveRecord.Tests\ActiveRecordGenericsTestCase.cs
[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")]Now I am ready to focus on another matter ;)
public class ProjectTypeList: Lookup
{
.. zero code ;)
}
[ActiveRecord("List_Lookups",
DiscriminatorColumn = "Type",
DiscriminatorType = "String",
DiscriminatorValue = "NA")]
public class Lookup: ActiveRecordBase
{
.... some code ...
}[ActiveRecord(DiscriminatorValue = "PTL")]Testing
public class ProjectTypeList: Lookup
{
}
ProjectTypeList.DeleteAll();Which cause all the records in the Lookup table deleted. WEIRD !
"Implement our own DeleteAll(), FindAll() and other method by in the derived classes."I hope I won't waste my time next time I tried to deal with this scenario.
using Castle.ActiveRecord;
namespace PID.Net.Models
{
[ActiveRecord(DiscriminatorValue = "PTL")]
public class ProjectTypeList: Lookup
{
public new static void DeleteAll()
{
DeleteAll(typeof (ProjectTypeList));
}
public new static ProjectTypeList[] FindAll()
{
return (ProjectTypeList[]) FindAll(typeof (ProjectTypeList));
}
}
}