Beispiel #1
0
                public bool MoveNext()
                {
                    if (context == null)
                    {
                        context = new MessageLogDbContext(sqlQuery.nameOrConnectionString);
                        var queryable = context.Set <MessageLogEntity>().AsQueryable()
                                        .Where(x => x.Kind == StandardMetadata.CommandKind);

                        var where = sqlQuery.criteria.ToExpression();
                        if (where != null)
                        {
                            queryable = queryable.Where(where);
                        }

                        commands = queryable
                                   .AsEnumerable()
                                   .Select(x => this.sqlQuery.serializer.Deserialize <ICommand>(x.Payload))
                                   .GetEnumerator();
                    }

                    return(commands.MoveNext());
                }
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.Serialize <string>(command),
                });
                context.SaveChanges();
            }
        }