When writing a DAL in a .NET application, it was decided to use the CodeFirst approach of EF6. There is an entity class - client:
public class Client { public int ClientId { get; set; } //PK //... //address properties: public string City { get; set; } public string Street { get; set; } public string House { get; set; } public string Flat { get; set; } //... }
From the point of view of the OO approach, it makes sense to encapsulate the properties related to the address of the object in a separate class for the convenience of accessing the object itself in the code, then the code will look like this:
public class Client { public int ClientId { get; set; } //PK //... public int AddressId { get; set; } public Address Address { get; set; } //... } public class Address { public int AddressId { get; set; } //PK public string City { get; set; } public string Street { get; set; } public string House { get; set; } public string Flat { get; set; } }
And everything seems to be fine, but you need to store in the database itself the fields with the address value as regular columns for each client in the table containing the client data, and not allocate a separate table for the addresses. But at the same time, in the code itself I would like to encapsulate the fields in a separate class. Can this be done with Fluent API or DA? And is it even possible? Thank.
Address
stored separately, I would still break it onCity
,Street
i.e. separate directories and otherwise get ready to overcome the difficulties that you are laying yourself. and what you want is possible, but better do it right - Bald