11 The Sybase Entity Framework Data Provider : Mapping Data Types and Functions

Mapping Data Types and Functions
Mapping Sybase Data Types to Simple Types
In Table 11-7, the columns are defined as follows:
Table 11-8 shows the mapping of EDM Simple Types to Sybase data types. The columns are defined as follows:
Mapping EDM Canonical Functions to Sybase Functions
The ADO.NET Entity Framework translates the Entity Data Model (EDM) canonical functions to the corresponding data source functionality for the ADO.NET Sybase 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 11-9 describes the mapping of EDM aggregate canonical functions to Sybase functions.
Avg(expression)
AVG(expression)
BigCount(expression)
COUNT_BIG(expression)
Count(expression)
COUNT(expression)
Max(expression)
MAX(expression)
Min(expression)
MIN(expression)
StDev(expression)
STDEV_SAMP(expression)
Sum(expression)
SUM(expression)
Math Canonical Functions
Table 11-10 describes the mapping of EDM math canonical functions to Sybase functions.
Abs(value)
ABS(value)
Ceiling(value)
CEILING(value)
Floor(value)
FLOOR(value)
Round(value)
ROUND(value, 0)
Round(value, digits)
ROUND(value, 0)
Date and Time Canonical Functions
Table 11-11 describes the mapping of EDM date and time canonical functions to Sybase functions.
Day(expression)
DAY(expression)
GetTotalOffsetMinutes(DateTimeOffset)
Hour(expression)
DATEPART(HOUR, expression)
Millisecond(expression)
Minute(expression)
Month(expression)
MONTH(expression)
Second(expression)
Year(expression)
YEAR(expression)
Bitwise Canonical Functions
Table 11-12 describes the mapping of EDM bitwise canonical functions to Sybase functions.
BitWiseAnd (value1, value2)
(value1 & value2)
(~value)
BitWiseOr (value1, value2)
(value1 | value2)
BitWiseXor (value1, value2)
(value1 ^ value2)
String Canonical Functions
Table 11-13 describes the mapping of EDM string canonical functions to Sybase functions.
Concat(string1, string2)
(string1 || string2)
IndexOf(target, string)
CHARINDEX(target, string)
Left(string, length)
LEFT(string)
Length(string)
LEN(string)
LTrim(string)
LTRIM(string)
Replace(string1, string2, string3)
STR_REPLACE(string1, string2, string3)
Reverse(string)
REVERSE(string)
Right(string, length)
RIGHT(string, length)
RTrim(string)
RTRIM(string)
Substring(string, start, length)
SUBSTRING(string, start, length)
ToLower(string)
LOWER(string)
ToUpper(string)
UPPER(string)
Trim(string)
LTRIM(RTRIM(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. In other words, the Entity Framework data provider simply passes the function call to the database server as is. For example, Sybase does not support features that rely on DateTimeOffset. To provide that functionality, you can create a custom function of the same name on the database that the data provider can call.