6 The DB2 Entity Framework Data Provider : Mapping Data Types and Functions

Mapping Data Types and Functions
Mapping DB2 Data Types to Simple Types
In Table 6-7, the columns are defined as follows:
 

1
Always cast as a TimeStamp.

Table 6-8 shows the mapping of EDM Simple Types to DB2 data types. The columns are defined as follows:
 

1
Always cast as a TimeStamp.

2
A DateTimeOffset value is always inserted in the database as UTC.

Mapping EDM Canonical Functions to DB2 Functions
The ADO.NET Entity Framework translates the Entity Data Model (EDM) canonical functions to the corresponding data source functionality for the ADO.NET DB2 Entity data provider. The function invocations are expressed in a common form across data sources.
Because these canonical functions are independent of data sources, argument and return types of canonical functions are defined in terms of types in the EDM. When an Entity SQL query uses canonical functions, the appropriate function is called at the data source.
Both null-input behavior and error conditions are explicitly specified for all canonical functions. However, the ADO.NET Entity Framework does not enforce this behavior. Further details are available at:
http://msdn.microsoft.com/en-us/library/bb738626.aspx
Aggregate Canonical Functions
Table 6-9 describes the mapping of EDM aggregate canonical functions to DB2 functions.
Avg(expression)
avg(expression)
BigCount(expression)
count_big(expression)
Count(expression)
count(expression)
Max(expression)
max(expression)
Min(expression)
min(expression)
StDev(expression)
stddev(expression)
Sum(expression)
sum(expression)
Date and Time Canonical Functions
Table 6-10 describes the mapping of EDM date and time canonical functions to DB2 functions.
Year(expression)
Year(expression)
Month(expression)
Month(expression)
Day(expression)
Day(expression)
Hour(expression)
Hour(expression)
Minute(expression)
Minute(expression)
Second(expression)
Second(expression)
Millisecond(expression)
GetTotalOffsetMinutes(DateTime Offset)
Math Canonical Functions
Table 6-11 describes the mapping of EDM math canonical functions to DB2 functions.
Abs(value)
abs(value)
Ceiling(value)
ceiling(value)
Floor(value)
floor(value)
Round(value)
round(value)
String Canonical Functions
Table 6-12 describes the mapping of EDM string canonical functions to DB2 functions.
Concat(string1, string2)
concat(string1, string2)
IndexOf(target, string2)
position(target, string2)
Left(string1, length)
left(string1, length)
Length(string)
length(string)
LTrim(string)
ltrim(string)
Replace(string1, string2, string3)
replace(string1, string2, string3)
Reverse(string)
Right(string1, length)
right(string1, length)
RTrim(string)
rtrim(string)
Substring(string, start, length)
Substring(string, start, length)
ToLower(string)
lower(string)
ToUpper(string)
upper(string)
Trim(string)
Handling Unsupported Canonical Functions
Because some canonical functions are not supported on the underlying database, the Entity Framework data provider allows the function call to "fall through" to the database. For example, DB2 does not support REVERSE(). To provide that functionality, you can create a custom function of the same name on the database that the data provider can call.