Complex types and struct objects are data types with internal structure but without Key properties. They are represented as light-green shapes on the diagram. They define a data structure composed of scalar or enum properties or other struct objects.
While Entity Developer works with complex types and struct objects in a similar way, there is a certain differences between them in code generation and how Telerik Data Access allows using them. Struct objects are generated as structures, not classes, in code (with the struct keyword). Complex type are generated as normal classes in code. Only struct object can be used as a type of entity properties and properties of other struct objects. Complex types cannot be used as types of properties. Only complex type can be used as a type of the result of a method, that calls a stored procedure or function, returning one or more resultset. Struct object cannot be used for mapping stored routine result. Entity Developer works with complex types and struct objects in mostly the same way, and in Entity Developer terms both of these categories can be referred as "complex types". They have the Is Struct property, that can be set in the Properties window or in the complex type editor, and this property determines whether this is a struct object or not and how it can be used in the model. In the Model Explorer window, both struct objects and non-struct complex types can be found in the Complex Types node, and they have no visual differences on the diagram. |
The main properties of complex types are:
Complex types that are struct objects enable scalar properties to be organized within entities. The fields of these objects are mapped to the same record in the database table with the fields of the parent entity. You can use complex types for a more precise presentation of the denormalized table structure and for the specific types returned from stored procedures and functions, depending on the Is Struct property value. There are several ways to create a complex type. They are described below. |
Creating a Struct Object from an EntityTo create a struct object from an existing entity, select the properties from this entity and create a complex type based on them. For example, you have the Company entity and want to create a complex type describing Address. For that purpose, perform the following steps:
Creating a Struct Object from Several Entities Using Model Refactoring
|
To create a new complex type perform the following steps:
|
To delete a complex type use one of the following options:
Entity Developer will then ask you whether you want to delete the object from the model too. |
Working with Struct Objects and Complex Types Stored Procedure and Stored Function With Resultset Stored Procedure with Multiple Resultsets External Struct Objects and Complex Types
|