public void Dispose() { if (context != null) { context.Dispose(); context = null; GC.SuppressFinalize(this); } if (events != null) { events.Dispose(); } }
public void Save(ICommand command) { using (var context = new MessageLogDbContext(this.nameOrConnectionString)) { var metadata = this.metadataProvider.GetMetadata(command); context.Set <MessageLogEntity>().Add(new MessageLogEntity { Id = Guid.NewGuid(), SourceId = command.Id.ToString(), Kind = metadata.TryGetValue(StandardMetadata.Kind), AssemblyName = metadata.TryGetValue(StandardMetadata.AssemblyName), FullName = metadata.TryGetValue(StandardMetadata.FullName), Namespace = metadata.TryGetValue(StandardMetadata.Namespace), TypeName = metadata.TryGetValue(StandardMetadata.TypeName), SourceType = metadata.TryGetValue(StandardMetadata.SourceType) as string, CreationDate = DateTime.UtcNow.ToString("o"), Payload = serializer.Serialize(command), }); context.SaveChanges(); } }
public bool MoveNext() { if (context == null) { context = new MessageLogDbContext(sqlQuery.nameOrConnectionString); var queryable = context.Set <MessageLogEntity>().AsQueryable() .Where(x => x.Kind == StandardMetadata.EventKind); var where = sqlQuery.criteria.ToExpression(); if (where != null) { queryable = queryable.Where(where); } events = queryable .AsEnumerable() .Select(x => this.sqlQuery.serializer.Deserialize <IEvent>(x.Payload)) .GetEnumerator(); } return(events.MoveNext()); }