# TryLoad

> Loads all the properties of a document, already deseriazed into objects.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.Search](/engine/6000.7/script-reference/unityeditor/search.md)
* **Assembly:** UnityEditor

## TryLoad(ulong, IEnumerable\<Object>)

Loads all the properties of a document, already deseriazed into objects.

```csharp
bool TryLoad(ulong documentKey, out IEnumerable<object> data)
```

### Parameters

**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): A document key.**** (\[IEnumerable\<Object>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)): The document property values.

### Returns

| Type                                                          | Description                                                |
| ------------------------------------------------------------- | ---------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the record is found and is valid, false otherwise. |

### Remarks

```csharp
// 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());
}
```

Additional Resources: [IPropertyDatabaseView.CreateDocumentKey](/engine/6000.7/script-reference/unityeditor/search/ipropertydatabaseview/createdocumentkey.md).

## TryLoad(ulong, IEnumerable\<IPropertyDatabaseRecord>)

Loads all the properties of a document, still contained within records.

```csharp
bool TryLoad(ulong documentKey, out IEnumerable<IPropertyDatabaseRecord> records)
```

### Parameters

**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): A document key.**** (\[IEnumerable\<IPropertyDatabaseRecord>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)): The document property records.

### Returns

| Type                                                          | Description                                                |
| ------------------------------------------------------------- | ---------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True 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.

```csharp
// 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);
}
```

Additional Resources: [IPropertyDatabaseView.CreateDocumentKey](/engine/6000.7/script-reference/unityeditor/search/ipropertydatabaseview/createdocumentkey.md).
