Sugerir traducción
 
Otros han sugerido:

progress indicator
No hay más sugerencias.
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Ver contenido:  en paraleloVer contenido: en paralelo
.NET Framework Class Library
EntityConnection Class

Contains a reference to a conceptual model and a data source connection. This class cannot be inherited.

System..::.Object
  System..::.MarshalByRefObject
    System.ComponentModel..::.Component
      System.Data.Common..::.DbConnection
        System.Data.EntityClient..::.EntityConnection

Namespace:  System.Data.EntityClient
Assembly:  System.Data.Entity (in System.Data.Entity.dll)
Visual Basic
Public NotInheritable Class EntityConnection _
    Inherits DbConnection
C#
public sealed class EntityConnection : DbConnection
Visual C++
public ref class EntityConnection sealed : public DbConnection
F#
[<Sealed>]
type EntityConnection =  
    class
        inherit DbConnection
    end

The EntityConnection type exposes the following members.

  NameDescription
Public methodEntityConnection()()()Initializes a new instance of the EntityConnection class.
Public methodEntityConnection(String)Initializes a new instance of the EntityConnection class, based on the connection string.
Public methodEntityConnection(MetadataWorkspace, DbConnection)Initializes a new instance of the EntityConnection class with a specified MetadataWorkspace and DbConnection.
Top
  NameDescription
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event. (Inherited from Component.)
Public propertyConnectionStringGets or sets the EntityConnection connection string. (Overrides DbConnection..::.ConnectionString.)
Public propertyConnectionTimeoutGets the number of seconds to wait when attempting to establish a connection before ending the attempt and generating an error. (Overrides DbConnection..::.ConnectionTimeout.)
Public propertyContainerGets the IContainer that contains the Component. (Inherited from Component.)
Public propertyDatabaseGets the name of the current database, or the database that will be used after a connection is opened. (Overrides DbConnection..::.Database.)
Public propertyDataSourceGets the name or network address of the data source to connect to. (Overrides DbConnection..::.DataSource.)
Protected propertyDbProviderFactoryGets the DbProviderFactory for this DbConnection. (Inherited from DbConnection.)
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected propertyEventsGets the list of event handlers that are attached to this Component. (Inherited from Component.)
Public propertyServerVersionGets a string that contains the version of the data source to which the client is connected. (Overrides DbConnection..::.ServerVersion.)
Public propertySiteGets or sets the ISite of the Component. (Inherited from Component.)
Public propertyStateGets the ConnectionState property of the underlying provider if the EntityConnection is open. Otherwise, returns Closed. (Overrides DbConnection..::.State.)
Public propertyStoreConnectionProvides access to the underlying data source connection that is used by the EntityConnection object.
Top
  NameDescription
Protected methodBeginDbTransactionStarts a database transaction. (Inherited from DbConnection.)
Public methodBeginTransaction()()()Begins a transaction by using the underlying provider.
Public methodBeginTransaction(IsolationLevel)Begins a transaction with the specified isolation level by using the underlying provider.
Public methodChangeDatabaseNot supported. (Overrides DbConnection..::.ChangeDatabase(String).)
Public methodCloseCloses the connection to the database. (Overrides DbConnection..::.Close()()().)
Public methodCreateCommandCreates a new instance of an EntityCommand, with the Connection set to this EntityConnection.
Protected methodCreateDbCommandCreates and returns a DbCommand object associated with the current connection. (Inherited from DbConnection.)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()()()Releases all resources used by the Component. (Inherited from Component.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.)
Public methodEnlistTransactionEnlists this EntityConnection in the specified transaction. (Overrides DbConnection..::.EnlistTransaction(Transaction).)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeReleases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetMetadataWorkspaceReturns the MetadataWorkspace associated with this EntityConnection.
Public methodGetSchema()()()Returns schema information for the data source of this DbConnection. (Inherited from DbConnection.)
Public methodGetSchema(String)Returns schema information for the data source of this DbConnection using the specified string for the schema name. (Inherited from DbConnection.)
Public methodGetSchema(String, array<String>[]()[])Returns schema information for the data source of this DbConnection using the specified string for the schema name and the specified string array for the restriction values. (Inherited from DbConnection.)
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodMemberwiseClone()()()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Protected methodOnStateChangeRaises the StateChange event. (Inherited from DbConnection.)
Public methodOpenEstablishes a connection to the data source by calling the underlying data provider's Open method. (Overrides DbConnection..::.Open()()().)
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Top
  NameDescription
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Public eventStateChangeOccurs when the state of the event changes. (Inherited from DbConnection.)
Top
  NameDescription
