# 標準函式的對應 CLR 方法CLR Method to Canonical Function Mapping

Entity Framework 提供一組標準函式，可實作在許多資料庫系統常見的功能，例如字串操作和數學函式。The Entity Framework provides a set of canonical functions that implement functionality that is common across many database systems, such as string manipulation and mathematical functions. 這樣就可以讓開發人員以廣泛的資料庫系統為相標。This enables developers to target a broad range of database systems. 從某種查詢技術 (例如 LINQ to Entities) 呼叫時，這些標準函式會轉譯成所使用之提供者的正確對應存放函式。When called from a querying technology, such as LINQ to Entities, these canonical functions are translated to the correct corresponding store function for the provider being used. 這樣就可以利用跨資料來源的通用形式來表示函式引動過程，在不同的資料來源提供一致的查詢體驗。This allows function invocations to be expressed in a common form across data sources, providing a consistent query experience across data sources. 如果運算元為數值型別，位元運算 AND、OR,、NOT 和 XOR 運算子也是對應到這些標準函式。The bitwise AND, OR, NOT, and XOR operators are also mapped to canonical functions when the operand is a numeric type. 若為布林運算元，位元運算 AND、OR、NOT 和 XOR 運算子會計算這些運算元的邏輯 AND、OR、NOT 和 XOR 運算。For Boolean operands, the bitwise AND, OR, NOT, and XOR operators compute the logical AND, OR, NOT, and XOR operations of their operands. 如需詳細資訊，請參閱標準函式。For more information, see Canonical Functions.

## System.String 方法 (靜態) 對應System.String Method (Static) Mapping

System.String 方法 (靜態)System.String method (static) 標準函式Canonical function
System.String Concat(String str0, String str1)System.String Concat(String str0, String str1) Concat(str0, str1)Concat(str0, str1)
System.String Concat(String str0, String str1, String str2)System.String Concat(String str0, String str1, String str2) Concat(Concat(str0, str1), str2)Concat(Concat(str0, str1), str2)
System.String Concat(String str0, String str1, String str2, String str03)System.String Concat(String str0, String str1, String str2, String str03) Concat(Concat(Concat(str0, str1), str2), str3)Concat(Concat(Concat(str0, str1), str2), str3)
Boolean Equals(String a, String b)Boolean Equals(String a, String b) = 運算子= operator
Boolean IsNullOrEmpty(String value)Boolean IsNullOrEmpty(String value) (IsNull(value)) OR Length(value) = 0(IsNull(value)) OR Length(value) = 0
Boolean op_Equality(String a, String b)Boolean op_Equality(String a, String b) = 運算子= operator
Boolean op_Inequality(String a , String b)Boolean op_Inequality(String a , String b) != 運算子!= operator
Microsoft.VisualBasic.Strings.Trim(String str)Microsoft.VisualBasic.Strings.Trim(String str) Trim(str)Trim(str)
Microsoft.VisualBasic.Strings.LTrim(String str)Microsoft.VisualBasic.Strings.LTrim(String str) Ltrim(str)Ltrim(str)
Microsoft.VisualBasic.Strings.RTrim(String str)Microsoft.VisualBasic.Strings.RTrim(String str) Rtrim(str)Rtrim(str)
Microsoft.VisualBasic.Strings.Len(String expression)Microsoft.VisualBasic.Strings.Len(String expression) Length(expression)Length(expression)
Microsoft.VisualBasic.Strings.Left(String str, Int32 Length)Microsoft.VisualBasic.Strings.Left(String str, Int32 Length) Left(str, Length)Left(str, Length)
Microsoft.VisualBasic.Strings.Mid(String str, Int32 Start, Int32 Length)Microsoft.VisualBasic.Strings.Mid(String str, Int32 Start, Int32 Length) Substring(str, Start, Length)Substring(str, Start, Length)
Microsoft.VisualBasic.Strings.Right(String str, Int32 Length)Microsoft.VisualBasic.Strings.Right(String str, Int32 Length) Right(str, Length)Right(str, Length)
Microsoft.VisualBasic.Strings.UCase(String Value)Microsoft.VisualBasic.Strings.UCase(String Value) ToUpper(Value)ToUpper(Value)
Microsoft.VisualBasic.Strings.LCase(String Value)Microsoft.VisualBasic.Strings.LCase(String Value) ToLower(Value)ToLower(Value)

## System.String 方法 (執行個體) 對應System.String Method (Instance) Mapping

