Ejemplo n.º 1
0
 public void Dispose()
 {
     if (context != null)
     {
         context.Dispose();
         context = null;
         GC.SuppressFinalize(this);
     }
     if (events != null)
     {
         events.Dispose();
     }
 }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
                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());
                }