Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6845813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:32:49+00:00 2026-05-27T00:32:49+00:00

I’m trying to learn proper way of defining classes. I have two classes where

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:32:49+00:00Added an answer on May 27, 2026 at 12:32 am

    There are various options here:

    O/R mapping

    Use a framework to generate your classes from the database layout. Extend the classes to add your own functionality and extra properties. Some frameworks to do this are:

    • Entity Framework
    • NHibernate
    • LLBLGen
    • LINQ to SQL using the O/R Designer

    Code your own

    You could also write your own queries, and while for the learning purposes (and sometimes for the sake of simplicity and less overhead and dependencies) it’s the less recommended approach. You could use a DataReader that you fill with the results of a query, and assign the properties manually:

    foo.Bar = dataReader["Bar"].ToString()
    

    The Enterprise Library can make things a bit easier here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.