共用方式為


CLR 方法與標準函式的對應

某些 CLR 方法會轉換成命令樹標準函式,這些函式可以在資料庫上執行。如果 CLR 方法無法對應到命令樹標準函式,當發生轉譯時將會擲回例外狀況。

System.String 方法 (靜態) 對應

System.String 方法 (靜態) 標準函式

System.String Concat(String str0, String str1)

Concat(str0, str1)

System.String Concat(String str0, String str1, String str2)

Concat(Concat(str0, str1), str2)

System.String Concat(String str0, String str1, String str2, String str03)

Concat(Concat(Concat(str0, str1), str2), str3)

Boolean Equals(String a, String b)

= 運算子

Boolean IsNullOrEmpty(String value)

(IsNull(value)) OR Length(value) = 0

Boolean op_Equality(String a, String b)

= 運算子

Boolean op_Inequality(String a , String b)

!= 運算子

Microsoft.VisualBasic.Strings.Trim(String str)

Trim(str)

Microsoft.VisualBasic.Strings.LTrim(String str)

Ltrim(str)

Microsoft.VisualBasic.Strings.RTrim(String str)

Rtrim(str)

Microsoft.VisualBasic.Strings.Len(String expression)

Length(expression)

Microsoft.VisualBasic.Strings.Left(String str, Int32 Length)

Left(str, Length)

Microsoft.VisualBasic.Strings.Mid(String str, Int32 Start, Int32 Length)

Substring(str, Start, Length)

Microsoft.VisualBasic.Strings.Right(String str, Int32 Length)

Right(str, Length)

Microsoft.VisualBasic.Strings.UCase(String Value)

ToUpper(Value)

Microsoft.VisualBasic.Strings.LCase(String Value)

ToLower(Value)

System.String 方法 (執行個體) 對應

System.String 方法 (執行個體) 標準函式 附註

Boolean Contains(String value)

IndexOf(this, value) > 0

Boolean EndsWith(String value)

Right(this, length(value)) = value

Boolean StartsWith(String value)

IndexOf(this, value) = 1

Int32 get_Length()

Length(this)

Int32 IndexOf(String value)

IndexOf(this, value) - 1

System.String Insert(Int32 startIndex, String value)

Concat(Concat(Substring(this, 1, startIndex), value), Substring(this, startIndex+1, Length(this) - startIndex))

System.String Remove(Int32 startIndex)

Substring(this, 1, startIndex)

System.String Remove(Int32 startIndex, Int32 count)

Concat(Substring(this, 1, startIndex) , Substring(this, startIndex + count +1, Length(this) - (startIndex + count)))

只有當 count 是大於或等於 0 的整數時,才支援 Remove(startIndex, count)。

System.String Replace(String oldValue, String newValue)

Replace(this, oldValue, newValue)

System.String Substring(Int32 startIndex)

Substring(this, startIndex +1, Length(this) - startIndex)

System.String Substring(Int32 startIndex, Int32 length)

Substring(this, startIndex +1, length)

System.String ToLower()

ToLower(this)

System.String ToUpper()

ToUpper(this)

System.String Trim()

Trim(this)

System.String TrimEnd(Char[] trimChars)

RTrim(this)

System.String TrimStart(Char[]trimChars)

LTrim(this)

Boolean Equals(String value)

= 運算子

System.DateTime 方法 (靜態) 對應

System.DateTime 方法 (靜態) 標準函式 附註

Boolean Equals(DateTime t1, DateTime t2)

= 運算子

System.DateTime get_Now()

CurrentDateTime()

System.DateTime get_UtcNow()

CurrentUtcDateTime()

Boolean op_Equality(DateTime d1, DateTime d2)

= 運算子

Boolean op_GreaterThan(DateTime t1, DateTime t2)

> 運算子

Boolean op_GreaterThanOrEqual(DateTime t1, DateTime t2)

>= 運算子

Boolean op_Inequality(DateTime t1, DateTime t2)

!= 運算子

Boolean op_LessThan(DateTime t1, DateTime t2)

< 運算子

Boolean op_LessThanOrEqual(DateTime t1, DateTime t2)

<= 運算子

