I'm trying to learn proper way of defining classes. I have two classes where Person is definition for every possible information about person, while Client is using information from Person and is highely connected with Person.
public class Person {
public virtual int ID { get; set; }
public virtual string FirmaNazwa { get; set; }
public virtual string Imie { get; set; }
public virtual string Nazwisko { get; set; }
public virtual Adres Adres { get; set; }
public virtual Adres AdresKorespondencyjny { get; set; }
public virtual UrzadSkarbowy UrzadSkarbowy { get; set; }
public virtual string Pesel { get; set; }
public virtual string Nip { get; set; }
public virtual string Regon { get; set; }
public virtual string Krs { get; set; }
public virtual DateTime KrsData { get; set; }
public virtual string KrsOznaczenie { get; set; }
public virtual string Rodzaj { get; set; } // Typ klienta (Firma / Osoba)
public virtual string Narodowosc { get; set; }
public virtual string ZgodaNaPrzetwarzanieDanychOsobowych { get; set; }
public virtual string ZgodaNaPrzetwarzanieDanychOsobowychMarketing { get; set; }
public virtual Pracownik Uzytkownik { get; set; }
public virtual DateTime DataZmiany { get; set; }
}
public sealed class Client {
public int ID { get; set; }
public Person Person { get; set; }
public Pracownik Uzytkownik { get; set; }
public DateTime DataZmiany { get; set; }
public string Haslo { get; set; }
public string Typ { get; set; }
public void GetClient() {
}
}
I've got 2 tables in SQL which are basically Person and Client tables with fields that are similar to those defined in c#.
Now I would like to add some methods (GetClient() and similar) to actually get Client information but since to get all Client information I need to get all Person information first. In SQL I would do query with JOIN's and I kinda get Client info connected with Person info straight away. So do I basically do it like:
public void GetClient() {
//SQLQUERYHERE
Person podmiot = new Person();
podmiot.FirmaNazwa = ...
podmiot.Imie = ...
Haslo = "test";
}
Or should I do it differently?