Search documentationEsc

FullItem

One base class that combines etags, timestamps, and time-to-live.

FullItem combines every behavior offered by the smaller bases:

  • IItemId, Type, and partition-key handling (from Item).
  • IItemWithEtag — optimistic concurrency control via Etag.
  • IItemWithTimeStampsCreatedTimeUtc, LastUpdatedTimeUtc, and LastUpdatedTimeRaw.
  • IItemWithTimeToLive — per-item TimeToLive overriding the container default.

If you want the works without thinking about it, derive from FullItem.

using Microsoft.Azure.CosmosRepository;
using Microsoft.Azure.CosmosRepository.Attributes;
namespace OptimisticConcurrencyControl;
[Container("accounts")]
[PartitionKeyPath("/id")]
public class BankAccount : FullItem
{
public string Name { get; set; } = string.Empty;
public double Balance { get; set; }
public void Withdraw(double amount)
{
if (Balance - amount < 0.0)
throw new InvalidOperationException("Cannot go overdrawn");
Balance -= amount;
}
public void Deposit(double amount) => Balance += amount;
public override string ToString() =>
$"Account (Name = {Name}, Balance = {Balance}, Etag = {Etag})";
}

When you don’t want everything

FullItem is the most expressive base, but it’s also the most opinionated. Pick a smaller base when:

NeedBase class
Only optimistic concurrencyEtagItem
Only timestampsTimeStampedItem
Only TTL overridesTimeToLiveItem
Custom mixImplement the matching IItemWith* interfaces yourself