none
Pre-compiled Queries RRS feed

  • Question

  • Sorry I am new to LINQ, 

    Can somebody help to write a pre-compiled query for the following code?

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

      

    Thanks!!!


    • Edited by FelixFliex Monday, February 10, 2014 5:37 AM
    Monday, February 10, 2014 3:34 AM

Answers

  • Hello,

    >>Can somebody help to write a pre-compiled query for the following code?

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

    If I guess correct, the “StaffNo” should be an entity, the Modal and Staff are both the instance of the Context, and I am confused that why it uses the different name, are they different instances or others?

    For the LINQ query, it should be similar to be below codes:

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

    If I misunderstand, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by FelixFliex Tuesday, February 11, 2014 9:32 AM
    Tuesday, February 11, 2014 7:47 AM
    Moderator