public override void InsertSet(IEnumerable <CreditCard> toInsert, int batchSize)
 {
     using (var ctx = new AWDataContext(this.ConnectionStringToUse, batchSize))
     {
         ctx.CreditCards.AddRange(toInsert);
         ctx.SaveChanges();
     }
 }
Пример #2
0
        public ActionResult Products_Create([DataSourceRequest] DataSourceRequest request, Product product)
        {
            if (ModelState.IsValid)
            {
                var entity = new Product
                {
                    Name                  = product.Name,
                    ProductNumber         = product.ProductNumber,
                    MakeFlag              = product.MakeFlag,
                    FinishedGoodsFlag     = product.FinishedGoodsFlag,
                    Color                 = product.Color,
                    SafetyStockLevel      = product.SafetyStockLevel,
                    ReorderPoint          = product.ReorderPoint,
                    StandardCost          = product.StandardCost,
                    ListPrice             = product.ListPrice,
                    Size                  = product.Size,
                    SizeUnitMeasureCode   = product.SizeUnitMeasureCode,
                    WeightUnitMeasureCode = product.WeightUnitMeasureCode,
                    Weight                = product.Weight,
                    DaysToManufacture     = product.DaysToManufacture,
                    ProductLine           = product.ProductLine,
                    Class                 = product.Class,
                    Style                 = product.Style,
                    ProductSubcategoryID  = product.ProductSubcategoryID,
                    ProductModelID        = product.ProductModelID,
                    SellStartDate         = product.SellStartDate,
                    SellEndDate           = product.SellEndDate,
                    DiscontinuedDate      = product.DiscontinuedDate,
                    rowguid               = product.rowguid,
                    ModifiedDate          = product.ModifiedDate
                };

                db.Products.Add(entity);
                db.SaveChanges();
                product.ProductID = entity.ProductID;
            }

            return(Json(new[] { product }.ToDataSourceResult(request, ModelState)));
        }