Share via


Metodo ObjectContext.CreateEntityKey

[Questa pagina è specifica della versione 6 di Entity Framework. La versione più recente è disponibile come pacchetto NuGet per "Entity Framework". Per ulteriori informazioni su Entity Framework, vedere la pagina msdn.com/data/ef.]

Crea la chiave di entità per un oggetto specifico o restituisce la chiave di entità se già esiste.

Spazio dei nomi:  System.Data.Entity.Core.Objects
Assembly:  EntityFramework (in EntityFramework.dll)

Sintassi

'Dichiarazione
Public Overridable Function CreateEntityKey ( _
    entitySetName As String, _
    entity As Object _
) As EntityKey
'Utilizzo
Dim instance As ObjectContext 
Dim entitySetName As String 
Dim entity As Object 
Dim returnValue As EntityKey 

returnValue = instance.CreateEntityKey(entitySetName, _
    entity)
public virtual EntityKey CreateEntityKey(
    string entitySetName,
    Object entity
)
public:
virtual EntityKey^ CreateEntityKey(
    String^ entitySetName, 
    Object^ entity
)
abstract CreateEntityKey : 
        entitySetName:string * 
        entity:Object -> EntityKey  
override CreateEntityKey : 
        entitySetName:string * 
        entity:Object -> EntityKey
public function CreateEntityKey(
    entitySetName : String, 
    entity : Object
) : EntityKey

Parametri

  • entitySetName
    Tipo: System.String
    Nome completo del set di entità a cui appartiene l'oggetto entità.
  • entity
    Tipo: System.Object
    Oggetto per il quale viene recuperata la chiave di entità.

Valore restituito

Tipo: System.Data.Entity.Core.EntityKey
EntityKey dell'oggetto.

Eccezioni

Eccezione Condizione
ArgumentNullException

Quando uno dei parametri è Null.

ArgumentException

Quando entitySetName è vuoto o quando il tipo dell'oggetto entità non è presente nel set di entità o quando entitySetName non è completo.

InvalidOperationException

Quando la chiave di entità non può essere costruita correttamente in base ai parametri specificati.

Vedere anche

Riferimento

ObjectContext Classe

Spazio dei nomi System.Data.Entity.Core.Objects