static void Select() { TableQuery <ProductTesting> tableQuery = table.CreateQuery <ProductTesting>(); //IQueryable<ProductTesting> pts = from productTesting in tableQuery select productTesting; IQueryable <ProductTesting> pts = from productTesting in tableQuery.Where <ProductTesting>(x => x.Result == "Pass") select productTesting; ProductTesting pt = pts.First <ProductTesting>(); Console.WriteLine(HttpUtility.UrlDecode(pt.TestDate) + "," + pt.ProductSn + "," + pt.Result); }
static void Delete() { TableQuery <ProductTesting> tableQuery = table.CreateQuery <ProductTesting>(); //IQueryable<ProductTesting> pts = from productTesting in tableQuery select productTesting; IQueryable <ProductTesting> pts = from productTesting in tableQuery.Where <ProductTesting>(x => x.ProductSn == "P0001") select productTesting; ProductTesting productTest = pts.First <ProductTesting>(); TableOperation tbOp = TableOperation.Delete(productTest); table.Execute(tbOp); }
static void Insert() { TableOperation tbOp; //添加 ProductTesting productTest = new ProductTesting(); productTest.TestDate = HttpUtility.UrlEncode("2017/08/01");//对斜杠做编码,避免抛出异常 productTest.ProductSn = "P0003"; productTest.Result = "Pass"; productTest.Name = "ProductA"; tbOp = TableOperation.Insert(productTest); table.Execute(tbOp); }