LinqConnect fully supports mapping methods to stored procedures and functions. For example we will map the following methods:
| C#csharp | Copy Code |
|---|---|
to the stored function GetPrice(PRODUCT IN VARCHAR2) and stored procedures GetCompany(CompanyName IN VARCHAR2) and GetMultipleResultSets(). GetPrice method returns a scalar value, while GetCompany method returns a collection of Company entities, and GetMultipleResultSets returns three collections: two collections of Company and Order entities, and a collection of AddressType coplex types.
Function, Parameter, and ResultType attributes are used for attribute mapping of methods. See the following tables for their properties' descriptions.
Function Attribute Properties
| Property | Type | Description |
|---|---|---|
| IsComposable | Boolean | Specifies whether a method is mapped to a function (true) or to a stored procedure (false). |
| Name | String | Specifies the name of the function or stored procedure. |
Parameter Attribute Properties
| Property | Type | Description |
|---|---|---|
| DbType | String | Specifies the type of the parameter. |
| Name | String | Specifies the name of the parameter. |
ResultType Attribute Properties
| Property | Type | Description |
|---|---|---|
| Type | System.Type | Specifies the valid or expected type mapping for a function having various result types. |
| Order | System.Int32 | Specifies the ordinal number of returned from function resultset. |
See the example of the attribute mapping below:
| C#csharp | Copy Code | ||
|---|---|---|---|
| |||
| Visual Basic | Copy Code | ||
|---|---|---|---|
| |||
XML mapping of methods uses Function, Parameter, and ElementType tags.
<Function Name="GetPrice" Method="GetPrice" IsComposable="true" > <Parameter Name="PRODUCT" Member="product" DbType="VARCHAR2" /> </Function> <Function Name="GetCompany" Method="GetCompany"> <Parameter Name="CompanyName" Member="companyName" DbType="VARCHAR2" /> <ElementType Name="Company" /> </Function> <Function Name="GetMultipleResultSets" Method="GetMultipleResultSets"> <ElementType Name="Company" /> <ElementType Name="Order" /> <ElementType Type="AddressType" /> </Function> |
Fluent Mapping of methods is not supported.