Data Modeling Library for .NET
- Documentation Website
- API Reference
- Anchor Wiki
- The change log starts with version 4.0.
Some entity base classes are literally just this.
public class BaseEntity : IEntity
{
public int Id { get; set; }
}
Besides locking down the name of your primary key (which you probably don't want anyways), that's not very helpful. So what should a base class do for you? Well, here's a short list.
- Validation, both attribute and imperative (
IDataErrorInfo
/INotifyDataErrorInfo
) - Property change notifications (
INotifyPropertyChanged
) - Change tracking so you know when records need to be saved (
IChangeTracking
) - Undo (
IRevertableChangeTracking
) - A second undo level for dialogs with ok/cancel buttons. (
IEditableObject
)
Tortuga Anchor does all of this, and at a very low cost.
Normal DTO
public class Person
{
public string FirstName { get; set; }
}
Tortuga.Anchor Model
public class Person : ModelBase
{
public string FirstName
{
get { return Get<string>(); }
set { Set(value); }
}
}
Just the slight change in how you write your properties is all you need to enable validation and property change notification. To add change tracking, change the base class to ChangeTrackingModelBase
. If you want a second level of undo, then use EditableObjectModelBase
.
And since all of the functionality is exposed through standard .NET interfaces, your existing frameworks and libraries will just work, including serializers and ORMs.