ObjectContext - конструктор (EntityConnection, String)
[Эта страница относится к документации к Entity Framework 6. Последняя версия доступна в составе пакета Entity Framework NuGet. Дополнительные сведения об Entity Framework см. в разделе msdn.com/data/ef.]
Инициализирует новый экземпляр класса ObjectContext с данным соединением и именем контейнера сущностей.
Пространство имен: System.Data.Entity.Core.Objects
Сборка: EntityFramework (в EntityFramework.dll)
Синтаксис
'Декларация
<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification := "Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")> _
Protected Sub New ( _
connection As EntityConnection, _
defaultContainerName As String _
)
'Применение
Dim connection As EntityConnection
Dim defaultContainerName As String
Dim instance As New ObjectContext(connection, _
defaultContainerName)
[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
protected ObjectContext(
EntityConnection connection,
string defaultContainerName
)
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA2214:DoNotCallOverridableMethodsInConstructors", Justification = L"Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
protected:
ObjectContext(
EntityConnection^ connection,
String^ defaultContainerName
)
[<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")>]
new :
connection:EntityConnection *
defaultContainerName:string -> ObjectContext
protected function ObjectContext(
connection : EntityConnection,
defaultContainerName : String
)
Параметры
- connection
Тип: System.Data.Entity.Core.EntityClient.EntityConnection
Объект EntityConnection, содержащий ссылки на модель и подключение к источнику данных.
- defaultContainerName
Тип: System.String
Имя контейнера сущностей по умолчанию. Если параметр defaultContainerName задается с помощью этого метода, свойство становится доступным только для чтения.
Исключения
Исключение | Условие |
---|---|
ArgumentNullException | Параметр connection имеет значение NULL. |
ArgumentException | Недопустимый параметр connection, defaultContainerName или неправильная рабочая область метаданных. |