Beispiel #1
0
 public void Dispose()
 {
     if (context != null)
     {
         context.Dispose();
         context = null;
         GC.SuppressFinalize(this);
     }
     if (events != null)
     {
         events.Dispose();
     }
 }
Beispiel #2
0
        public void Save(ICommand command)
        {
            using (var context = new MessageLogDbContext())
            {
                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.SerializeToString(command),
                });
                context.SaveChanges();
            }
        }
Beispiel #3
0
                public bool MoveNext()
                {
                    if (context == null)
                    {
                        context = new MessageLogDbContext();
                        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());
                }