Returns an instance of an object from the collection using a distinct value (see IDatabaseObjects.DistinctFieldName). If the collection has implemented the IDatabaseObjects.Subset function then the objDistinctValue need only be unique within the collection's subset, not the entire database table. Returns Nothing/null if the distinct value does not exist in the database. This feature is what differentiates Database.Object() from Database.ObjectIfExists().

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

Syntax

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

Parameters

objCollection
Type: DatabaseObjects..::..IDatabaseObjects
The collection that contains the object.
objDistinctValue
Type: System..::..Object
The value that uniquely identifies the object within the collection. This is the value of the field defined by the collection's IDatabaseObjects.DistinctFieldName function.

Return Value

IDatabaseObject (DatabaseObjects.IDatabaseObject)

Examples

Loads a product using a product ID of 123
CopyC#
objProduct = objDatabase.Object(NorthwindDB.Products, 123)

See Also