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 798491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:58:46+00:00 2026-05-14T22:58:46+00:00

I have three tables as shown below Emp —- empID int empName deptID empDetails

  • 0

I have three tables as shown below

Emp
----
empID int 
empName
deptID


empDetails
-----------
empDetailsID int
empID int

empDocuments
--------------
docID
empID
docName
docType

I am creating a entity class so that I can use n-tier architecture to do database transactions etc in C#. I started creating class for the same as shown below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace employee
{
    class emp
    {
        private int empID;
        private string  empName;
        private int deptID;

        public int EmpID { get; set; }
        public string EmpName { get; set; }
        public int deptID { get; set; }

    }
}

My question is as empDetails and empDocuments are related to emp by empID. How do I have those in my emp class.

I would appreciate if you can direct me to an example.

Thanks

  • 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-14T22:58:47+00:00Added an answer on May 14, 2026 at 10:58 pm

    Tables which contain a foreign key normally represent a greater entity’s details.

    Both EmpDetails and EmpDocuments represent a different detail level of your greater entity Emp.

    Since you may have many documents and many details for each Emp instance, your details tables shall be gathered as a list inside of your emp class.

    public class emp {
        public int Id { get; set; }
        public string Name { get; set; }
        public int DepartmentId { get; set; }
        public IList<empDetail> Details { 
            get {
                return _details;
            }
        }
        private IList<empDetail> _details;
        public IList<empDocument> Documents {
            get {
                return _documents;
            }
        }
        private IList<empDocument> _documents;
    }
    

    Using NHibernate, you could simply don’t care about your database relational model and have this tool generate your database relational schema automatically using the SchemaExportTool from your class diagram through XML mapping files (Follow this link for an overview).

    There are multiple plugins, if we may call them so, to NHibernate such as Fluent NHibernate (FNH), Linq to NHibernate.

    Here are some useful links which shall help you get acquainted with it:

    1. NHibernate Reference Documentation
    2. Basic O/R mapping
    3. ISessionFactory Configuration
    4. Speaking of architecture : NHibernate Architecture
    5. Collection Mapping –> Pretty useful for mapping your two empDetail and empDocument collections within your emp entity class.
    6. A Nice Tutorial

    A few advantages of using NHibernate:

    1. Never get bothered designing a relational model again;
    2. Don’t bother about the underlying datastore, NHibernate supports multiple database engines by simple XML configuration file (no need to recompile the application for any of the underlying databases);
    3. Increase your development by easily from 25% to 50% or over once you master NHibernate;

    Otherwise, there is also Microsoft Enterprise Library which I often use in conjunction with NHibernate, or depending on the projects, I may prefer only use EntLib with the different application blocks:

    1. Data Access Application Block;
    2. Exception Handling Application Block;
    3. Logging Application Block;
    4. Security Application Block;
    5. Unity Application Block;

    And I may forget some others…

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

Sidebar

Related Questions

I have three simple tables as shown below: +----+-------------+ +----+-----------+ +----+---------------+ | artists |
I have three tables with a one to many relationship as shown below. What
I have three tables specifying important columns below Users(Id, username) Groups(Id, groupname, creator) (creator
I have couple of tables in my Oracle database as shown below **IM_FP** FP_ID
I have orders and order details table as shown as below: OrderDetails Order_ID int
I have two tables afrostarprofiles and afrostarvvideos created as shown below. artistid field in
I have three tables A: A.pID primary key, A.Name nvarchar(250) B: B.pID primary key,
I have three tables: videos, videos_categories, and categories. The tables look like this: videos:
I have three tables of information where the business_id is the common thread. I
I have three tables being used for this problem: songs, blacklist, and whitelist. The

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.