共用方式為


DbFunctions.Left 方法

[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]

用於 LINQ to Entities 查詢時,此方法會叫用標準 EDM 函式 Left 以傳回某字串最左邊指定之數目的字元。

命名空間:  System.Data.Entity
組件:  EntityFramework (在 EntityFramework.dll 中)

語法

'宣告
<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId := "length")> _
<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId := "stringArgument")> _
<SuppressMessageAttribute("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId := "string")> _
<DbFunctionAttribute("Edm", "Left")> _
Public Shared Function Left ( _
    stringArgument As String, _
    length As Nullable(Of Long) _
) As String
'用途
Dim stringArgument As String 
Dim length As Nullable(Of Long)
Dim returnValue As String 

returnValue = DbFunctions.Left(stringArgument, _
    length)
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "length")]
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "stringArgument")]
[SuppressMessageAttribute("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "string")]
[DbFunctionAttribute("Edm", "Left")]
public static string Left(
    string stringArgument,
    Nullable<long> length
)
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA1801:ReviewUnusedParameters", MessageId = L"length")]
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA1801:ReviewUnusedParameters", MessageId = L"stringArgument")]
[SuppressMessageAttribute(L"Microsoft.Naming", L"CA1720:IdentifiersShouldNotContainTypeNames", MessageId = L"string")]
[DbFunctionAttribute(L"Edm", L"Left")]
public:
static String^ Left(
    String^ stringArgument, 
    Nullable<long long> length
)
[<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "length")>]
[<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "stringArgument")>]
[<SuppressMessageAttribute("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "string")>]
[<DbFunctionAttribute("Edm", "Left")>]
static member Left : 
        stringArgument:string * 
        length:Nullable<int64> -> string
public static function Left(
    stringArgument : String, 
    length : Nullable<long>
) : String

參數

傳回值

類型:System.String
包含從輸入字串左邊算起,長度達指定之字元數的字串。

備註

您不可以直接呼叫此函式。 此函式只能出現在 LINQ to Entities 查詢內。 此函式會轉譯為資料庫中的對應函式。

請參閱

參考

DbFunctions 類別

System.Data.Entity 命名空間