Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TryLoad

Loads all the properties of a document, already deseriazed into objects.
Read time 1 minuteLast updated 6 days ago

Definition

TryLoad(ulong, IEnumerable<Object>)

Loads all the properties of a document, already deseriazed into objects.
bool TryLoad(ulong documentKey, out IEnumerable<object> data)

Parameters

documentKey

A document key.

The document property values.

Returns

Type

Description

boolTrue if the record is found and is valid, false otherwise.

Remarks

// Load all values not associated with a document, already deserialized.using (var view = propertyDatabase.GetView()){ var nullDocumentKey = view.CreateDocumentKey(null); if (!view.TryLoad(nullDocumentKey, out IEnumerable<object> noDocumentProperties)) Assert.Fail("Failed to load properties with no documents."); Assert.IsNotEmpty(noDocumentProperties); Assert.AreEqual("myDocs_", noDocumentProperties.First());}

TryLoad(ulong, IEnumerable<IPropertyDatabaseRecord>)

Loads all the properties of a document, still contained within records.
bool TryLoad(ulong documentKey, out IEnumerable<IPropertyDatabaseRecord> records)

Parameters

documentKey

A document key.

The document property records.

Returns

Type

Description

boolTrue if the record is found and is valid, false otherwise.

Remarks

This method doesn't deserialize the values. You have to deserialize them yourself by calling IPropertyDatabaseView.GetObjectFromRecordValue.
// Load all values associated with a document, not deserialized.using (var view = propertyDatabase.GetView()){ var myAssetDocumentKey = view.CreateDocumentKey("path/to/my/asset"); if (!view.TryLoad(myAssetDocumentKey, out IEnumerable<IPropertyDatabaseRecord> myDocumentRecords)) Assert.Fail("Failed to load records for my asset document."); var deserializedValues = new Dictionary<PropertyDatabaseRecordKey, object>(); foreach (var myDocumentRecord in myDocumentRecords) { var value = view.GetValueFromRecord<object>(myDocumentRecord.value); deserializedValues.Add(myDocumentRecord.key, value); } Assert.AreEqual(5, deserializedValues.Count);}