コード例 #1
0
        public async Task InsertItemsSampleData(MesDbContext db)
        {
            var items = GetItems();

            db.Items.AddRange(items);
            try
            {
                int numAffected = await db.SaveChangesAsync();

                _Logger.LogInformation(@"Saved {numAffected} states");
            }
            catch (Exception exp)
            {
                _Logger.LogError($"Error in {nameof(MesDbSeeder)}: " + exp.Message);
                throw;
            }
        }
コード例 #2
0
 public ItemsRepository(MesDbContext context, ILoggerFactory loggerFactory)
 {
     _Context = context;
     _Logger  = loggerFactory.CreateLogger("ItemsRepository");
 }