TableBuilder<TColumns>.PrimaryKey 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
PrimaryKey(Expression<Func<TColumns,Object>>, String, Object) |
指定資料表的主鍵。 |
PrimaryKey(Expression<Func<TColumns,Object>>, String, Boolean, Object) |
指定資料表的主鍵。 Entity Framework 移轉 API 的設計目的不是接受未受信任來源所提供的輸入, (例如應用程式的使用者) 。 如果從這類來源接受輸入,則應該先加以驗證,再傳遞至這些 API 以防止 SQL 插入式攻擊等。 |
PrimaryKey(Expression<Func<TColumns,Object>>, String, Object)
指定資料表的主鍵。
public System.Data.Entity.Migrations.Builders.TableBuilder<TColumns> PrimaryKey (System.Linq.Expressions.Expression<Func<TColumns,object>> keyExpression, string name = null, object anonymousArguments = null);
member this.PrimaryKey : System.Linq.Expressions.Expression<Func<'Columns, obj>> * string * obj -> System.Data.Entity.Migrations.Builders.TableBuilder<'Columns>
Public Function PrimaryKey (keyExpression As Expression(Of Func(Of TColumns, Object)), Optional name As String = null, Optional anonymousArguments As Object = null) As TableBuilder(Of TColumns)
參數
- keyExpression
- Expression<Func<TColumns,Object>>
代表要做為主索引鍵之屬性的 Lambda 運算式。
C#: t = > t.Id
VB.Net:函式 (t) t.Id
如果主索引鍵是由多個屬性所組成,則指定匿名型別 (包括屬性)。 C#: t = > new { t.Id1, t.Id2 } VB.Net: Function (t) New with { t.Id1, t.Id2 }
- name
- String
主索引鍵的名稱。 如果提供 null,則會產生預設名稱。
- anonymousArguments
- Object
提供者可能處理的其他引數。 使用匿名型別語法來指定引數,例如 'new { SampleArgument = 「MyValue」 }'。
傳回
本身,以便鏈結多個呼叫。
適用於
PrimaryKey(Expression<Func<TColumns,Object>>, String, Boolean, Object)
指定資料表的主鍵。
Entity Framework 移轉 API 的設計目的不是接受未受信任來源所提供的輸入, (例如應用程式的使用者) 。 如果從這類來源接受輸入,則應該先加以驗證,再傳遞至這些 API 以防止 SQL 插入式攻擊等。
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
public System.Data.Entity.Migrations.Builders.TableBuilder<TColumns> PrimaryKey (System.Linq.Expressions.Expression<Func<TColumns,object>> keyExpression, string name = null, bool clustered = true, object anonymousArguments = null);
member this.PrimaryKey : System.Linq.Expressions.Expression<Func<'Columns, obj>> * string * bool * obj -> System.Data.Entity.Migrations.Builders.TableBuilder<'Columns>
Public Function PrimaryKey (keyExpression As Expression(Of Func(Of TColumns, Object)), Optional name As String = null, Optional clustered As Boolean = true, Optional anonymousArguments As Object = null) As TableBuilder(Of TColumns)
參數
- keyExpression
- Expression<Func<TColumns,Object>>
代表要做為主索引鍵之屬性的 Lambda 運算式。 C#: t = > t.Id VB.Net:函式 (t) t.Id 如果主鍵是由多個屬性所組成,則請指定匿名型別,包括屬性。 C#: t = > new { t.Id1, t.Id2 } VB.Net: Function (t) New with { t.Id1, t.Id2 }
- name
- String
主索引鍵的名稱。 如果提供 null,則會產生預設名稱。
- clustered
- Boolean
值,指出這是否為叢集主鍵。
- anonymousArguments
- Object
提供者可能處理的其他引數。 使用匿名型別語法來指定引數,例如 'new { SampleArgument = 「MyValue」 }'。
傳回
本身,以便鏈結多個呼叫。
- 屬性