Path: redb/redb.Core/Exceptions/RedbUniqueKeyDefinitionException.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Exceptions/RedbUniqueKeyDefinitionException.cs
----
using System;
namespace redb.Core.Exceptions;
///
/// Thrown by scheme synchronisation when [RedbUnique] sits where it cannot be enforced: on a
/// property inside an array, a dictionary or a nested class, on a reference, a list item, an enum, a
/// collection, or on a type with no canonical form. Rejected at synchronisation, not at insert —
/// otherwise the behaviour would degrade into an index that silently never fires.
///
///
/// Also thrown by GetByUniqueAsync when asked for a property that is not a unique key.
///
///
public class RedbUniqueKeyDefinitionException : Exception
{
/// CLR type or scheme the property belongs to.
public string SchemeName { get; }
/// The offending property.
public string PropertyName { get; }
/// Why it cannot be a unique key.
public string Reason { get; }
public RedbUniqueKeyDefinitionException(string schemeName, string propertyName, string reason)
: base($"[RedbUnique] on '{schemeName}.{propertyName}' cannot be enforced: {reason}. " +
"A unique key must be a scalar property — string, integer, Guid, bool, double, " +
"decimal, date/time or byte[] — of the Props class or of a nested class reached " +
"without crossing a collection.")
{
SchemeName = schemeName;
PropertyName = propertyName;
Reason = reason;
}
}