FullItem
One base class that combines etags, timestamps, and time-to-live.
FullItem combines every behavior offered by the smaller bases:
IItem—Id,Type, and partition-key handling (fromItem).IItemWithEtag— optimistic concurrency control viaEtag.IItemWithTimeStamps—CreatedTimeUtc,LastUpdatedTimeUtc, andLastUpdatedTimeRaw.IItemWithTimeToLive— per-itemTimeToLiveoverriding 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:
| Need | Base class |
|---|---|
| Only optimistic concurrency | EtagItem |
| Only timestamps | TimeStampedItem |
| Only TTL overrides | TimeToLiveItem |
| Custom mix | Implement the matching IItemWith* interfaces yourself |