当前位置: 首页>>代码示例>>C#>>正文


C# Product.Save方法代码示例

本文整理汇总了C#中Product.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Product.Save方法的具体用法?C# Product.Save怎么用?C# Product.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Product的用法示例。


在下文中一共展示了Product.Save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Acc_Update_Simple

        public void Acc_Update_Simple()
        {
            int records = new Update(Product.Schema).Set("UnitPrice").EqualTo(100).Where("productid").IsEqualTo(1).Execute();
            Assert.IsTrue(records == 1);

            //pull it back out
            Product p = new Product(1);
            Assert.IsTrue(p.UnitPrice == 100);

            //reset it to 50
            p.UnitPrice = 50;
            p.Save("unit test");
        }
开发者ID:bnewland1958,项目名称:SubSonic,代码行数:13,代码来源:UpdateTests.cs

示例2: Main

        static void Main()
        {
            ConvertUtilities.SetCurrentThreadCulture("en-US");
            Category category = new Category();
            category.Name = "EN: High-Tech";
            category.Save();
            Category.SaveLocalizedValues(category, 1036, false, "FR: High-Tech");

            Product product = new Product();
            product.Name = "Phone";
            product.Category = category;
            product.Save();

            Console.WriteLine(Product.LoadById(product.Id).Name);
            Console.WriteLine(Product.LoadById(product.Id).Name);

            ConvertUtilities.SetCurrentThreadCulture(1036);
            Console.WriteLine(Category.Load(category.Id).Name);
            Console.WriteLine(Category.Load(category.Id).Name);
            ConvertUtilities.SetCurrentThreadCulture(1033);
            Console.WriteLine(Category.Load(category.Id).Name);
            Console.WriteLine(Category.Load(category.Id).Name);
        }
开发者ID:modulexcite,项目名称:CodeFluent-Entities,代码行数:23,代码来源:Program.cs

