Returns an object using a unique key value. The key must be unique within this collection. If the collection's DatabaseObjects.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 DatabaseObjects.ObjectByKey() from DatabaseObjects.ObjectByKeyExists().

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

Syntax

C#
protected IDatabaseObject ObjectByKeyIfExists(
	Object objKey
)
Visual Basic
Protected Function ObjectByKeyIfExists ( _
	objKey As Object _
) As IDatabaseObject
Visual C++
protected:
IDatabaseObject^ ObjectByKeyIfExists(
	Object^ objKey
)

Parameters

objKey
Type: System..::..Object
The key that identifies the object with this collection. The key is the value of the field defined by this collection's KeyFieldName.

Return Value

IDatabaseObject (DatabaseObjects.IDatabaseObject)

Examples

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

        Return MyBase.ObjectByKey(strProductCode)

    End Get
End Property

See Also