Table of Contents

Struct Attr<T, TConverter>

Namespace
DynaSharp
Assembly
DynaSharp.dll

An attribute with a .NET type and the converter that writes it. The source generator emits one per property (Customer.Attrs.Email), Attr<T>(string) makes one for a number, and any other can be created by hand. A value of the wrong type is a compile error. The docs call such an attribute a handle: Order.Attrs.Total is the handle of the Total property.

public readonly struct Attr<T, TConverter> where TConverter : IDynamoDbConverter<T>

Type Parameters

T

The .NET type.

TConverter

The converter.

Inherited Members
Extension Methods

Remarks

The path has the syntax described on Attr.

Constructors

Attr(string)

Initializes a new instance of the Attr<T, TConverter> struct.

public Attr(string path)

Parameters

path string

The name or document path.

Exceptions

ArgumentException

path is null or empty.

Properties

Path

Gets the name or document path.

public string Path { get; }

Property Value

string

Methods

Between(T, T)

Checks for a range, both bounds included. DynamoDB rejects a low bound above the high bound.

public Between<T, TConverter> Between(T low, T high)

Parameters

low T

The low bound.

high T

The high bound.

Returns

Between<T, TConverter>

The condition.

Eq(T)

Compares with =.

public Compare<T, TConverter> Eq(T value)

Parameters

value T

The value.

Returns

Compare<T, TConverter>

The condition.

Exists()

Checks with attribute_exists. An attribute with the DynamoDB null value exists.

public AttributeExists Exists()

Returns

AttributeExists

The condition.

Ge(T)

Compares with >=. Strings compare by their UTF-8 bytes.

public Compare<T, TConverter> Ge(T value)

Parameters

value T

The value.

Returns

Compare<T, TConverter>

The condition.

Gt(T)

Compares with >. Strings compare by their UTF-8 bytes.

public Compare<T, TConverter> Gt(T value)

Parameters

value T

The value.

Returns

Compare<T, TConverter>

The condition.

Le(T)

Compares with <=. Strings compare by their UTF-8 bytes.

public Compare<T, TConverter> Le(T value)

Parameters

value T

The value.

Returns

Compare<T, TConverter>

The condition.

Lt(T)

Compares with <. Strings compare by their UTF-8 bytes.

public Compare<T, TConverter> Lt(T value)

Parameters

value T

The value.

Returns

Compare<T, TConverter>

The condition.

Ne(T)

Compares with <>. It holds for an attribute that does not exist.

public Compare<T, TConverter> Ne(T value)

Parameters

value T

The value.

Returns

Compare<T, TConverter>

The condition.

NotExists()

Checks with attribute_not_exists. An attribute with the DynamoDB null value exists.

public AttributeExists NotExists()

Returns

AttributeExists

The condition.

NotExistsOrLe(T)

Checks that the attribute is missing or at most a value, (attribute_not_exists(a) OR a <= :v), which is NotExists().Or(Le(value)): the guard of something free or expired, such as a lease whose end is at or before now. See NotExistsOrLt(T).

public Or<AttributeExists, Compare<T, TConverter>> NotExistsOrLe(T value)

Parameters

value T

The value the stored one may not exceed.

Returns

Or<AttributeExists, Compare<T, TConverter>>

The condition.

NotExistsOrLt(T)

Checks that the attribute is missing or below a value, (attribute_not_exists(a) OR a < :v): the guard of a write that must never move an item back.

public Or<AttributeExists, Compare<T, TConverter>> NotExistsOrLt(T value)

Parameters

value T

The value the stored one has to be below, such as the version or the time of the event that is written.

Returns

Or<AttributeExists, Compare<T, TConverter>>

The condition.

Remarks

It is NotExists().Or(Lt(value)). .If(Order.Attrs.PlacedAt.NotExistsOrLt(order.PlacedAt)) stores an event only when the item holds an older one, or none, so an event that arrives late or twice fails the condition. An item that does not exist passes, and so does one without the attribute. The DynamoDB null value is an attribute that exists and compares with nothing, so an item that holds it fails.

ToString()

Returns the path.

public override string ToString()

Returns

string

The path.

Value(T)

Makes a value of this attribute for a hole of an interpolated expression: $"{attr} = {attr.Value(x)}".

public Arg<T, TConverter> Value(T value)

Parameters

value T

The value.

Returns

Arg<T, TConverter>

The value with its converter.

Operators

implicit operator Attr(Attr<T, TConverter>)

Converts the attribute to one without a type, for what takes attributes of different types, such as a projection. There is no conversion to a string: it would turn a value of the wrong type in Set(attribute, value) into a call with a path that compiles.

public static implicit operator Attr(Attr<T, TConverter> attribute)

Parameters

attribute Attr<T, TConverter>

The attribute.

Returns

Attr