Explicit interface implemetationPrivate methodIDbConnection..::.BeginTransaction()()()Begins a database transaction. (Inherited from DbConnection.)
Explicit interface implemetationPrivate methodIDbConnection..::.BeginTransaction(IsolationLevel)Begins a database transaction with the specified IsolationLevel value. (Inherited from DbConnection.)
Explicit interface implemetationPrivate methodIDbConnection..::.CreateCommandCreates and returns a DbCommand object that is associated with the current connection. (Inherited from DbConnection.)
Top

To avoid inadvertently putting objects such as System.Data.Common.CommandTrees and ObjectContext out of sync with their metadata, EntityConnection must lock its metadata. No changes to the connection string are allowed after the metadata is locked. The following are two scenarios in which metadata is locked:

  • The EntityConnection instance is constructed through the default constructor, or through the EntityConnection(String) constructor, which accepts a connection string. In either case the connection string might be changed multiple times before the connection is opened. Calling [M:System.Data.EntityClient.EntityConnection.Open()] or [M:System.Data.EntityClient.EntityConnection.GetMetadataWorkspace()] locks the metadata.

  • The EntityConnection instance is constructed through the EntityConnection(MetadataWorkspace, DbConnection) constructor, which accepts a MetadataWorkspace and a DbConnection. In this case, the metadata is locked at construction time. No changes to the connection string are ever allowed.

When metadata is loaded, the EntityConnection verifies that the conceptual model, the storage model, and the mapping file are all present.

For code examples, see Working with EntityClient.

.NET Framework

Supported in: 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Biblioteca de clases de .NET Framework
EntityConnection (Clase)

Contiene una referencia a un modelo conceptual y una conexión a un origen de datos. Esta clase no puede heredarse.

System..::.Object
  System..::.MarshalByRefObject
    System.ComponentModel..::.Component
      System.Data.Common..::.DbConnection
        System.Data.EntityClient..::.EntityConnection

Espacio de nombres:  System.Data.EntityClient
Ensamblado:  System.Data.Entity (en System.Data.Entity.dll)
Visual Basic
Public NotInheritable Class EntityConnection _
    Inherits DbConnection
C#
public sealed class EntityConnection : DbConnection
Visual C++
public ref class EntityConnection sealed : public DbConnection
F#
[<Sealed>]
type EntityConnection =  
    class
        inherit DbConnection
    end

El tipo EntityConnection expone los siguientes miembros.

  NombreDescripción
Método públicoEntityConnection()()()Inicializa una nueva instancia de la clase EntityConnection.
Método públicoEntityConnection(String)Inicializa una nueva instancia de la clase EntityConnection, basándose en la cadena de conexión.
Método públicoEntityConnection(MetadataWorkspace, DbConnection)Inicializa una nueva instancia de la clase EntityConnection con los objetos MetadataWorkspace y DbConnection especificados.
Arriba
  NombreDescripción
