本文整理汇总了C#中System.Item.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Save方法的具体用法?C# Item.Save怎么用?C# Item.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRetrieveUpdateDelete
public void CreateRetrieveUpdateDelete()
{
string sku = DateTime.Now.ToString( "MMddHHmm" );
string name = string.Format( "test item - {0}", DateTime.Now.ToString( "MMdd HHmm" ) );
// create test
Item item = new Item();
item.Sku = sku;
item.Name = name;
item.Save();
// retrieve test
item = Item.Retrieve( sku );
Assert.AreEqual( name, item.Name );
// update test
item.Name += " update test";
item.Save();
// delete test
item.Delete();
}
示例2: ManyToOneTest
public void ManyToOneTest()
{
Item Temp = new Item();
Temp.Name = "Parent";
for (int x = 0; x < 5; ++x)
{
Item Child = new Item();
Child.Name = "Child "+x.ToString();
Child.Parent=Temp;
Temp.Children.Add(Child);
}
Temp.Save();
Item Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
foreach (Item Child in Parent.Children)
Assert.Equal(Parent, Child.Parent);
Assert.Equal(5, Parent.Children.Count);
Assert.Equal(null, Parent.Parent);
Parent.Children = Parent.Children.Remove(x => x.Name == "Child 0").ToList();
Parent.Save();
Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
foreach (Item Child in Parent.Children)
Assert.Equal(Parent, Child.Parent);
Assert.Equal(4, Parent.Children.Count);
Assert.Equal(null, Parent.Parent);
Parent.Delete();
Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
Assert.Null(Parent);
Assert.Equal(1, Item.All().Count());
}
示例3: CreateInvalidItem
public void CreateInvalidItem()
{
Item item = new Item();
item.Name = "Bad Item";
item.Save();
}