将SQL转换为LINQ格式where子句

时间:2012-09-06 10:03:24

标签: c# .net sql linq sql-to-linq-conversion

 Qry = "select childID,ChildEmail,ChildUserID, ChildPassword from ChildProfile ";
 Qry = Qry + " where ucase(ChildFName) = '" 
           + Strings.UCase(Strings.Trim(Txtname.Text)) 
           + "' and ucase(childlname) = '" 
           + Strings.UCase(Strings.Trim(txtSurName.Text)) 
           + "' and childmobile = '" 
           + Strings.Trim(txtMobile.Text) + "'";

我们如何将此查询转换为LINQ

List<PatientDTO> lstChildProf = objService.GetAllPatient();
    lstChildProf = new List<PatientDTO>(
        from l in lstChildProf where 
        );

不知道怎么写这里的where子句

请帮忙

1 个答案:

答案 0 :(得分:1)

类似的东西:

List<PatientDTO> lstChildProf = objService.GetAllPatient()
    .Where( l => l.ChildFName == Strings.UCase(Strings.Trim(Txtname.Text))
            && l.ChildName == Strings.UCase(Strings.Trim(txtSurName.Text)) 
            && l.chiuldMob == Strings.Trim(txtMobile.Text))
    .ToList<PatientDTO>();