TypedItem 3.0.0-rc2

This is a prerelease version of TypedItem.
dotnet add package TypedItem --version 3.0.0-rc2
                    
NuGet\Install-Package TypedItem -Version 3.0.0-rc2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TypedItem" Version="3.0.0-rc2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TypedItem" Version="3.0.0-rc2" />
                    
Directory.Packages.props
<PackageReference Include="TypedItem" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TypedItem --version 3.0.0-rc2
                    
#r "nuget: TypedItem, 3.0.0-rc2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TypedItem@3.0.0-rc2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TypedItem&version=3.0.0-rc2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=TypedItem&version=3.0.0-rc2&prerelease
                    
Install as a Cake Tool

TypedItem

TypedItem is a .NET extension library for Azure Cosmos DB (SQL API) that adds typed item management, soft delete, and hierarchical type queries to any Cosmos DB container.

Each document stores a _type field computed from C# inheritance and [ItemType] attributes. This lets you safely store multiple item types in a single container and query them with full type safety.

Installation

dotnet add package TypedItem

Requires Microsoft.Azure.Cosmos 3.x and .NET 10.

Quick start

1 — Define a partition-key base class

public class MyContainerItem : TypedItemBase
{
    [JsonProperty("part")]
    public string Part { get; set; }

    public override PartitionKey GetPartitionKey()
        => CreatePartitionKey(Part);
}

2 — Define typed item classes

Annotate with [ItemType("name")]. Write operations require a sealed class.

[ItemType("person")]
public sealed class PersonItem : MyContainerItem
{
    [JsonProperty("firstName")] public string FirstName { get; set; }
    [JsonProperty("lastName")]  public string LastName  { get; set; }
}

3 — Use extension methods

All methods extend Microsoft.Azure.Cosmos.Container and TransactionalBatch:

// Write
await container.CreateTypedItemAsync(person);
await container.UpsertTypedItemAsync(person);
await container.ReplaceTypedItemAsync(person, person.Id);

// Read — throws CosmosException (404) if soft-deleted or wrong type
var response = await container.ReadTypedItemAsync<PersonItem>(id, partitionKey);

// Soft-delete (sets _deleted = true via conditional PATCH)
await container.SoftDeleteTypedItemAsync(person);

// Query
var result = await container.QueryTypedItemAsync<PersonItem, PersonItem>(q => q);

Type hierarchy

Use C# inheritance with multiple [ItemType] attributes to build dot-separated type hierarchies:

[ItemType("event")]                   // non-sealed = queryable parent
public class EventItem : MyContainerItem
{
    [JsonProperty("date")] public DateTime Date { get; set; }
}

[ItemType("phonecall")]               // _type stored as "event.phonecall"
public sealed class PhonecallItem : EventItem
{
    [JsonProperty("duration")] public int Duration { get; set; }
}

[ItemType("meeting")]                 // _type stored as "event.meeting"
public sealed class MeetingItem : EventItem
{
    [JsonProperty("attendees")] public string[] Attendees { get; set; }
}

QueryTypedItemAsync automatically filters by type:

// Returns only phone calls
var calls = await container.QueryTypedItemAsync<PhonecallItem, PhonecallItem>(q => q);

// Returns ALL events (phone calls + meetings)
var events = await container.QueryTypedItemAsync<EventItem, EventItem>(q => q);

Fields stored in documents

JSON field Description
_type Dot-separated type identifier (e.g., "event.phonecall")
_deleted Soft-delete flag (true = logically deleted)
id Document id (auto-generated if not set)
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-rc2 95 4/25/2026
3.0.0-rc1 91 4/25/2026
2.0.1 313 12/2/2023
2.0.0 500 2/9/2023
1.2.1 1,095 12/21/2021
1.1.1 469 12/14/2021
1.1.0 470 12/7/2021
1.0.3 476 11/22/2021
1.0.2 477 11/22/2021
0.1.0 534 11/8/2021