public async Task InsertAsync(T data) { var mState = new MongoState <K>(); mState.StateId = data.StateId; mState.Id = ObjectId.GenerateNewId().ToString(); using (var ms = new PooledMemoryStream()) { Serializer.Serialize <T>(ms, data); mState.Data = ms.ToArray(); } if (mState.Data != null && mState.Data.Count() > 0) { await mongoStorage.GetCollection <MongoState <K> >(database, collection).InsertOneAsync(mState, null, new CancellationTokenSource(3000).Token); } }
public async Task InsertAsync(T data) { var mState = new MongoState <K> { StateId = data.StateId, Id = ObjectId.GenerateNewId().ToString(), Version = data.Version }; using (var ms = new PooledMemoryStream()) { Serializer.Serialize <T>(ms, data); mState.Data = ms.ToArray(); } if (mState.Data != null && mState.Data.Count() > 0) { await grainConfig.Storage.GetCollection <MongoState <K> >(grainConfig.DataBase, grainConfig.SnapshotCollection).InsertOneAsync(mState, null, new CancellationTokenSource(3000).Token); } }