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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:16:55+00:00 2026-05-22T23:16:55+00:00

hello everyone i have a problem with my 3-tiers application i don’t know how

  • 0

hello everyone i have a problem with my 3-tiers application i don’t know how to get data from multiple tables using linq2sql in 3 tiers architecture application here is each layers code

GestionProjetCommon Project

Client Class :

public class Client
{
    private int _ID;
    public int ID
    {
        get { return _ID; }
        set { _ID = value; }
    }
    private string _Name;
    public string Name
    {
        get { return _Name; }
        set { _Name = value; }
    }

}

Project Class :

public class Projet
{
    private int _ID;
    public int ID
    {
        get { return _ID; }
        set { _ID = value; }
    }
    private string _Title;
    public string Title        {

        get { return _Title; }
        set { _Title= value; }

    }

   private int _IDClient;
    public int IDClient
    {
        get { return _IDClient; }
        set { _IDClient = value; }
    }
}

GestionProjetDAL Project

GestionProjetDA Class :

public class GestionProjetDA
{
    private GestionProjetDADataContext db = new GestionProjetDADataContext();
    public List<GestionProjet.Client> GetClients() //This Works Fine No Problem !
    {
        var req = from clt in db.Clients select clt;

        List<GestionProjet.Client> clientList = new List<GestionProjet.Client>();
        foreach (Clients item in req)
        {
            clientList.Add(new GestionProjet.Client() { ID = item.ID, Nom = item.Nom });
        }
        return clientList;
    }

public List<GestionProjet.Client> GetProjectClient()
    {
        var req = from prj in db.Projets
                  from clt in db.Clients
                  where clt.ID == prj.IDClient
                                  select new
                                  {
                                      Name=clt.Name,
                                      Projet = prj.Title,
                                  };
        List<GestionProjet.Client> clientProjectList = new List<GestionProjet.Client>();
      foreach (var clt in req)
        {
//I Don't know what to do in here and get the Data From both of the Tables
        }

    }
 }

GestionProjetBusiness Project

GestionProjetB Class :

 public class GestionProjetB
{
    private GestionProjetDAL.GestionProjetDA GPDA = new GestionProjetDAL.GestionProjetDA();

    public List<Client> GetClients()
    {
        return GPDA.GetClients();
    }

  //Here i Should put the 2nd Method

}

Well as you can see i have no problem with getting data from one table but the only problem is getting it from multiple tables.

i’ve been look for a solution the whole night but i didn’t find it please help me
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-22T23:16:57+00:00Added an answer on May 22, 2026 at 11:16 pm

    Create a DTO class,
    something like:

    public class ClientDTO
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public string ProjectName { get; set; }
        }
    

    now write a good linq expression to fill the DTO class:

     public List<GestionProjet.Client> GetProjectClient()
        {
            return (from prj in db.Projets
                      join clt in db.Clients on prj.IDClient equals clt.ID
                                      select new ClientDTO
                                      {
                                          Name = clt.Name,
                                          ProjetName = prj.Title,
                                          ID = clt.ID
                                      }).ToList();
    
        }
    

    I hope I understood your problem right, and pardon me for not testing the code before posting.

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

Sidebar

Related Questions

Hello everyone and thanks in advance. I have a problem and I have 2
hello everyone I have some problem with understanding this piece of the code: import
Hello everyone is there any possibly to fetch data from mysql databases in javascript
Hello we have an SQL server application running over a low bandwith connection. We
Hello everyone Masters Of Web Delevopment :) I have a piece of PHP script
Introduction : Hello Everyone, I have been looking for days for a way to
Some details XAMPP 1.7.1 OS tested on vista and xp Hello everyone. I have
Hello wonderful people of stackoverflow! I have a problem. I am working on an
THIS PROBLEM IS NOW SOLVED. THANK YOU TO EVERYONE WHO REPLIED. Hello, I am
hello everyone I have 3 files: engine script #! /bin/tcsh -f cat $1 |./hello

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.