Customization & Refactoring

Customization & Refactoring

Please watch this video for an in-depth overview of Customization & Refactoring.

 

Unlike standard LINQ to SQL, PLINQO supports customizing and refactoring your DBML.

Easy Synchronization of Database Changes

Changes are an inevitable part of any project. The LINQ to SQL designer in Visual Studio provides a lot of support for manipulating entities, but does NOT make it easy when a refactor is required. The LINQ to SQL designer requires that the entity be dropped and recreated to generate the necessary updates. When the entity is dropped, any updates made for that entity are also lost and now must be re-created. This is time consuming, tedious and results in work being done over and over again. With PLINQO, make changes, right-click, generate, DONE! PLINQO makes it that easy. PLINQO supports syncing the database with the dbml while preserving any manual dbml updates.

Metadata Customization/Syncing

The System.ComponentModel.DataAnnotations assembly introduced in .NET 3.5 SP1 provides another opportunity for PLINQO to make life easier. PLINQO generates and maintains a metadata class inside each entity. This metadata class allows you to easily add extra knowledge about your domain objects and their properties. Each time PLINQO is re-generated, DBML and database changes are synced while preserving any custom changes using a new feature in CodeSmith called the insert class merge strategy. The process of maintaining metadata on each entity in the system now can be as simple as regenerating your metadata classes.

Here is a picture of a MetaData class that sits inside a User class.

[CodeSmith.Data.Audit.Audit]
private class Metadata
{
    // Only Attributes in the class will be preserved.

    public int Id { get; set; }

    [Required]
    public string UserName { get; set; }

    [Required]
    [DataType(System.ComponentModel.DataAnnotations.DataType.Password)]
    public string Password { get; set; }

    [DataType(System.ComponentModel.DataAnnotations.DataType.EmailAddress)]
    public string EmailAddress { get; set; }

    public string FirstName { get; set; }

    public string LastName { get; set; }

    public System.Data.Linq.Binary Avatar { get; set; }

    [Now(EntityState.New)]
    [CodeSmith.Data.Audit.NotAudited]
    public System.DateTime CreatedDate { get; set; }

    [Now(EntityState.Dirty)]
    [CodeSmith.Data.Audit.NotAudited]
    public System.DateTime ModifiedDate { get; set; }

    public System.Data.Linq.Binary RowVersion { get; set; }

    public EntitySet AssignedTaskList { get; set; }

    public EntitySet CreatedTaskList { get; set; }

    public EntitySet UserRoleList { get; set; }
}

 

Having this pre-configured makes it obvious where to go when extra knowledge is needed about the model. ASP.NET Dynamic Data attributes such as what control should display the data, data types, how to validate fields and actions taken on properties are just a few of the attributes available for use within the metadata class.

Next: Data Services & WCF