Minor clean-up in Ordering Context
This commit is contained in:
parent
625f53213b
commit
a88fbf339f
@ -7,8 +7,7 @@ using System;
|
||||
|
||||
namespace Ordering.Infrastructure.EntityConfigurations
|
||||
{
|
||||
class OrderEntityTypeConfiguration
|
||||
: IEntityTypeConfiguration<Order>
|
||||
class OrderEntityTypeConfiguration : IEntityTypeConfiguration<Order>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Order> orderConfiguration)
|
||||
{
|
||||
@ -21,6 +20,7 @@ namespace Ordering.Infrastructure.EntityConfigurations
|
||||
orderConfiguration.Property(o => o.Id)
|
||||
.ForSqlServerUseSequenceHiLo("orderseq", OrderingContext.DEFAULT_SCHEMA);
|
||||
|
||||
//Address value object persisted as owned entity type supported since EF Core 2.0
|
||||
orderConfiguration.OwnsOne(o => o.Address);
|
||||
|
||||
orderConfiguration.Property<DateTime>("OrderDate").IsRequired();
|
||||
@ -32,7 +32,7 @@ namespace Ordering.Infrastructure.EntityConfigurations
|
||||
var navigation = orderConfiguration.Metadata.FindNavigation(nameof(Order.OrderItems));
|
||||
|
||||
// DDD Patterns comment:
|
||||
//Set as Field (New since EF 1.1) to access the OrderItem collection property through its field
|
||||
//Set as field (New since EF 1.1) to access the OrderItem collection property through its field
|
||||
navigation.SetPropertyAccessMode(PropertyAccessMode.Field);
|
||||
|
||||
orderConfiguration.HasOne<PaymentMethod>()
|
||||
|
@ -12,22 +12,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
|
||||
{
|
||||
public class OrderingContext
|
||||
: DbContext,IUnitOfWork
|
||||
|
||||
public class OrderingContext : DbContext,IUnitOfWork
|
||||
{
|
||||
public const string DEFAULT_SCHEMA = "ordering";
|
||||
|
||||
public DbSet<Order> Orders { get; set; }
|
||||
|
||||
public DbSet<OrderItem> OrderItems { get; set; }
|
||||
|
||||
public DbSet<PaymentMethod> Payments { get; set; }
|
||||
|
||||
public DbSet<Buyer> Buyers { get; set; }
|
||||
|
||||
public DbSet<CardType> CardTypes { get; set; }
|
||||
|
||||
public DbSet<OrderStatus> OrderStatus { get; set; }
|
||||
|
||||
private readonly IMediator _mediator;
|
||||
@ -63,7 +55,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
|
||||
// You will need to handle eventual consistency and compensatory actions in case of failures in any of the Handlers.
|
||||
await _mediator.DispatchDomainEventsAsync(this);
|
||||
|
||||
|
||||
// After executing this line all the changes (from the Command Handler and Domain Event Handlers)
|
||||
// performed throught the DbContext will be commited
|
||||
var result = await base.SaveChangesAsync();
|
||||
|
Loading…
x
Reference in New Issue
Block a user