Entity Inheritance

WCF RIA Services

Inheritance Implemented

WCF RIA Services provides a pattern for writing application logic in methods that are members of a DomainService class. Developers write query methods to return entities and Create, Update, Delete (CUD) methods to change entities. The current preview extends this capability to inheritance hierarchies of entities. Developers can write query methods that returns an entity of a specified type or a more derived type. Likewise, they can write CUD methods that operate on a specific or more derived entity types. Such methods are also called polymorphic methods.

Many Data Access Layers (DALs) such as LINQ to SQL, nhibernate, LINQ to Entities support inheritance among the entities mapped to database tables. Likewise, users may author classes that are in an inheritance hierarchy and use such classes in DomainService operations.

Let us consider an example of an inheritance hierarchy and the corresponding DomainService methods. We will explore the generated code and its usage as well.

Example

Basic Inheritance Hierarchy

Consider the following hierarchy for Customer entity.

Figure 1: Basic Customer Inheritance Hierarchy

Such a hierarchy may be a part of DAL-generated classes or hand-coded classes. In either case, a developer can use these classes for authoring DomainService methods. Consider the object model shown below:


Post a Comment