Propiedad protegidaCanRaiseEventsObtiene un valor que indica si el componente puede generar un evento. (Se hereda de Component).
Propiedad públicaConnectionStringObtiene o establece la cadena de conexión EntityConnection. (Invalida a DbConnection..::.ConnectionString).
Propiedad públicaConnectionTimeoutObtiene el número de segundos que se debe esperar cuando se intenta establecer una conexión antes de que finalice el intento y se genere un error. (Invalida a DbConnection..::.ConnectionTimeout).
Propiedad públicaContainerObtiene IContainer que contiene Component. (Se hereda de Component).
Propiedad públicaDatabaseObtiene el nombre de la base de datos actual o de la base de datos que se va a utilizar cuando se abra la conexión. (Invalida a DbConnection..::.Database).
Propiedad públicaDataSourceObtiene el nombre o la dirección de red del origen de datos con el que se va a conectar. (Invalida a DbConnection..::.DataSource).
Propiedad protegidaDbProviderFactoryObtiene DbProviderFactory para este DbConnection. (Se hereda de DbConnection).
Propiedad protegidaDesignModeObtiene un valor que indica si Component está actualmente en modo de diseño. (Se hereda de Component).
Propiedad protegidaEventsObtiene la lista de controladores de eventos asociados a Component. (Se hereda de Component).
Propiedad públicaServerVersionObtiene una cadena que contiene la versión del origen de datos al que está conectado el cliente. (Invalida a DbConnection..::.ServerVersion).
Propiedad públicaSiteObtiene o establece ISite de Component. (Se hereda de Component).
Propiedad públicaStateObtiene la propiedad ConnectionState del proveedor subyacente si el objeto EntityConnection está abierto. En caso contrario, devuelve Closed. (Invalida a DbConnection..::.State).
Propiedad públicaStoreConnectionProporciona acceso a la conexión de origen de datos subyacente usada por el objeto EntityConnection.
Arriba
  NombreDescripción
Método protegidoBeginDbTransactionInicia una transacción de base de datos. (Se hereda de DbConnection).
Método públicoBeginTransaction()()()Comienza una transacción utilizando el proveedor subyacente.
Método públicoBeginTransaction(IsolationLevel)Comienza una transacción con el nivel de aislamiento especificado utilizando el proveedor subyacente.
Método públicoChangeDatabaseNo se admite. (Invalida a DbConnection..::.ChangeDatabase(String)).
Método públicoCloseCierra la conexión con la base de datos. (Invalida a DbConnection..::.Close()()()).
Método públicoCreateCommandCrea una nueva instancia de EntityCommand, con la propiedad Connection establecida en EntityConnection.
Método protegidoCreateDbCommandCrea y devuelve un objeto DbCommand asociado a la conexión actual. (Se hereda de DbConnection).
Método públicoCreateObjRefCrea un objeto que contiene toda la información relevante necesaria para generar un proxy utilizado para comunicarse con un objeto remoto. (Se hereda de MarshalByRefObject).
Método públicoDispose()()()Libera todos los recursos utilizados por el objeto Component. (Se hereda de Component).
Método protegidoDispose(Boolean)Libera los recursos no administrados usados por Component y, opcionalmente, los recursos administrados. (Se hereda de Component).
Método públicoEnlistTransactionDa de alta este objeto EntityConnection en la transacción especificada. (Invalida a DbConnection..::.EnlistTransaction(Transaction)).
Método públicoEquals(Object)Determina si el objeto Object especificado es igual al objeto Object actual. (Se hereda de Object).
Método protegidoFinalizeLibera recursos no administrados y realiza otras operaciones de limpieza antes de que se reclame el objeto Component durante la recolección de elementos no utilizados. (Se hereda de Component).
Método públicoGetHashCodeActúa como función hash para un tipo concreto. (Se hereda de Object).
Método públicoGetLifetimeServiceRecupera el objeto de servicio de duración actual que controla la directiva de duración de esta instancia. (Se hereda de MarshalByRefObject).
Método públicoGetMetadataWorkspaceDevuelve el objeto MetadataWorkspace asociado a este objeto EntityConnection.
Método públicoGetSchema()()()Devuelve información de esquema para el origen de datos de DbConnection. (Se hereda de DbConnection).
Método públicoGetSchema(String)Devuelve información de esquema para el origen de datos de DbConnection utilizando la cadena especificada para el nombre del esquema. (Se hereda de DbConnection).
Método públicoGetSchema(String, array<String>[]()[])Devuelve información de esquema para el origen de datos de DbConnection utilizando la cadena especificada para el nombre del esquema y la matriz de cadena determinada para los valores de restricción. (Se hereda de DbConnection).
Método protegidoGetServiceDevuelve un objeto que representa el servicio suministrado por Component o por Container. (Se hereda de Component).
Método públicoGetTypeObtiene el objeto Type de la instancia actual. (Se hereda de Object).
Método públicoInitializeLifetimeServiceObtiene un objeto de servicio de duración para controlar la directiva de duración de esta instancia. (Se hereda de MarshalByRefObject).
Método protegidoMemberwiseClone()()()Crea una copia superficial del objeto Object actual. (Se hereda de Object).
Método protegidoMemberwiseClone(Boolean)Crea una copia superficial del objeto MarshalByRefObject actual. (Se hereda de MarshalByRefObject).
Método protegidoOnStateChangeProvoca el evento StateChange. (Se hereda de DbConnection).
Método públicoOpenEstablece una conexión con el origen de datos llamando al método Open del proveedor de datos subyacente. (Invalida a DbConnection..::.Open()()()).
Método públicoToStringDevuelve un objeto String que contiene el nombre del objeto Component, en caso de que exista. Este método no debe reemplazarse. (Se hereda de Component).
Arriba
  NombreDescripción
