事务
using (var db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.xxx, DbType = SqlSugar.DbType.MySql })) { try { db.Ado.BeginTran(); var count = db.Updateable(flow).ExecuteCommand(); if (count != 1) throw new Exception(); db.Ado.CommitTran(); return 1; } catch (Exception) { db.Ado.RollbackTran(); return 0; } }
判断字段不为空且值==1
query = query.Where(a => SqlFunc.HasValue(a.visible) && a.visible.Value ==1);
query = query.Where(a => a.visible !=null && a.visible.Value ==1);
order by , page
var result = query .OrderBy(a=>a.ModifyTime,OrderByType.Desc) .ToPageList(pageIndex, pageSize, ref count);