RtRecordArrayItemUpdate
Namespace: Meshmakers.Octo.Runtime.Contracts
Describes the atomic update of one item of a RecordArray attribute: the item whose
RtRecordArrayItemUpdate.MatchMember equals RtRecordArrayItemUpdate.MatchValue gets the RtRecordArrayItemUpdate.MemberUpdates, every other
item and every other member stays untouched.
public sealed class RtRecordArrayItemUpdate
Inheritance Object → RtRecordArrayItemUpdate
Remarks:
The update is executed by the persistence layer as ONE atomic statement (MongoDB: $set with
arrayFilters on the match member). The stored entity is not read, there is no version check and no
retry. Concurrent updates of different items therefore never interfere; concurrent updates of the same item
keep the last write.
Use it when several writers change different items of the same RecordArray of one entity in parallel
(for example one DataPoint per state in Control.States). A read-modify-write of the whole array
(read the entity, change one item in memory, write the array back) loses concurrent changes.
Names (RtRecordArrayItemUpdate.AttributeName, RtRecordArrayItemUpdate.MatchMember, the keys of RtRecordArrayItemUpdate.MemberUpdates) are
PascalCase as in RtTypeWithAttributes.Attributes. Members of value type Secret are refused, the
match member cannot be updated by the same item update, and only scalar members (String, Int, Int64, Double,
Boolean, DateTime, DateTimeOffset, TimeSpan, Enum) are supported.
Properties
AttributeName
Name of the RecordArray attribute of the entity (PascalCase).
public string AttributeName { get; }
Property Value
MatchMember
Name of the record member that identifies the item (PascalCase), for example ExternalId.
public string MatchMember { get; }
Property Value
MatchValue
Value the RtRecordArrayItemUpdate.MatchMember of the item must have.
public object MatchValue { get; }
Property Value
MemberUpdates
Member name (PascalCase) to new value. Only these members of the matched item are written.
public IReadOnlyDictionary<string, object> MemberUpdates { get; }
Property Value
IReadOnlyDictionary<String, Object>
Constructors
RtRecordArrayItemUpdate(String, String, Object, IReadOnlyDictionary<String, Object>)
Creates a new item update.
public RtRecordArrayItemUpdate(string attributeName, string matchMember, object matchValue, IReadOnlyDictionary<string, object> memberUpdates)
Parameters
attributeName String
Name of the RecordArray attribute of the entity (PascalCase)
matchMember String
Name of the record member that identifies the item (PascalCase)
matchValue Object
Value of matchMember of the item to update; never null
memberUpdates IReadOnlyDictionary<String, Object>
Member name (PascalCase) to new value; at least one entry