Evento públicoDisposedSe produce cuando el componente se elimina mediante una llamada al método Dispose. (Se hereda de Component).
Evento públicoStateChangeSe produce cuando cambia el estado del evento. (Se hereda de DbConnection).
Arriba
  NombreDescripción
Implementación explícita de interfacesMétodo privadoIDbConnection..::.BeginTransaction()()()Inicia una transacción de base de datos. (Se hereda de DbConnection).
Implementación explícita de interfacesMétodo privadoIDbConnection..::.BeginTransaction(IsolationLevel)Inicia una transacción de base de datos con el valor de IsolationLevel especificado. (Se hereda de DbConnection).
Implementación explícita de interfacesMétodo privadoIDbConnection..::.CreateCommandCrea y devuelve un objeto DbCommand asociado a la conexión actual. (Se hereda de DbConnection).
Arriba

Para evitar que objetos como System.Data.Common.CommandTrees y ObjectContext dejen de estar sincronizados involuntariamente con sus metadatos, EntityConnection debe bloquear los metadatos. No se permiten cambios en la cadena de conexión una vez bloqueados los metadatos. A continuación se presentan dos escenarios en los que se bloquean los metadatos:

  • La instancia de EntityConnection se crea mediante el constructor predeterminado, o mediante el constructor EntityConnection(String), que acepta una cadena de conexión. En cualquiera de los casos, la cadena de conexión se puede cambiar varias veces antes de abrirse la conexión. La llamada a los métodos [M:System.Data.EntityClient.EntityConnection.Open()] o [M:System.Data.EntityClient.EntityConnection.GetMetadataWorkspace()] bloquea los metadatos.

  • La instancia de EntityConnection se crea mediante el constructor EntityConnection(MetadataWorkspace, DbConnection), que acepta MetadataWorkspace y DbConnection. En este caso, los metadatos se bloquean en el momento de la creación. No se permiten en ningún caso cambios en la cadena de conexión.

Cuando se cargan los metadatos, EntityConnection comprueba que el modelo conceptual, el modelo de almacenamiento y el archivo de asignación estén presentes.

Para obtener ejemplos de código, vea Working with EntityClient.

.NET Framework

Compatible con: 4, 3.5 SP1

.NET Framework Client Profile

Compatible con: 4

Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker