public void t() { var reader = new ExcelFileReader(); var itmes = reader.ReadDistinctBrands( @"D:\dev\C#\ExposurePresenter\XLSInputFiles\PLK Grzegorz branże.xlsx").ToArray(); // var db = new ExposureDb(); // foreach (var item in itmes) // { // db.ExposureRecords.Add(item); // } }
public void PopulateData(string filePath, ExposureDb db) { var fileReader = new ExcelFileReader(); db.Branches.AddOrUpdate(branch => branch.Name, fileReader.ReadDistinctBrnaches(filePath).ToArray()); db.Brands.AddOrUpdate(brand => brand.Name, fileReader.ReadDistinctBrands(filePath).ToArray()); db.Disciplines.AddOrUpdate(discipline => discipline.Name, fileReader.ReadDistinctDisciplines(filePath).ToArray()); var records = fileReader.ReadExposureRecords(filePath).ToArray(); foreach (var exposureRecord in records) { db.ExposureRecords.AddOrUpdate(record => new { record.Brand, record.Month }, exposureRecord); db.SaveChanges(); } }