ObjectContext 建構函式 (String)
[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]
使用給定的連接字串和預設實體容器名稱,初始化 ObjectContext 類別的新執行個體。
命名空間: System.Data.Entity.Core.Objects
組件: EntityFramework (在 EntityFramework.dll 中)
語法
'宣告
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification := "Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")> _
Public Sub New ( _
connectionString As String _
)
'用途
Dim connectionString As String
Dim instance As New ObjectContext(connectionString)
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification = "Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")]
public ObjectContext(
string connectionString
)
[SuppressMessageAttribute(L"Microsoft.Reliability", L"CA2000:DisposeObjectsBeforeLosingScope", Justification = L"Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")]
public:
ObjectContext(
String^ connectionString
)
[<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification = "Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")>]
new :
connectionString:string -> ObjectContext
public function ObjectContext(
connectionString : String
)
參數
- connectionString
類型:System.String
連接字串,它也會提供中繼資料資訊的存取權。
例外狀況
例外狀況 | 條件 |
---|---|
ArgumentNullException | connectionString 是 null。 |
ArgumentException | connectionString 無效或中繼資料工作空間無效。 |