示例3: Acc_Saving_String_Property_With_StringValue_Null_Results_In_NullValue_In_DB

        public void Acc_Saving_String_Property_With_StringValue_Null_Results_In_NullValue_In_DB()
        {
            Product p = new Product(2);
            p.QuantityPerUnit = "null";
            p.Save();

            p = new Product(2);
            Assert.IsNotNull(p.QuantityPerUnit);
            Assert.AreEqual("null", p.QuantityPerUnit);
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:10,代码来源:SelectTests.cs

示例4: GivenAModelWithADbReferenceProperty_FetchRef_ShouldReturnTheCorrectEntity

        public void GivenAModelWithADbReferenceProperty_FetchRef_ShouldReturnTheCorrectEntity()
        {
            var supplier = new Supplier { Name = "Acme" };
            supplier.Save();

            var product = new Product {
                Name = "Hammer",
                Price = "10",
                Supplier = new DbReference<Supplier>(supplier.Id)
            };
            product.Save();

            var fetchedRef = product.GetRef(x => x.Supplier);

            Assert.IsNotNull(fetchedRef);
            Assert.AreEqual(fetchedRef.Name, supplier.Name);
        }
开发者ID:efbenson,项目名称:NoRMatic,代码行数:17,代码来源:BasicTests.cs

示例5: NestedSessionScopeAndLazyLoad

        public void NestedSessionScopeAndLazyLoad()
        {
            var product = new Product();
            product.Categories.Add( new Category("x") );
            product.Categories.Add( new Category("y") );
            product.Categories.Add( new Category("z") );

            using (new SessionScope()) {
                product.Save();
            }

            using(new SessionScope())
            {
                var product1 = Product.Find(product.Id);
                Assert.AreEqual( 3, product1.Categories.Count );

                foreach(var cat in product1.Categories)
                {
                    Assert.AreEqual(1, cat.Name.Length);
                }

                var product2 = Product.Find(product.Id);
                Assert.AreEqual( 3, product2.Categories.Count );

                using(new SessionScope())
                {
                    foreach(var cat in product2.Categories)
                    {
                        Assert.AreEqual(1, cat.Name.Length);
                    }
                }

                using(new SessionScope())
                {
                    var product3 = Product.Find(product.Id);
                    Assert.AreEqual( 3, product3.Categories.Count );

                    foreach(var cat in product3.Categories)
                    {
                        Assert.AreEqual(1, cat.Name.Length);
                    }
                }
            }
        }
开发者ID:shosca,项目名称:ActiveRecord,代码行数:44,代码来源:SessionScopeTestCase.cs

示例6: SaveProduct

 public void SaveProduct(int Id, string Title, string Group, string SubGroup, string Partcode, string Manufacturer, string Description, string InternalNotes, string Availability, string ProductLines)
 {
     Product p = new Product(Id);
     p.Title = Title;
     p.Group = Group;
     p.SubGroup = SubGroup;
     p.Partcode = Partcode;
     p.Manufacturer = Manufacturer;
     p.Description = Description;
     p.InternalNotes = InternalNotes;
     p.Availability = Availability;
     p.Save();
     p.ClearProductLines();
     foreach (string productLineId in ProductLines.Split(','))
     {
         if (!String.IsNullOrEmpty(productLineId))
             p.AttachProductLine(Convert.ToInt32(productLineId));
     }
 }
开发者ID:tonybaloney,项目名称:No-More-Spreadsheets,代码行数:19,代码来源:QuoteService.cs

示例7: Acc_Object_CRUD

        public void Acc_Object_CRUD()
        {
            //Add a product
            Product p = new Product();
            p.ProductName = "Test";
            p.QuantityPerUnit = "test amount";
            p.ReorderLevel = null;
            p.SupplierID = 1;
            p.UnitPrice = 100;
            p.UnitsInStock = 0;
            p.UnitsOnOrder = 0;
            p.CategoryID = 1;
            p.Discontinued = false;

            Assert.AreEqual(0, p.ProductID);

            p.Save("Unit Test");

            Assert.IsTrue(p.ProductID > 0);

            //delete unit test record
            Query qry = new Query(Product.Schema);
            qry.QueryType = QueryType.Delete;
            qry.AddWhere("productName", "Test");
            qry.Execute();
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:26,代码来源:GeneratedObjectTests.cs

示例8: Acc_Products_NullCrud

        public void Acc_Products_NullCrud()
        {
            //add a new product
            Product product = new Product();
            product.CategoryID = 1;
            product.Discontinued = false;
            product.ProductName = "Unit Test Product";
            product.QuantityPerUnit = null;
            product.ReorderLevel = null;
            product.SupplierID = null;
            product.UnitPrice = null;
            product.UnitsInStock = null;
            product.UnitsOnOrder = null;

            product.Save("");

            //get the new id
            int newID = product.ProductID;

            product = new Product(newID);
            product.ReorderLevel = 100;
            product.Save("unit test");

            //pull it out to confirm
            product = new Product(newID);
            Assert.IsTrue(product.ReorderLevel == 100, "Bad Save");
            Assert.IsTrue(product.SupplierID == null, "Bad Save, Null not inserted");

            //delete it
            ActiveRecord<Product>.Delete(newID);
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:31,代码来源:ActiveRecordTest.cs

示例9: Acc_Products_Crud

        public void Acc_Products_Crud()
        {
            //add a new product
            Product product = CreateTestProduct();
            product.Save("");

            //get the new id
            int newID = product.ProductID;

            product = new Product(newID);
            product.ReorderLevel = 100;
            product.Save("unit test");

            //pull it out to confirm
            product = new Product(newID);
            Assert.IsTrue(product.ReorderLevel == 100, "Bad Save");

            DeleteTestProduct();
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:19,代码来源:ActiveRecordTest.cs

示例10: Insert

        public void Insert(string ProductName,int? SupplierID,int? CategoryID,string QuantityPerUnit,decimal? UnitPrice,short? UnitsInStock,short? UnitsOnOrder,short? ReorderLevel,bool Discontinued,string AttributeXML,DateTime? DateCreated,Guid? ProductGUID,DateTime CreatedOn,string CreatedBy,DateTime ModifiedOn,string ModifiedBy,bool Deleted)
        {
            Product item = new Product();

            item.ProductName = ProductName;

            item.SupplierID = SupplierID;

            item.CategoryID = CategoryID;

            item.QuantityPerUnit = QuantityPerUnit;

            item.UnitPrice = UnitPrice;

            item.UnitsInStock = UnitsInStock;

            item.UnitsOnOrder = UnitsOnOrder;

            item.ReorderLevel = ReorderLevel;

            item.Discontinued = Discontinued;

            item.AttributeXML = AttributeXML;

            item.DateCreated = DateCreated;

            item.ProductGUID = ProductGUID;

            item.CreatedOn = CreatedOn;

            item.CreatedBy = CreatedBy;

            item.ModifiedOn = ModifiedOn;

            item.ModifiedBy = ModifiedBy;

            item.Deleted = Deleted;

            item.Save(UserName);
        }
开发者ID:RyanDansie,项目名称:SubSonic-2.0,代码行数:40,代码来源:ProductController.cs


注:本文中的Product.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。