如何编写预编译查询?

时间:2014-02-10 05:56:32

标签: c# sql linq

有人可以帮助为以下代码编写预编译查询吗?

Modal.StaffNo def = Staff.StaffNo.Where(a =>
 a.Number1 == number1 && a.Number2 == number2
 ).FirstOrDefault();

感谢!!!

2 个答案:

答案 0 :(得分:0)

您可以编写上面这样的linq查询。

SELECT TOP 1 * FROM StaffNo Where number1=@number1 and number2=@number2

答案 1 :(得分:0)

试试这个,希望我能帮到你:

Modal.StaffNo def = (from o in Staff.StaffNo where o.Number1 == number1 && o.Number2 == number2 select o).FirstOrDefault();