예제 #1
0
 public List <License> GetLicenses()
 {
     using (var context = new DotNetDemoContext())
     {
         var licenses = context.Licenses.ToList();
         return(licenses);
     }
 }
예제 #2
0
 public List <Organization> GetOrganizations()
 {
     using (var context = new DotNetDemoContext())
     {
         var organizations = context.Organizations.ToList();
         return(organizations);
     }
 }
예제 #3
0
        public async Task <bool> CreateUpdateOrganizationsAsync(List <Organization> organizations)
        {
            using (var context = new DotNetDemoContext())
            {
                context.Database.ExecuteSqlCommand("TRUNCATE TABLE [Organizations]");
                ((DbSet <Organization>)context.Organizations).AddRange(organizations);
                await context.SaveChangesAsync();

                return(true);
            }
        }
예제 #4
0
 public async Task <bool> CreateUpdateLicensesAsync(List <License> licenses)
 {
     using (var context = new DotNetDemoContext())
     {
         try
         {
             context.Database.ExecuteSqlCommand("TRUNCATE TABLE [Licenses]");
             ((DbSet <License>)context.Licenses).AddRange(licenses);
             await context.SaveChangesAsync();
         }
         catch (Exception ex)
         {
             throw;
         }
         return(true);
     }
 }