Ejemplo n.º 1
0
        public void RunInTransaction(TransactionalOperation <WebisellSqlServerDbContext> operation)
        {
            OpenConnection();
            // Run an EF Core command in the transaction
            var options = new DbContextOptionsBuilder <WebisellSqlServerDbContext>()
                          .UseSqlServer(_connection)
                          .Options;

            using (var context = new WebisellSqlServerDbContext(options))
            {
                context.Database.UseTransaction(_transaction);
                operation(context);
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public List <Product> GetProducts(int categoryId)
        {
            using (var context = new WebisellSqlServerDbContext())
            {
                return(context.Products.FromSql($@"
                    SELECT  ProductId,
		                Id as SpecificTableProductId, 
                        {0} as CategoryId,
		                Name,
		                price as Price,
		                Available,
		                Data as JsonData
                    FROM Products_{0}
                    ", categoryId)
                       .ToList());
            }
        }