Asignar un método CLR a una función canónicaCLR Method to Canonical Function Mapping

Entity Framework proporciona un conjunto de funciones canónicas que implementan funcionalidad que es común en muchos sistemas de base de datos, como la manipulación de cadenas y las funciones matemáticas.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. Esto permite a los programadores dirigir sus conocimientos a un amplio intervalo de sistemas de base de datos.This enables developers to target a broad range of database systems. Cuando se invocan desde una tecnología de creación de consultas, como LINQ to Entities, estas funciones canónicas se convierten en la correspondiente función de almacenamiento correcta para ser utilizada por el proveedor.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. Esto permite que las llamadas a funciones se expresen de forma común en los orígenes de datos, proporcionando una experiencia de consultas coherente en los citados orígenes de datos.This allows function invocations to be expressed in a common form across data sources, providing a consistent query experience across data sources. Los operadores bit a bit AND, OR, NOT y XOR también se asignan a funciones canónicas cuando el operando es un tipo numérico.The bitwise AND, OR, NOT, and XOR operators are also mapped to canonical functions when the operand is a numeric type. En el caso de operandos booleanos, los operadores bit a bit AND, OR, NOT y XOR calculan las operaciones lógicas AND, OR, NOT y XOR de sus operandos.For Boolean operands, the bitwise AND, OR, NOT, and XOR operators compute the logical AND, OR, NOT, and XOR operations of their operands. Para obtener más información, consulte funciones canónicas.For more information, see Canonical Functions.

En los escenarios LINQ, las consultas en Entity Framework implican la asignación de ciertos métodos de CLR a métodos en el origen de datos subyacente a través de funciones canónicas.For LINQ scenarios, queries against the Entity Framework involve mapping certain CLR methods to methods on the underlying data source through canonical functions. Las llamadas a métodos en una consulta en LINQ to Entities no asignadas explícitamente a una función canónica harán que se lance una excepción NotSupportedException en tiempo de ejecución.Any method calls in a LINQ to Entities query that are not explicitly mapped to a canonical function will result in a runtime NotSupportedException exception being thrown.

Asignación del método System.String (estático)System.String Method (Static) Mapping

Método System.String (estático)System.String method (static) Función canónicaCanonical 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) = (operador)= 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) = (operador)= operator
Boolean op_Inequality(String a , String b)Boolean op_Inequality(String a , String b) != (operador)!= 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)

Asignación del método System.String (instancia)System.String Method (Instance) Mapping

Método System.String (instancia)System.String method (instance) Función canónicaCanonical function NotasNotes
Boolean Contains(String value)Boolean Contains(String value) this LIKE '%value%'this LIKE '%value%' Si value no es una constante, entonces asigna a IndexOf (this, value) > 0If value is not a constant, then this maps to IndexOf(this, value) > 0
Boolean EndsWith(String value)Boolean EndsWith(String value) this AL IGUAL QUE ' % value'this LIKE '%value' Si value no es una constante, entonces asigna a Right(this, length(value)) = value.If 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%' Si value no es una constante, entonces asigna a 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 (subcadena (this, 1, startIndex), subcadena (this, startIndex + count + 1, longitud (this)-(startIndex + count)))Concat(Substring(this, 1, startIndex) , Substring(this, startIndex + count +1, Length(this) - (startIndex + count))) Remove(startIndex, count) solo es compatible si count es un número entero mayor o igual que 0.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 (this, startIndex + 1, length)Substring(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) = (operador)= operator

Asignación del método System.DateTime (estático)System.DateTime Method (Static) Mapping

Método System.DateTime (estático)System.DateTime method (static) Función canónicaCanonical function NotasNotes
Boolean Equals(DateTime t1, DateTime t2)Boolean Equals(DateTime t1, DateTime t2) = (operador)= 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) = (operador)= operator
Boolean op_GreaterThan(DateTime t1, DateTime t2)Boolean op_GreaterThan(DateTime t1, DateTime t2) > (operador)> operator
Boolean op_GreaterThanOrEqual(DateTime t1, DateTime t2)Boolean op_GreaterThanOrEqual(DateTime t1, DateTime t2) > = (operador)>= operator
Boolean op_Inequality(DateTime t1, DateTime t2)Boolean op_Inequality(DateTime t1, DateTime t2) != (operador)!= operator
Booleano op_LessThan (fecha y hora t1, fecha y hora t2)Boolean op_LessThan(DateTime t1, DateTime t2) < (operador)< operator
Boolean op_LessThanOrEqual(DateTime t1, DateTime t2)Boolean op_LessThanOrEqual(DateTime t1, DateTime t2) < = (operador)<= operator
Microsoft.VisualBasic.DateAndTime.DatePart( _Microsoft.VisualBasic.DateAndTime.DatePart( _

ByVal Interval como DateInterval, _ByVal Interval As DateInterval, _

ByVal DateValue como DateTime, _ByVal DateValue As DateTime, _

ByVal opcional FirstDayOfWeekValue como FirstDayOfWeek = VbSunday, _Optional ByVal FirstDayOfWeekValue As FirstDayOfWeek = VbSunday, _

ByVal opcional FirstWeekOfYearValue como FirstWeekOfYear = VbFirstJan1 _Optional ByVal FirstWeekOfYearValue As FirstWeekOfYear = VbFirstJan1 _

) As Integer) As Integer
Para obtener más información, consulte la sección Función DatePart.See the DatePart Function section for more information.
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()

