c# - How can I find that a record successfully deleted from Db using LINQ -
i'm using linq-to-sql, , wrote block delete record in database. executenonquery returns integer value, , value can find if record deleted or not. how can linq? example in code:
aspnetdbdatacontext aspdb = new aspnetdbdatacontext(); var res=from p in aspdb.trackpoints p.routefk==routeid select p; aspdb.trackpoints.deleteonsubmit(res.first()); aspdb.submitchanges();
system.data.linq.changeset cs = aspdb.getchangeset(); bool isdeleted = cs.deletes.count() == 0;
here if cs.deletes equal 0 means has been ok , row deleted if greater zero, mean there records have not been deleted successfully
Comments
Post a Comment