public Order Get(Guid id) { using (var connection = new SqlConnection(SqlConnectionLocator.LocalhostSqlExpress())) { var domainEvents = connection .Query<OrderEvent>(SqlQueries.SelectOrderEventQuery, new {id}) .OrderBy(x => x.CreationDate) .ToArray() .Select(ConvertToDomainEvent) .ToArray(); var order = new Order(); order.Replay(domainEvents); if (order.IsDeleted) { return null; } return order; } }
public Order Get(Guid id) { using (var dataContext = new DataContext()) { var domainEvents = dataContext .Set<OrderEvent>() .Where(x => x.AggregateId == id) .OrderBy(x => x.CreationDate) .ToArray() .Select(ConvertToDomainEvent) .ToArray(); var order = new Order(); order.Replay(domainEvents); if (order.IsDeleted) { return null; } return order; } }