SHARE
TWEET

Untitled

EraCoder Apr 26th, 2018 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data.Entity;
  6.  
  7. namespace DtabaseConnect.CRUD
  8. {
  9.     public static class CUD
  10.     {
  11.         static Context.DigitalServiceContext digitalServiceContext = new Context.DigitalServiceContext();
  12.         public static void ModifyEntity(Object Object)
  13.         {
  14.            digitalServiceContext.Entry(Object).State = EntityState.Modified;
  15.            digitalServiceContext.SaveChanges();
  16.  
  17.         }
  18.  
  19.         public static void DeleteEntity(Object Object)
  20.         {
  21.             digitalServiceContext.Entry(Object).State = EntityState.Deleted;
  22.             digitalServiceContext.SaveChanges();
  23.         }
  24.  
  25.         public static void AddEntity(Object Object)
  26.         {
  27.             digitalServiceContext.Entry(Object).State = EntityState.Added;
  28.             digitalServiceContext.SaveChanges();
  29.         }
  30.     }
  31.  
  32.     public static class CUDRoot
  33.     {
  34.         public static void ModifyEntity(Object Object)
  35.         {
  36.             Connection.SetDatabaseConnection.SetRoot();
  37.             Context.DigitalServiceContext digitalServiceContext = new Context.DigitalServiceContext();
  38.             digitalServiceContext.Entry(Object).State = EntityState.Modified;
  39.             digitalServiceContext.SaveChanges();
  40.             Connection.SetDatabaseConnection.UnsetRoot();
  41.  
  42.         }
  43.  
  44.         public static void DeleteEntity(Object Object)
  45.         {
  46.             Connection.SetDatabaseConnection.SetRoot();
  47.             Context.DigitalServiceContext digitalServiceContext = new Context.DigitalServiceContext();
  48.             digitalServiceContext.Entry(Object).State = EntityState.Deleted;
  49.             digitalServiceContext.SaveChanges();
  50.             Connection.SetDatabaseConnection.UnsetRoot();
  51.         }
  52.  
  53.         public static void AddEntity(Object Object)
  54.         {
  55.             Connection.SetDatabaseConnection.SetRoot();
  56.             Context.DigitalServiceContext digitalServiceContext = new Context.DigitalServiceContext();
  57.             digitalServiceContext.Entry(Object).State = EntityState.Added;
  58.             digitalServiceContext.SaveChanges();
  59.             Connection.SetDatabaseConnection.UnsetRoot();
  60.         }
  61.     }
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top