Activities of "mat.guthrie@loupa.io"

Hi,

When you say "it works perfectly" what do you mean? When I did exactly that, the Customer Entity didn't have a Address collection navigation property and it appeared to create a 1-1 relationship in CustomerWithNaviagtionProperties class. See below. That's not 1 Customer with Many addresses.

Your screenshots just illustrate the UI for creating Addresses. That's wasn't the question.

Further assistance would be appreciated. Thanks

Mat

public class Customer : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
    public virtual Guid? TenantId { get; set; }

    [CanBeNull]
    public virtual string Name { get; set; }
    public Guid? AddressId { get; set; }

    public Customer()
    {

    }

    public Customer(Guid id, Guid? addressId, string name)
    {

        Id = id;
        Check.Length(name, nameof(name), CustomerConsts.NameMaxLength, 0);
        Name = name;
        AddressId = addressId;
    }

}

public class CustomerWithNavigationProperties
{
    public Customer Customer { get; set; }

    public Address Address { get; set; }       

    
}

Hi,

NOTE: This is not an answer, just a follow-up question

Having gone through the free Implementing DDD pdf I see that the reason that navigation properties are not created is so as to remain database provider agnostic. I will only be using EF Core and SQL so this is not an issue for me. I note that the documentation says "If you think such features are important for you and you will never stray from the EF Core, we believe that it is worth stretching this principle."

Do you have any code samples that make use of entities with navigation properties? Normally I would just use AutoMapper to map the DTO to the entity and sub-entities, however is is not possible because the requirements use Guid as the identity. Is there anyway to get around this or a preferred method that doesn't involve setting every property manually. Something like:

CreateMap<AddressCreateDto, Address>().ConstructUsing(a => new Address(_guidGenerator.Create()));

An example of the type of entity relationships I'm trying to deal with would be as follows:

    public class Customer
    {
        public Guid Id { get; set; }
        public string Email { get; set; }
        public object FirstName { get; set; }
        public object LastName { get; set; }
        public int CurrencyId { get; set; }

        // Navigation Property
        public List<Address> Addresses { get; set; }

        // Navigation Property
        public Currency Currency { get; set; }

    }

    public class Address
    {
        public Guid Id { get; set; }
        public string Line1 { get; set; }

        public string City { get; set; }

        public string Zip { get; set; }
    }

    // Shared Reference Data
    public class Currency
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string IsoCode { get; set; }
    }

Any assistance or sample code would be very helpful.

Thanks

Mat

Hi,

Ok, I've been some more testing.

I'm calling CurrentTenant.Change() within an MVC page an it is correctly changing the TenantId.I am then calling the StoresAppService.CreateAsync();

If I check CurrentTenant.Id within the CreateAsync method it is null.

Any assistance would be appreciated.

Mat

顯示 3 個紀錄的 1 到 3 個.
Made with ❤️ on ABP v8.2.0-preview Updated on 3月 25, 2024, 15:11