一些範列如下:
//直接使用 Operator
var products = ORM.Product.Select()
.Where(CN.Product.Name == "ABC")
.And(CN.Product.Name != "DEF")
.And(CN.Product.Name % "ABC%") //這是 Like
.And(CN.Product.Name | "apple, orange".SqlListStr()) // 這是 in
.And(CN.Product.Is_Available)
.And(!CN.Product.Is_Deleted)
.And(CN.Product.OriginalPrice > 5)
.And(CN.Product.OriginalPrice <= 500)
.And(CN.Product.CreateDate < DateTime.Now.AddMonths(-1))
.GetList<ORM.Product>();
//產出 SQL: Select * From [Product] (NoLock) Where ( ([Name] <> N'DEF') ) And ( ([Name] like N'ABC%') ) And ( ([Name] in ('apple',' orange')) ) And ([Is_Available] = 'Y') And ( ([Is_Deleted] = 'N') ) And ( ([OriginalPrice] > 5) ) And ( ([OriginalPrice] <= 500) ) And ( ([CreateDate] < '2020-11-26T10:17:15.553') )
//用 Id 取出物件並修改
var product = ORM.Product.Get(3);
U2.WU.DebugWriteLine(product.Name);
product.Name = "平格藍均抱枕套45*45 ABC";
product.Modify();
//新增一筆資料
var newId = new ORM.Product()
{
Name = "New Product",
OriginalPrice = 100,
Is_Hot = "Y"
}.Add();
//用 Id 修改資料
var updateCount = new ORM.Product(3)
{
Name = "New Product",
OriginalPrice = 100,
Is_Hot = "Y"
}.Modify();