本文整理汇总了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");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
}
示例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));
}
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}