Freigeben über


ObjectContext.TryGetObjectByKey-Methode

[Diese Seite bezieht sich auf Entity Framework Version 6. Die neueste Version ist als 'Entity Framework' NuGet-Paket verfügbar. Weitere Informationen zu Entity Framework finden Sie unter msdn.com/data/ef.]

Gibt ein Objekt mit dem angegebenen Entitätsschlüssel zurück.

Namespace:  System.Data.Entity.Core.Objects
Assembly:  EntityFramework (in EntityFramework.dll)

Syntax

'Declaration
<SuppressMessageAttribute("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate")> _
Public Overridable Function TryGetObjectByKey ( _
    key As EntityKey, _
    <OutAttribute> ByRef value As Object _
) As Boolean
'Usage
Dim instance As ObjectContext 
Dim key As EntityKey 
Dim value As Object 
Dim returnValue As Boolean 

returnValue = instance.TryGetObjectByKey(key, _
    value)
[SuppressMessageAttribute("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate")]
public virtual bool TryGetObjectByKey(
    EntityKey key,
    out Object value
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1007:UseGenericsWhereAppropriate")]
public:
virtual bool TryGetObjectByKey(
    EntityKey^ key, 
    [OutAttribute] Object^% value
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate")>]
abstract TryGetObjectByKey : 
        key:EntityKey * 
        value:Object byref -> bool 
[<SuppressMessageAttribute("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate")>]
override TryGetObjectByKey : 
        key:EntityKey * 
        value:Object byref -> bool
public function TryGetObjectByKey(
    key : EntityKey, 
    value : Object
) : boolean

Parameter

  • value
    Typ: System.Object%
    Enthält das Objekt, wenn diese Methode erfolgreich beendet wurde.

Rückgabewert

Typ: System.Boolean
true, wenn das Objekt erfolgreich abgerufen wurde.false, wenn der Schlüssel temporär ist oder die Verbindung bzw. der Wert NULL ist.

Ausnahmen

Ausnahme Bedingung
ArgumentException

Nicht kompatible Metadaten für key.

ArgumentNullException

Schlüssel ist NULL.

Siehe auch

Verweis

ObjectContext Klasse

System.Data.Entity.Core.Objects-Namespace