System.String 方法 (執行個體)System.String method (instance) 標準函式Canonical function 注意Notes
Boolean Contains(String value)Boolean Contains(String value) this LIKE '%value%'this LIKE '%value%' 如果value不是常數，則這會對應至 IndexOf （thisvalue） > 0If value is not a constant, then this maps to IndexOf(this, value) > 0
Boolean EndsWith(String value)Boolean EndsWith(String value) thisLIKE ' '% valuethis LIKE '%value' 如果 value 不是一個常數，則這會對應至 Right(this, length(value)) = valueIf value is not a constant, then this maps to Right(this, length(value)) = value.
Boolean StartsWith(String value)Boolean StartsWith(String value) this LIKE 'value%'this LIKE 'value%' 如果 value 不是一個常數，則這會對應至 IndexOf(this, value) = 1。If value is not a constant, then this maps to IndexOf(this, value) = 1.
LengthLength Length(this)Length(this)
Int32 IndexOf(String value)Int32 IndexOf(String value) IndexOf(this, value) - 1IndexOf(this, value) - 1
System.String Insert(Int32 startIndex, String value)System.String Insert(Int32 startIndex, String value) Concat(Concat(Substring(this, 1, startIndex), value), Substring(this, startIndex+1, Length(this) - startIndex))Concat(Concat(Substring(this, 1, startIndex), value), Substring(this, startIndex+1, Length(this) - startIndex))
System.String Remove(Int32 startIndex)System.String Remove(Int32 startIndex) Substring(this, 1, startIndex)Substring(this, 1, startIndex)
System.String Remove(Int32 startIndex, Int32 count)System.String Remove(Int32 startIndex, Int32 count) Concat （substring （this，1， startIndex），substring （thisstartIndex count this count + + 1，Length （）-（startIndex））） + Concat(Substring(this, 1, startIndex) , Substring(this, startIndex + count +1, Length(this) - (startIndex + count))) 只有當 startIndex 是大於或等於 0 的整數時，才支援 Remove(count, count)。Remove(startIndex, count) is only supported if count is an integer greater than or equal to 0.
System.String Replace(String oldValue, String newValue)System.String Replace(String oldValue, String newValue) Replace(this, oldValue, newValue)Replace(this, oldValue, newValue)
System.String Substring(Int32 startIndex)System.String Substring(Int32 startIndex) Substring(this, startIndex +1, Length(this) - startIndex)Substring(this, startIndex +1, Length(this) - startIndex)
System.String Substring(Int32 startIndex, Int32 length)System.String Substring(Int32 startIndex, Int32 length) Substring （thisstartIndex + 1， lengthSubstring(this, startIndex +1, length)
System.String ToLower()System.String ToLower() ToLower(this)ToLower(this)
System.String ToUpper()System.String ToUpper() ToUpper(this)ToUpper(this)
System.String Trim()System.String Trim() Trim(this)Trim(this)
System.String TrimEnd(Char[] trimChars)System.String TrimEnd(Char[] trimChars) RTrim(this)RTrim(this)
System.String TrimStart(Char[]trimChars)System.String TrimStart(Char[]trimChars) LTrim(this)LTrim(this)
Boolean Equals(String value)Boolean Equals(String value) = 運算子= operator

## System.DateTime 方法 (靜態) 對應System.DateTime Method (Static) Mapping

System.DateTime 方法 (靜態)System.DateTime method (static) 標準函式Canonical function 注意Notes
Boolean Equals(DateTime t1, DateTime t2)Boolean Equals(DateTime t1, DateTime t2) = 運算子= operator
System.DateTime.NowSystem.DateTime.Now CurrentDateTime()CurrentDateTime()
System.DateTime.UtcNowSystem.DateTime.UtcNow CurrentUtcDateTime()CurrentUtcDateTime()
Boolean op_Equality(DateTime d1, DateTime d2)Boolean op_Equality(DateTime d1, DateTime d2) = 運算子= operator
Boolean op_GreaterThan(DateTime t1, DateTime t2)Boolean op_GreaterThan(DateTime t1, DateTime t2) > 運算子> operator
Boolean op_GreaterThanOrEqual(DateTime t1, DateTime t2)Boolean op_GreaterThanOrEqual(DateTime t1, DateTime t2) > = 運算子>= operator
Boolean op_Inequality(DateTime t1, DateTime t2)Boolean op_Inequality(DateTime t1, DateTime t2) != 運算子!= operator

