static void Main(string[] args) { var recordsPath = @$ "{Environment.CurrentDirectory}/text.csv"; var dataSource = @"(LocalDB)\MSSQLLocalDB"; var databaseFilename = @$ "{Directory.GetCurrentDirectory()}\WorkDatabase.mdf"; var connString = $@"Data Source={dataSource};AttachDbFilename={databaseFilename};Integrated Security=True;MultipleActiveResultSets=True"; CreateRecords(recordsPath); using (var csvRecords = new CsvEnumerable <Record>(recordsPath)) { var consoleLogger = new Logger(); using (IRepository <Record> repository = LoggingProxy <IRepository <Record> > .CreateInstance(new MSSQLLocalDBRepository(connString), consoleLogger)) { var tasks = new List <Task <int> >(); foreach (var record in csvRecords) { Console.WriteLine($"Name = {record.Name}, Number = {record.Number}"); tasks.Add(repository.CreateAsync(record)); } Task.WaitAll(tasks.ToArray()); } } }
static void Main(string[] args) { IRepository <Person> repository = LoggingProxy <IRepository <Person> > .CreateInstance(new Repository <Person>()); CsvEnumerable <Person> csvList = new CsvEnumerable <Person>(AppSettingsProvider.GetInstance().Settings.CsvFileName); try { foreach (Person p in csvList) { repository.Add(p); } } catch (Exception ex) { Console.Write(ex); } }