# Invalidate

> Invalidates all the properties stored for an entire document.

## Definition

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

## Invalidate(string)

Invalidates all the properties stored for an entire document.

```csharp
public void Invalidate(string documentId)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): A document identifier.

### Examples

```csharp
// Store multiple properties of a document.
var document = "path/to/my/asset";
propertyDatabase.Store(document, "prop1", "value1");
propertyDatabase.Store(document, "prop2", "value2");

// Invalidate the entire document.
propertyDatabase.Invalidate(document);

// The invalidated document can no longer be retrieved.
if (propertyDatabase.TryLoad(PropertyDatabase.CreateDocumentKey(document), out IEnumerable<object> documentValues))
    Assert.Fail("TryLoad should have failed to retrieve the document values.");
```

## Invalidate(ulong)

Invalidates all the properties stored for an entire document.

```csharp
public void Invalidate(ulong documentKey)
```

### Parameters

**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): A document key.

### Remarks

```csharp
// Store multiple properties of a document.
var documentKey = PropertyDatabase.CreateDocumentKey("path/to/my/asset");
propertyDatabase.Store(documentKey, PropertyDatabase.CreatePropertyHash("prop1"), "value1");
propertyDatabase.Store(documentKey, PropertyDatabase.CreatePropertyHash("prop2"), "value2");

// Invalidate the entire document by its key.
propertyDatabase.Invalidate(documentKey);

// The invalidated document can no longer be retrieved.
if (propertyDatabase.TryLoad(documentKey, out IEnumerable<object> documentKeyValues))
    Assert.Fail("TryLoad should have failed to retrieve the document values.");
```

Additional Resources: [PropertyDatabase.CreateDocumentKey](/engine/6000.6/script-reference/unityeditor/search/propertydatabase/createdocumentkey.md).

## Invalidate(PropertyDatabaseRecordKey)

Invalidates a single property record so it is no longer retrievable.

```csharp
public void Invalidate(in PropertyDatabaseRecordKey recordKey)
```

### Parameters

**** (\[PropertyDatabaseRecordKey]\(/engine/6000.6/script-reference/unityeditor/search/propertydatabaserecordkey)): A record key.

### Remarks

```csharp
// Store a property.
var propertyRecordKey = PropertyDatabase.CreateRecordKey("path/to/my/asset", "m_Color");
propertyDatabase.Store(propertyRecordKey, new Color(1, 0, 1));

// Invalidate the property.
propertyDatabase.Invalidate(propertyRecordKey);

// The invalidated property can no longer be retrieved.
if (propertyDatabase.TryLoad(propertyRecordKey, out object propertyValue))
    Assert.Fail("TryLoad should have failed to retrieve the record.");
```

Additional Resources: [PropertyDatabase.CreateRecordKey](/engine/6000.6/script-reference/unityeditor/search/propertydatabase/createrecordkey.md).
