本文整理汇总了C#中DataBase.ItemGetAll方法的典型用法代码示例。如果您正苦于以下问题:C# DataBase.ItemGetAll方法的具体用法?C# DataBase.ItemGetAll怎么用?C# DataBase.ItemGetAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase.ItemGetAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateItem
public void UpdateItem()
{
DataBase dataBase = new DataBase();
string name = Guid.NewGuid().ToString();
Item item = new Item
{
Name = name,
Description = Guid.NewGuid().ToString(),
ItemTypeId = 0,
Image = new byte[] {1, 2, 3, 4, 5},
};
int rowsInserted = dataBase.ItemInsert(item);
Assert.AreEqual(1, rowsInserted);
List<Item> items = dataBase.ItemGetAll(@"SELECT Id, Name, Description, ItemType, Image FROM Item");
Assert.IsNotNull(items);
Item find = items.Find(i => i.Name == name);
Assert.IsNotNull(find);
string newName = Guid.NewGuid().ToString();
find.Name = newName;
int rowsUpdated = dataBase.ItemUpdate(find);
Assert.AreEqual(1, rowsUpdated);
Item updatedItem = dataBase.ItemGet(find.Id);
Assert.AreEqual(newName, updatedItem.Name);
Assert.AreEqual(item.Description, updatedItem.Description);
Assert.AreEqual(item.ItemTypeId, updatedItem.ItemTypeId);
}
示例2: InsertItemWitPicture
public void InsertItemWitPicture()
{
DataBase dataBase = new DataBase();
string name = Guid.NewGuid().ToString();
const string imagePath = "Untitled.png";
byte[] imageData = Misc.GetImageData(imagePath);
Assert.IsNotNull(imageData, "No image '{0}'!", imagePath);
Item item = new Item
{
Name = name,
Description = Guid.NewGuid().ToString(),
ItemTypeId = 0,
Image = imageData,
};
int rowsInserted = dataBase.ItemInsert(item);
Assert.AreEqual(1, rowsInserted);
List<Item> items = dataBase.ItemGetAll(@"SELECT Id, Name, Description, ItemType, Image FROM Item");
Assert.IsNotNull(items, "Ites is null");
Item find = items.Find(i => i.Name == name);
Assert.IsNotNull(find, "Item {0} not found!", name);
Assert.AreEqual(imageData.Length, find.Image.Length, "Wrong Image!");
}