c# - mvc3 getting a DB model remove error -


i doing database check see if rows expired getting system.data.entity.dbset error on db.servicers.remove(servicer) saying piece of code has invalid arguments .my little code is

var servicer = (from s in db.servicers                 datetime.now >= s.expired select s).tolist();          if (servicer.any())         {             db.servicers.remove(servicer);             db.savechanges();         } 

the expired field datetime , want loop database , delete record expires today or has expired; whats best way solve error.

like lews therin said remove takes type t should enumerate list.

var servicer = (from s in db.servicers                 datetime.now >= s.expired select s).tolist();      if (servicer.any())     {         foreach(var s in servicer)          {             db.servicers.remove(s);         }         db.savechanges();     } 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -