大家好,我的 3 层应用程序有问题我不知道如何在 3 层架构应用程序中使用 linq2sql 从多个表中获取数据这里是每一层的代码
GestionProjet通用项目
客户类别:
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; }
}
}
项目类:
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 项目
GestionProjetDA 类:
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
}
}
}
GestionProjet商业项目
GestionProjetB 类:
public class GestionProjetB
{
private GestionProjetDAL.GestionProjetDA GPDA = new GestionProjetDAL.GestionProjetDA();
public List<Client> GetClients()
{
return GPDA.GetClients();
}
//Here i Should put the 2nd Method
}
正如你所看到的,我从一个表中获取数据没有问题,但唯一的问题是从多个表中获取数据。
我整晚都在寻找解决方案,但我没有找到,请帮助我,谢谢