我对实体查询非常陌生,我想将此sql查询转换为实体查询:
select A1.PrID,A3.Pr_Nom, A1.MpID, A2.Mp_Designation, A1.PR_Mp_etat, A1.Pr_Mp_quantite
from Pr_Mp A1, MatierePremiere A2, Projet A3
where A1.MpID = A2.MpID
and A3.PrID=A1.PrID
and A3.Pr_Nom= 'projet1'
我想从这个查询得到的是检索Mp_designation和MpID(从表matierePremiere中检索数据)
这是我的表格:
public partial class MatierePremiere
{
public MatierePremiere()
{
this.Commandes = new List<Commande>();
this.Pr_Mp = new List<Pr_Mp>();
}
public int MpID { get; set; }
public string Mp_Designation { get; set; }
public virtual ICollection<Commande> Commandes { get; set; }
public virtual ICollection<Pr_Mp> Pr_Mp { get; set; }
}
public partial class Pr_Mp
{
public int PrID { get; set; }
public int MpID { get; set; }
public string Pr_Mp_etat { get; set; }
public double Pr_Mp_quantite { get; set; }
public virtual MatierePremiere MatierePremiere { get; set; }
public virtual Projet Projet { get; set; }
}
public partial class Projet
{
public Projet()
{
this.Personnel_Projet = new List<Personnel_Projet>();
this.Pr_Mp = new List<Pr_Mp>();
}
public int PrID { get; set; }
public string Pr_Nom { get; set; }
public System.DateTime Pr_Date_Debut { get; set; }
public System.DateTime Pr_Date_Fin { get; set; }
public string Pr_Statut { get; set; }
public Nullable<System.DateTime> Pr_Tps_Estime { get; set; }
public Nullable<double> Pr_cout_Estime { get; set; }
public string Pr_Adresse_Terrain { get; set; }
public double Pr_Superficie_Terrain { get; set; }
public string Tech_Cin_Directeur_Technique { get; set; }
public string Tech_Cin_Responsable_projet { get; set; }
public string Tech_Cin_Architecte_Pilote { get; set; }
public System.DateTime created_date { get; set; }
public virtual ICollection<Personnel_Projet> Personnel_Projet { get; set; }
public virtual ICollection<Pr_Mp> Pr_Mp { get; set; }
}
我尝试了这个查询:
(from prMp in Pr_Mp
join mp in MatierePremieres
on prMp.MpID equals mp.MpID
join pr in Projets
on prMp.PrID equals pr.PrID
where pr.Pr_Nom=="projetTest"
select prMp.Pr_Mp_etat, mp.Mp_Designation, pr.pr_Nom)
.ToList()