开发者

Entity Framework 4 Design Question

开发者 https://www.devze.com 2023-02-10 01:40 出处:网络
I need a little advice on how to best solve this issue please. I have Customer, CustomerLocations, SalesOrder, and Invoice entities.

I need a little advice on how to best solve this issue please.

I have Customer, CustomerLocations, SalesOrder, and Invoice entities.

The customer needs to be able to have multiple billing/shipping address, per customer and per location, sort of like an address book. Simple!!

The SalesOrder and Invoice objects need to be able to store these addresses when created. Again, simple!!

Here is the deal though, I don't want to use a foreign key on the salesorder or invoice items, but the actual fields of the address (Line1, Line2, City, State....).

What would be the best way to solve this?

Update

How about this?

Entity Framework 4 Design Question

Or

Entity Framework 4 Design Question

and then you could access it like this:

Partial Public Class Customer

Public ReadOnly Property DefaultBillingAddress As Address
    Get
        Return Locations.First(Function(x) x.IsDefault).BillingAddresses.First(Function(x) x.IsDefault)
  开发者_运维技巧  End Get
End Property

Public ReadOnly Property DefaultShippingAddress As Address
    Get
        Return Locations.First(Function(x) x.IsDefault).ShippingAddresses.First(Function(x) x.IsDefault)
    End Get
End Property

End Class

0

精彩评论

暂无评论...
验证码 换一张
取 消