Asignación del método System.DateTime (instancia)System.DateTime Method (Instance) Mapping

Método System.DateTime (instancia)System.DateTime method (instance) Función canónicaCanonical function
Boolean Equals(DateTime value)Boolean Equals(DateTime value) = (operador)= operator
DayDay Day(this)Day(this)
HourHour Hour(this)Hour(this)
MillisecondMillisecond Millisecond(this)Millisecond(this)
MinuteMinute Minute(this)Minute(this)
MesMonth Month(this)Month(this)
SecondSecond Second(this)Second(this)
AñoYear Year(this)Year(this)

Asignación del método System.DateTimeOffset (instancia)System.DateTimeOffset Method (Instance) Mapping

La asignación mostrada para los métodos get sobre las propiedades enumeradas.The mapping shown for the get methods on the listed properties.

Método System.DateTimeOffset (instancia)System.DateTimeOffset method (instance) Función canónicaCanonical function NotasNotes
DayDay Day(this)Day(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
HourHour Hour(this)Hour(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
MillisecondMillisecond Millisecond(this)Millisecond(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
MinuteMinute Minute(this)Minute(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
MesMonth Month(this)Month(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
SecondSecond Second(this)Second(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
AñoYear Year(this)Year(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.

Nota

El método Equals devuelve true si los objetos DateTimeOffset comparados son iguales; de lo contrario, devuelve false.The Equals method returns true if the compared DateTimeOffset objects are equal; false otherwise. El método CompareTo devuelve 0, 1 o -1 dependiendo de si el objeto DateTimeOffset comparado es igual, mayor que, o menor que, respectivamente.The CompareTo method returns 0, 1, or -1 depending on whether the compared DateTimeOffset object is equal, greater than, or less than, respectively.

Asignación del método System.DateTimeOffset (estático)System.DateTimeOffset Method (Static) Mapping

La asignación mostrada para los métodos get sobre las propiedades enumeradas.The mapping shown for the get methods on the listed properties.

Método System.DateTimeOffset (estático)System.DateTimeOffset method (static) Función canónicaCanonical function NotasNotes
System.DateTimeOffset.Now()System.DateTimeOffset.Now() CurrentDateTimeOffset()CurrentDateTimeOffset() No se admite en SQL Server 2005.Not supported against SQL Server 2005.

Asignación del método System.TimeSpan (instancia)System.TimeSpan Method (Instance) Mapping

La asignación mostrada para los métodos get sobre las propiedades enumeradas.The mapping shown for the get methods on the listed properties.

Método System.TimeSpan (instancia)System.TimeSpan method (instance) Función canónicaCanonical function NotasNotes
HorasHours Hour(this)Hour(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
MillisecondsMilliseconds Millisecond(this)Millisecond(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
MinutosMinutes Minute(this)Minute(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.
SecondsSeconds Second(this)Second(this) No se admite en SQL Server 2005.Not supported against SQL Server 2005.

Nota

El método Equals devuelve true si los objetos TimeSpan comparados son iguales; de lo contrario, devuelve false.The Equals method returns true if the compared TimeSpan objects are equal; false otherwise. El método CompareTo devuelve 0, 1 o -1 dependiendo de si el objeto TimeSpan comparado es igual, mayor que, o menor que, respectivamente.The CompareTo method returns 0, 1, or -1 depending on whether the compared TimeSpan object is equal, greater than, or less than, respectively.

Función DatePartDatePart Function

La función DatePart está asignada a una función canónica de entre un grupo, según el valor de Interval.The DatePart Function is mapped to one of several different canonical functions, depending on the value of Interval. En la tabla siguiente, se muestra la asignación de la función canónica para los valores compatibles de Interval:The following table displays the canonical function mapping for the supported values of Interval:

Valor del intervaloInterval value Función canónicaCanonical function
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()

Asignación de funciones matemáticasMathematical Function Mapping

Método CLRCLR method Función canónicaCanonical 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(valor Double, dígitos Int16)System.Math.Round(Double value, Int16 digits) Round(valor, dígitos)Round(value, digits)
System.Math.Round(valor Double, dígitos Int32)System.Math.Round(Double value, Int32 digits) Round(valor, dígitos)Round(value, digits)
System.Math.Round(valor decimal, dígitos Int16)System.Math.Round(Decimal value, Int16 digits) Round(valor, dígitos)Round(value, digits)
System.Math.Round(valor decimal, dígitos Int32)System.Math.Round(Decimal value, Int32, digits) Round(valor, dígitos)Round(value, digits)
System.Math.Abs(valor Int16)System.Math.Abs(Int16 value) Abs(valor)Abs(value)
System.Math.Abs(valor Int32)System.Math.Abs(Int32 value) Abs(valor)Abs(value)
System.Math.Abs(valor Int64)System.Math.Abs(Int64 value) Abs(valor)Abs(value)
System.Math.Abs(valor Byte)System.Math.Abs(Byte value) Abs(valor)Abs(value)
System.Math.Abs(valor Single)System.Math.Abs(Single value) Abs(valor)Abs(value)
System.Math.Abs(valor Double)System.Math.Abs(Double value) Abs(valor)Abs(value)
System.Math.Abs(valor decimal)System.Math.Abs(Decimal value) Abs(valor)Abs(value)
System.Math.Truncate(valor Double, dígitos Int16)System.Math.Truncate(Double value, Int16 digits) Truncate(valor, dígitos)Truncate(value, digits)
System.Math.Truncate(valor Double, dígitos Int32)System.Math.Truncate(Double value, Int32 digits) Truncate(valor, dígitos)Truncate(value, digits)
System.Math.Truncate(valor Decimal, dígitos Int16)System.Math.Truncate(Decimal value, Int16 digits) Truncate(valor, dígitos)Truncate(value, digits)
System.Math.Truncate(valor Decimal, dígitos Int32)System.Math.Truncate(Decimal value, Int32 digits) Truncate(valor, dígitos)Truncate(value, digits)
System.Math.Power(valor Int32, exponente Int64)System.Math.Power(Int32 value, Int64 exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Int32, exponente Double)System.Math.Power(Int32 value, Double exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Int32, exponente Decimal)System.Math.Power(Int32 value, Decimal exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Int64, exponente Int64)System.Math.Power(Int64 value, Int64 exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Int64, exponente Double)System.Math.Power(Int64 value, Double exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Int64, exponente Decimal)System.Math.Power(Int64 value, Decimal exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Double, exponente Int64)System.Math.Power(Double value, Int64 exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Double, exponente Double)System.Math.Power(Double value, Double exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Double, exponente Decimal)System.Math.Power(Double value, Decimal exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Decimal, exponente Int64)System.Math.Power(Decimal value, Int64 exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Decimal, exponente Double)System.Math.Power(Decimal value, Double exponent) Power(valor, exponente)Power(value, exponent)
System.Math.Power(valor Decimal, exponente Decimal)System.Math.Power(Decimal value, Decimal exponent) Power(valor, exponente)Power(value, exponent)

Asignación de operadores bit a bitBitwise Operator Mapping

Operador bit a bitBitwise operator Función canónica para operandos no booleanosCanonical function for non-Boolean operands Función canónica para operandos booleanosCanonical function for Boolean operands
Operador AND bit a bitBitwise AND operator BitWiseAndBitWiseAnd op1 AND op2op1 AND op2
Operador OR bit a bitBitwise OR operator BitWiseOrBitWiseOr op1 OR op2op1 OR op2
Operador NOT bit a bitBitwise NOT operator BitWiseNotBitWiseNot NOT(op)NOT(op)
Operador XOR bit a bitBitwise XOR operator BitWiseXorBitWiseXor ((op1 AND NOT(op2)) OR (NOT(op1) AND op2))((op1 AND NOT(op2)) OR (NOT(op1) AND op2))

Otra asignaciónOther Mapping

MétodoMethod Función canónicaCanonical function
Guid.NewGuid ()Guid.NewGuid() NewGuid()NewGuid()

Vea tambiénSee also