flat database object vs object with relation properties - naming convention

41 Views Asked by At

I am in a struggle for naming my objects. I will start with an example.

I have a customer table in de the database. A object (short) version would look like this

public class CustomerModel

{
    public int CustomerID { get; set; }
    public int AddressID { get; set; }
    public string CustomerNumber { get; set; }
    public string CustomerGroup { get; set; }
}

As you can see the customer has a AddressID, which indicates that it has a relation to a address.

So I also wanted a second object for the customer that contains the Address object. Something like:

public class CustomerAddressModel : CustomerModel
    {
        public int AddressID => Address.AddressID;

        [Ignore]
        public AddressModel Address { get; set; }
    }

(p.s. I think I broke the inheritance in this example.)

The second object is called its base model + its child/relation model. Customer and Address, CustomerAddressModel. Personally I am not happy with this naming convention that I am using cause if the model had 10 relations, it would become a problem.

We use the 'Model' to indicate that its a database object and Dto for.. well data transfere. (and some more conventions)

What could be a good naming convention for objects that includes the relationship object(s) which gives the difference between a flat object.

p.s. using sqlkata if that gives any meaning.

0

There are 0 best solutions below