Funzioni canoniche String (Entity SQL)

Entity SQL include funzioni canoniche string.

Osservazioni

Nella tabella seguente sono illustrate le funzioni canoniche string Entity SQL.

Funzione Descrizione

Concat (string1, string2)

Restituisce una stringa che contiene l'oggetto string2 aggiunto a string1.

Argomenti

Tipo String.

Valore restituito

Tipo String. Se la lunghezza della stringa del valore restituito è superiore alla lunghezza massima consentita, si verificherà un errore.

Esempio

-- The following example returns abcxyz.

Concat('abc', 'xyz')

IndexOf(string1, string2)

Restituisce la posizione dell'oggetto string1 in string2o 0 se non viene trovato. Restituisce 1 per indicare l'inizio della stringa. La numerazione dell'indice inizia da 1.

Argomenti

Tipo String.

Valore restituito

Tipo Int32.

Esempio

-- The following example returns 4.

IndexOf('xyz', 'abcxyz')

Left (string, length)

Restituisce i primi caratteri length dal lato sinistro di string. Se la lunghezza di string è inferiore a length, viene restituita la stringa intera.

Argomenti

string: valore String.

length: tipo Int16, Int32, Int64 e Byte. length non può essere inferiore a zero.

Valore restituito

Tipo String.

Esempio

-- The following example returns abc.

Left('abcxyz', 3)

Length (string)

Restituisce la lunghezza (Int32), espressa in caratteri, della stringa.

Argomenti

string: tipo String.

Valore restituito

Tipo Int32.

Esempio

-- The following example returns 6.

Legth('abcxyz')

LTrim(string)

Restituisce string senza spazi iniziali.

Argomenti

Tipo String.

Valore restituito

Tipo String.

Esempio

-- The following example returns abc.

LTrim(' abc')

Replace (string1, string2, string3)

Restituisce string1, con tutte le occorrenze di string2 sostituite da string3.

Argomenti

Tipo String.

Valore restituito

Tipo String.

Esempio

-- The following example returns abcxyz.

Concat('abc', 'xyz')

Reverse (string)

Restituisce string con l'ordine dei caratteri invertito.

Argomenti

Tipo String.

Valore restituito

Tipo String.

Esempio

-- The following example returns dcba.

Reverse('abcd')

Right (string, length)

Restituisce gli ultimi caratteri length di string. Se la lunghezza di string è inferiore a length, viene restituita la stringa intera.

Argomenti

string: tipo String.

length: tipo Int16, Int32, Int64 e Byte. length non può essere inferiore a zero.

Valore restituito

Tipo String.

Esempio

-- The following example returns xyz.

Right('abcxyz', 3)

RTrim(string)

Restituisce string senza spazi finali.

Argomenti

Tipo String.

Valore restituito

Tipo String.

Substring (string, start, length)

Restituisce la sottostringa della stringa che inizia nella posizione start, con una lunghezza di length caratteri. Il valore iniziale 1 indica il primo carattere della stringa. La numerazione dell'indice inizia da 1.

Argomenti

string: tipo String.

start: tipo Int16, Int32, Int64 e Byte. start non può essere inferiore a uno.

length: tipo Int16, Int32, Int64 e Byte. length non può essere inferiore a zero.

Valore restituito

Tipo String.

Esempio

-- The following example returns xyz.

Substring('abcxyz', 4, 3)

ToLower(string)

Restituisce string con tutti i caratteri maiuscoli convertiti in caratteri minuscoli.

Argomenti

Tipo String.

Valore restituito

Tipo String.

Esempio

-- The following example returns abc.

ToLower('ABC')

ToUpper(string)

Restituisce string con i caratteri minuscoli convertiti in caratteri maiuscoli.

Argomenti

Tipo String.

Valore restituito

Tipo String.

Esempio

-- The following example returns ABC.

ToUpper('abc')

Trim(string)

Restituisce string senza spazi finali e iniziali.

Argomenti

Tipo String.

Valore restituito

Tipo String.

Esempio

-- The following example returns abc.

Trim(' abc ')

Queste funzioni restituiscono Null se l'input è Null.

Una funzionalità equivalente è disponibile nel provider gestito del client Microsoft SQL. Per ulteriori informazioni, vedere .Provider di dati .NET Framework per SQL Server (SqlClient) per le funzioni di Entity Framework.

Vedere anche

Concetti

Funzioni canoniche (Entity SQL)