Boolean op_LessThanOrEqual(DateTime t1, DateTime t2)Boolean op_LessThanOrEqual(DateTime t1, DateTime t2) < = 運算子<= operator
Microsoft.VisualBasic.DateAndTime.DatePart( _Microsoft.VisualBasic.DateAndTime.DatePart( _

ByVal Interval為 DateInterval，_ByVal Interval As DateInterval, _

ByVal DateValue做為 DateTime，_ByVal DateValue As DateTime, _

) As Integer) As Integer

Microsoft.VisualBasic.DateAndTime.NowMicrosoft.VisualBasic.DateAndTime.Now CurrentDateTime()CurrentDateTime()
Microsoft.VisualBasic.DateAndTime.Year(DateTime TimeValue)Microsoft.VisualBasic.DateAndTime.Year(DateTime TimeValue) Year()Year()
Microsoft.VisualBasic.DateAndTime.Month(DateTime TimeValue)Microsoft.VisualBasic.DateAndTime.Month(DateTime TimeValue) Month()Month()
Microsoft.VisualBasic.DateAndTime.Day(DateTime TimeValue)Microsoft.VisualBasic.DateAndTime.Day(DateTime TimeValue) Day()Day()
Microsoft.VisualBasic.DateAndTime.Hour(DateTime TimeValue)Microsoft.VisualBasic.DateAndTime.Hour(DateTime TimeValue) Hour()Hour()
Microsoft.VisualBasic.DateAndTime.Minute(DateTime TimeValue)Microsoft.VisualBasic.DateAndTime.Minute(DateTime TimeValue) Minute()Minute()
Microsoft.VisualBasic.DateAndTime.Second(DateTime TimeValue)Microsoft.VisualBasic.DateAndTime.Second(DateTime TimeValue) Second()Second()

## System.DateTime 方法 (執行個體) 對應System.DateTime Method (Instance) Mapping

System.DateTime 方法 (執行個體)System.DateTime method (instance) 標準函式Canonical function
Boolean Equals(DateTime value)Boolean Equals(DateTime value) = 運算子= operator
DayDay Day(this)Day(this)
HourHour Hour(this)Hour(this)
MillisecondMillisecond Millisecond(this)Millisecond(this)
MinuteMinute Minute(this)Minute(this)
MonthMonth Month(this)Month(this)

YearYear Year(this)Year(this)

## System.DateTimeOffset 方法 (執行個體) 對應System.DateTimeOffset Method (Instance) Mapping

System.DateTimeOffset 方法 (執行個體)System.DateTimeOffset method (instance) 標準函式Canonical function 注意Notes
DayDay Day(this)Day(this) 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.
HourHour Hour(this)Hour(this) 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.
MillisecondMillisecond Millisecond(this)Millisecond(this) 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.
MinuteMinute Minute(this)Minute(this) 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.
MonthMonth Month(this)Month(this) 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.

YearYear Year(this)Year(this) 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.

## System.DateTimeOffset 方法 (靜態) 對應System.DateTimeOffset Method (Static) Mapping

System.DateTimeOffset 方法 (靜態)System.DateTimeOffset method (static) 標準函式Canonical function 注意Notes
System.DateTimeOffset.Now()System.DateTimeOffset.Now() CurrentDateTimeOffset()CurrentDateTimeOffset() 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.

## System.TimeSpan 方法 (執行個體) 對應System.TimeSpan Method (Instance) Mapping

System.TimeSpan 方法 (執行個體)System.TimeSpan method (instance) 標準函式Canonical function 注意Notes

MillisecondsMilliseconds Millisecond(this)Millisecond(this) 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.

SecondsSeconds Second(this)Second(this) 對 SQL Server 2005 不支援。Not supported against SQL Server 2005.

### DatePart 函式DatePart Function

DatePart 函式會對應到幾個不同標準函式的其中一個，根據 Interval 的值而定。The DatePart Function is mapped to one of several different canonical functions, depending on the value of Interval. 下表顯示支援之 Interval 值的標準函式對應：The following table displays the canonical function mapping for the supported values of Interval:

DateInterval.YearDateInterval.Year Year()Year()
DateInterval.MonthDateInterval.Month Month()Month()
DateInterval.DayDateInterval.Day Day()Day()
DateInterval.HourDateInterval.Hour Hour()Hour()
DateInterval.MinuteDateInterval.Minute Minute()Minute()
DateInterval.SecondDateInterval.Second Second()Second()

