Пример #1
0
 protected override void Act()
 {
     using (Reader)
     {
         Document = CsvDocument.CreateFrom(Reader, Options);
     }
 }
Пример #2
0
        private static void SeedComments(StoryBlogDbContext context, Assembly resourceAssembly, ILogger logger)
        {
            var resource = resourceAssembly.GetManifestResourceStream("StoryBlog.Web.Services.Blog.API.Data.Comments.csv");

            using (var reader = new StreamReader(resource, Encoding.UTF8))
            {
                var document = CsvDocument.CreateFrom(reader);

                using (var transaction = context.Database.BeginTransaction())
                {
                    foreach (var row in document.Rows)
                    {
                        var comment = CreateCommentFromRow(context, row);
                        logger.LogDebug($"[SeedComment] Comment \'{comment.Id}\' created");
                    }

                    transaction.Commit();
                }
            }
        }