Beispiel #1
0
 public static void Insert(Branch branch)
 {
     using (PracticeContext context = new PracticeContext())
     {
         Repository <Branch> repository = new Repository <Branch>(context);
         repository.Insert(branch);
     }
 }
Beispiel #2
0
 public static void Insert(Student student)
 {
     using (PracticeContext context = new PracticeContext())
     {
         Repository <Student> repository = new Repository <Student>(context);
         repository.Insert(student);
     }
 }
Beispiel #3
0
 private async static Task <TResult> ExecuteAsync <T, TResult>(Func <Repository <T>, Task <TResult> > func) where T : class
 {
     using (PracticeContext context = new PracticeContext())
     {
         try
         {
             return(await func(new Repository <T>(context)));
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex);
             throw new Exception("Error Occured.");
         }
     }
 }
Beispiel #4
0
 private static void Execute <T>(Action <Repository <T> > action) where T : class
 {
     using (PracticeContext context = new PracticeContext())
     {
         try
         {
             action(new Repository <T>(context));
         }
         catch (SqlException ex)
         {
             Console.WriteLine(ex);
             throw new Exception("Error Occured.");
         }
     }
 }
Beispiel #5
0
 public Repository(PracticeContext context)
 {
     this.context = context;
 }