Features
What the templates generate
The dbml file
The DBML template generates or updates a LINQ to SQL dbml file from your database schema.
- Includes all tables, stored procedures, functions and views, and you can exclude objects with regular expressions.
- Automatically removes object prefixes and suffixes (for example,
tbl_andusp_). - Standardizes the object names produced from database tables.
- You can still customize the dbml file with the Visual Studio designer.
- You can refresh the dbml file from the current database schema without losing your customizations. See the safe attributes.
The DataContext and entity classes
The Entities template generates the LINQ to SQL DataContext class and the entity classes.
- One file per entity instead of one large file.
- Partial classes where you write custom code that isn't overwritten.
- A metadata class with attributes, built from the dbml information.
- The generated entity files are added to the project as code-behind files of the matching custom entity files.
Managers and query extensions
- The Managers template generates a manager class for each entity. It adds a customizable rules engine that enforces validation, business and security rules based on metadata attributes, and provides common queries by primary key, foreign key and index. The queries return
IQueryable, so you can extend them. - The Query Extensions template generates query extension methods for each entity.
And more
- Query result caching
- Performance improvements, such as batch updates and deletes
- Auditing
You can customize every template to meet your needs.
Advantages over the designer
The PLINQO templates have several advantages over the Visual Studio LINQ to SQL designer:
- No black box. You can customize the generated output, and you can still use the dbml designer in Visual Studio to make changes.
- Generate and regenerate the whole dbml file. Generate the dbml file for an entire database, then regenerate it as the schema changes. Regeneration preserves your customizations, such as entity, property and relationship names. With the designer, a database change means you drop the entity and add it again to pick up new columns or data type changes, which loses your customizations. The templates also exclude unwanted tables, stored procedures and views with filter expressions, and clean prefixes and suffixes from entity and property names (for example,
tbl_CustomerbecomesCustomer). - A business rules engine. Enforce property length, required field and regular expression rules, several other built-in rules, and authorization rules, all with metadata attributes.
SubmitChangeson the data context runs the rules against every entity in the change set. If a rule is broken, it throws aBrokenRulesExceptionthat lists the broken rules. - Manager classes. A manager class for each entity encapsulates the actions taken on that entity. Common actions, such as retrieving entities by primary key, index and foreign key, are generated, and the custom actions you add are preserved when you regenerate. LINQ makes it easy to scatter data access logic throughout an application; the manager classes keep it in one place.