Returns an object from the collection using a unique key value. The key must be unique within the collection. If the collection's IDatabaseObjects.Subset has been implemented then the key need only be unique within the subset specified, not the entire database table. Returns Nothing/null if the object does exist with the specified key. This feature is what differentiates Database.ObjectByKey() from Database.ObjectByKeyExists().

Namespace: DatabaseObjects
Assembly: DatabaseObjects (in DatabaseObjects.dll) Version: 3.8.1.0

Syntax

C#
public IDatabaseObject ObjectByKeyIfExists(
	IDatabaseObjects objCollection,
	Object objKey
)
Visual Basic
Public Function ObjectByKeyIfExists ( _
	objCollection As IDatabaseObjects, _
	objKey As Object _
) As IDatabaseObject
Visual C++
public:
IDatabaseObject^ ObjectByKeyIfExists(
	IDatabaseObjects^ objCollection, 
	Object^ objKey
)

Parameters

objCollection
Type: DatabaseObjects..::..IDatabaseObjects
The collection which contains the object.
objKey
Type: System..::..Object
The key that identifies the object with the collection. The key is the value of the field defined by the collection's IDatabaseObjects.KeyFieldName.

Return Value

IDatabaseObject (DatabaseObjects.IDatabaseObject)

Examples

CopyC#
Default Public ReadOnly Property Item(ByVal strProductCode As String) As Product
    Get

        Return objDatabase.ObjectByKey(Me, strProductCode)

    End Get
End Property

See Also