Microsoft.VisualBasic.DateAndTime.DatePart( _

ByVal Interval As DateInterval, _

ByVal DateValue As DateTime, _

Optional ByVal FirstDayOfWeekValue As FirstDayOfWeek = VbSunday, _

Optional ByVal FirstWeekOfYearValue As FirstWeekOfYear = VbFirstJan1 _

) As Integer

如需詳細資訊,請參閱「DatePart 函式」一節。

Microsoft.VisualBasic.DateAndTime.Now

CurrentDateTime()

Microsoft.VisualBasic.DateAndTime.Year(DateTime TimeValue)

Year()

Microsoft.VisualBasic.DateAndTime.Month(DateTime TimeValue)

Month()

Microsoft.VisualBasic.DateAndTime.Day(DateTime TimeValue)

Day()

Microsoft.VisualBasic.DateAndTime.Hour(DateTime TimeValue)

Hour()

Microsoft.VisualBasic.DateAndTime.Minute(DateTime TimeValue)

Minute()

Microsoft.VisualBasic.DateAndTime.Second(DateTime TimeValue)

Second()

System.DateTime 方法 (執行個體) 對應

System.DateTime 方法 (執行個體) 標準函式

Boolean Equals(DateTime value)

= 運算子

Int32 get_Day()

Day(this)

Int32 get_Hour()

Hour(this)

Int32 get_Millisecond()

Millisecond(this)

Int32 get_Minute()

Minute(this)

Int32 get_Month()

Month(this)

Int32 get_Second()

Second(this)

Int32 get_Year()

Year(this)

System.DateTimeOffset 方法 (執行個體) 對應

System.DateTimeOffset 方法 (執行個體) 標準函式 附註

Int32 get_Day()

Day(this)

對 SQL Server 2005 不支援。

Int32 get_Hour()

Hour(this)

對 SQL Server 2005 不支援。

Int32 get_Millisecond()

Millisecond(this)

對 SQL Server 2005 不支援。

Int32 get_Minute()

Minute(this)

對 SQL Server 2005 不支援。

Int32 get_Month()

Month(this)

對 SQL Server 2005 不支援。

Int32 get_Second()

Second(this)

對 SQL Server 2005 不支援。

Int32 get_Year()

Year(this)

對 SQL Server 2005 不支援。

System.DateTimeOffset 方法 (靜態) 對應

System.DateTimeOffset 方法 (靜態) 標準函式 附註

System.DateTimeOffset get_Now()

CurrentDateTimeOffset()

對 SQL Server 2005 不支援。

System.TimeSpan 方法 (執行個體) 對應

System.TimeSpan 方法 (執行個體) 標準函式 附註

Int32 get_Hours()

Hour(this)

對 SQL Server 2005 不支援。

Int32 get_Milliseconds()

Millisecond(this)

對 SQL Server 2005 不支援。

Int32 get_Minutes()

Minute(this)

對 SQL Server 2005 不支援。

Int32 get_Seconds()

Second(this)

對 SQL Server 2005 不支援。

DatePart 函式

DatePart 函式會對應到幾個不同標準函式的其中一個,根據 Interval 的值而定。下表顯示支援之 Interval 值的標準函式對應:

間隔值 標準函式

DateInterval.Year

Year()

DateInterval.Month

Month()

DateInterval.Day

Day()

DateInterval.Hour

Hour()

DateInterval.Minute

Minute()

DateInterval.Second

Second()

數學函式對應

CLR 方法 標準函式

System.Decimal.Ceiling(Decimal d)

Ceiling(d)

System.Decimal.Floor(Decimal d)

Floor(d)

System.Decimal.Round(Decimal d)

Round(d)

System.Math.Ceiling(Decimal d)

Ceiling(d)

System.Math.Floor(Decimal d)

Floor(d)

System.Math.Round(Decimal d)

Round(d)

System.Math.Ceiling(Double a)

Ceiling(a)

System.Math.Floor(Double a)

Floor(a)

System.Math.Round(Double a)

Round(a)

位元運算子對應

位元運算子 非布林運算元的標準函式 布林運算元的標準函式

位元 AND 運算子

BitWiseAnd

op1 AND op2

位元 OR 運算子

BitWiseOr

op1 OR op2

位元 NOT 運算子

BitWiseNot

NOT(op)

位元 XOR 運算子

BitWiseXor

((op1 AND NOT(op2)) OR (NOT(op1) AND op2))

另請參閱

其他資源

參考 (LINQ to Entities)