220
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
}
public
class
OrderDetails
{
public
Address BillingAddress {
get
;
set
; }
public
Address ShippingAddress {
get
;
set
; }
}
public
class
Address
{
public
string
Street {
get
;
set
; }
public
string
City {
get
;
set
; }
}
Additional details on owned entity types
•
Owned types are defined when you configure a navigation property to a particular type using
the OwnsOne fluent API.
•
The definition of an owned type in our metadata model is a composite of: the owner type, the
navigation property, and the CLR type of the owned type.
•
The identity (key) of an owned type instance in our stack is a composite of the identity of the
owner type and the definition of the owned type.
Owned entities capabilities
•
Owned types can reference other entities, either owned (nested owned types) or non-owned
(regular reference navigation properties to other entities).
•
You can map the same CLR type as different owned types in the same owner entity through
separate navigation properties.
•
Table splitting is set up by convention, but you can opt out by mapping the owned type to a
different table using ToTable.
•
Eager loading is performed automatically on owned types,
that is, there’s no need to call
.Include()
on the query.
•
Can be configured with attribute
[Owned]
, using EF Core 2.1 and later.
•
Can handle collections of owned types (using version 2.2 and later).
Dostları ilə paylaş: