public static void RemoveRecord <T>(T recordToRemove) where T : class
        {
            // Retrieve BookCatalog instance in way
            // that's consistent with your DataContext strategy
            LivrariaDataContext ldc = new LivrariaDataContext();

            Table <T> tableData    = ldc.GetTable <T>();
            var       deleteRecord = tableData.SingleOrDefault(record => record == recordToRemove);

            if (deleteRecord != null)
            {
                tableData.DeleteOnSubmit(deleteRecord);
            }

            // If you created a new BookCatalog instance, submit it's changes here
            ldc.SubmitChanges();
        }
Example #2
0
 public List <Autoridade> Listar()
 {
     return(ldc.GetTable <Autoridade>().ToList());
 }