首页 > 代码库 > Linq中使用like和if

Linq中使用like和if

 

                    //根据输入内容绑定工作令号下拉框值,匹配与输入内容相似的值                    var Tcn = (from ee in LinkToSQL.TasCom                               from ff in LinkToSQL.PerPla                               from gg in LinkToSQL.EmInfo                               where SqlMethods.Like(ee.TasComNum, "%" + txtTasComNum.Text.Trim() + "%")                               && ff.DesType == "常规"                               && gg.EmName==(ff.DrawPerson==null?ff.DesPerson:ff.DrawPerson)                               && ee.TasComID == ff.FK_TasComID                               && gg.NaWhoSp == "zhangmingming"                               && ee.IsDeleted == false                               select ee.TasComNum).Distinct();                    cbb_TasComNum.Items.Insert(0, "请选择");                    cbb_TasComNum.SelectedIndex = 0;                    cbb_TasComNum.Items.AddRange(Tcn.ToArray());