sequence contains no elements linq
  • I wrote this code but i am getting this error " 

    Sequence contains no elements

    " but the table PatientTreatmentTypes contains data.
    public static double GetTypeAmount(string type)
               var r = dbstatic.PatientTreatmentTypes.Where(x => x.Type == type).Single().ApprovedAmount;
              return r;
  • 2 Comments sorted by
  • use FirstOrDefault method and properly check your connection with database.
  • I have been using Single() and SingleOrDefault()  for a while now without any  problem.
    I am just curious why it is no longer working.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook


Popular Posts of the Week