CQRSalad.EventStore.MongoDB.MongoSnapshotSerializer.GetIdFilter C# (CSharp) Method

GetIdFilter() public method

public GetIdFilter ( string id ) : bool>>.Expression
id string
return bool>>.Expression
        public Expression<Func<BsonDocument, bool>> GetIdFilter(string id)
        {
            return document => document[AggregateIdElement] == id;
        }

Usage Example

Example #1
0
        public async Task <AggregateSnapshot> LoadSnapshot(string aggregateId)
        {
            var snapshot = await GetCollection().Find(_snapshotSerializer.GetIdFilter(aggregateId)).FirstOrDefaultAsync();

            return(snapshot != null?_snapshotSerializer.Deserialize(snapshot) : null);
        }