## 數學函式對應Mathematical Function Mapping

CLR 方法CLR method 標準函式Canonical function
System.Decimal.Ceiling(Decimal d)System.Decimal.Ceiling(Decimal d) Ceiling(d)Ceiling(d)
System.Decimal.Floor(Decimal d)System.Decimal.Floor(Decimal d) Floor(d)Floor(d)
System.Decimal.Round(Decimal d)System.Decimal.Round(Decimal d) Round(d)Round(d)
System.Math.Ceiling(Decimal d)System.Math.Ceiling(Decimal d) Ceiling(d)Ceiling(d)
System.Math.Floor(Decimal d)System.Math.Floor(Decimal d) Floor(d)Floor(d)
System.Math.Round(Decimal d)System.Math.Round(Decimal d) Round(d)Round(d)
System.Math.Ceiling(Double a)System.Math.Ceiling(Double a) Ceiling(a)Ceiling(a)
System.Math.Floor(Double a)System.Math.Floor(Double a) Floor(a)Floor(a)
System.Math.Round(Double a)System.Math.Round(Double a) Round(a)Round(a)
System.Math.Round(雙精度浮點數值、Int16 數字)System.Math.Round(Double value, Int16 digits) Round(值、數字)Round(value, digits)
System.Math.Round(雙精度浮點數值、Int32 數字)System.Math.Round(Double value, Int32 digits) Round(值、數字)Round(value, digits)
System.Math.Round(十進位值、Int16 數字)System.Math.Round(Decimal value, Int16 digits) Round(值、數字)Round(value, digits)
System.Math.Round(十進位值、Int32 數字)System.Math.Round(Decimal value, Int32, digits) Round(值、數字)Round(value, digits)
System.Math.Abs(Int16 值)System.Math.Abs(Int16 value) Abs(value)Abs(value)
System.Math.Abs(Int32 值)System.Math.Abs(Int32 value) Abs(value)Abs(value)
System.Math.Abs(Int64 值)System.Math.Abs(Int64 value) Abs(value)Abs(value)
System.Math.Abs(位元組值)System.Math.Abs(Byte value) Abs(value)Abs(value)
System.Math.Abs(單一值)System.Math.Abs(Single value) Abs(value)Abs(value)
System.Math.Abs(雙精度浮點數值)System.Math.Abs(Double value) Abs(value)Abs(value)
System.Math.Abs(十進位值)System.Math.Abs(Decimal value) Abs(value)Abs(value)
System.Math.Truncate(雙精度浮點數值、Int16 數字)System.Math.Truncate(Double value, Int16 digits) Truncate(值、數字)Truncate(value, digits)
System.Math.Truncate(雙精度浮點數值、Int32 數字)System.Math.Truncate(Double value, Int32 digits) Truncate(值、數字)Truncate(value, digits)
System.Math.Truncate(十進位值、Int16 數字)System.Math.Truncate(Decimal value, Int16 digits) Truncate(值、數字)Truncate(value, digits)
System.Math.Truncate(十進位值、Int32 數字)System.Math.Truncate(Decimal value, Int32 digits) Truncate(值、數字)Truncate(value, digits)
System.Math.Power(Int32 值、Int64 指數)System.Math.Power(Int32 value, Int64 exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(Int32 值、雙精度浮點指數)System.Math.Power(Int32 value, Double exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(Int32 值、十進位指數)System.Math.Power(Int32 value, Decimal exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(Int64 值、Int64 指數)System.Math.Power(Int64 value, Int64 exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(Int64 值、雙精度浮點指數)System.Math.Power(Int64 value, Double exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(Int64 值、十進位指數)System.Math.Power(Int64 value, Decimal exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(雙精度浮點數值、Int64 指數)System.Math.Power(Double value, Int64 exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(雙精度浮點數值、雙精度浮點指數)System.Math.Power(Double value, Double exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(雙精度浮點數值、十進位指數)System.Math.Power(Double value, Decimal exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(十進位值、Int64 指數)System.Math.Power(Decimal value, Int64 exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(十進位值、雙精度浮點指數)System.Math.Power(Decimal value, Double exponent) Power(值、指數)Power(value, exponent)
System.Math.Power(十進位值、十進位指數)System.Math.Power(Decimal value, Decimal exponent) Power(值、指數)Power(value, exponent)

## 其他對應Other Mapping

Guid.NewGuid()Guid.NewGuid() NewGuid()NewGuid()