本文整理汇总了C#中Categories.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Categories.Where方法的具体用法?C# Categories.Where怎么用?C# Categories.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Categories
的用法示例。
在下文中一共展示了Categories.Where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args) {
var osInfo = System.Environment.OSVersion;
Settings.Load(Toolkit.CurrentDirectory.FindPrecedingFile("settings.json").FullPath);
var pwd = Settings.Passcode;
var dbcfg = Settings.Databases["default"];
var cats = new Categories().Select();
var parents = new Categories().Where(new { ParentID = DBNull.Value });
var productData = Util.IO.File.ReadText("C:\\Work\\products.json");
var products = AOI.Util.Codecs.JSON.Decode<List<Dictionary<string, dynamic>>>(productData);
foreach (var product in products) {
var productCategory = ((string)product["category"]).ToUpper();
var parts = productCategory.Split('/');
var parentCategory = parts[0];
var pc = parents.Where(c => c.Label.ToUpper() == parentCategory).FirstOrDefault();
if (pc == null) {
pc = new Categories().Single(new { Label = productCategory });
if (pc == null) {
pc = new Categories().Add(new {
Label = parentCategory
});
parents.Add(pc);
}
}
if (parts.Length > 1) {
var childCategory = parts[1];
var child = pc.Child(childCategory, true);
product["category_id"] = child.ID;
} else {
product["category_id"] = pc.ID;
}
var description = product["description"];
description = Util.Toolkit.UrlDecode(description);
var url = product["picture"];
//var data = Util.Http.GET(url);
//Util.IO.File.WriteBinary("C:\\Work\\product.jpg", data);
//product["picture_snapshot"] = data;
}
Log.Trace("...");
//new Categories().Fetch(
// new {
// ParentID = 1
// }
//);
//var filtered = new Categories().Where(new {
// ParentID = 2
//});
//var categories = new Categories().Select();
//var category = categories[0];
//var childrens = category.Children;
////category.Update(new {
//// Description = "This is a category."
//// });
//var child = category.Create("MIRRORS");
//var children = category.Children;
var db = AOI.Data.Database.Open("DefaultConnection");
//db.Insert(new Query("INSERT INTO categories (label, ParentID) VALUES (@label, @ParentID);").Set("Label", "ACCESSORIES").Set("ParentID", 2));
//var people = db.SelectRecords<Person>("SELECT applicant_transaction_number as ID, first_name as FirstName, last_name as LastName FROM \"Applicants\" LIMIT 10;");
//var records = db.SelectRecords("SELECT first_name as FirstName, last_name as LastName FROM \"Applicants\" LIMIT 10;");
//var records = db.SelectRecords("SELECT * FROM \"Applicants\";");
//db.Insert(new Query("INSERT INTO categories (label) VALUES (@label);").Set("Label", "ACCESSORIES"));
//db.Insert(new Query("INSERT INTO categories (label) VALUES (@label);").Set("Label", "ARCHITECTURAL"));
//db.Insert(new Query("INSERT INTO categories (label) VALUES (@label);").Set("Label", "FURNISHINGS"));
//db.Insert(new Query("INSERT INTO categories (label) VALUES (@label);").Set("Label", "TEXTILES"));
var records = db.SelectRecords<Category>("SELECT * FROM Categories;");
Console.WriteLine("...");
}