public IEnumerable <AddressType> Search([FromUri] AddressTypeCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var q = db.AddressType; var list = (c == null ? q : q.Where(c.CreatePredicate())).ToList(); return(list); } }
public IActionResult PhysicallyRemove([FromQuery] AddressTypeCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var count = db.AddressType .Where(c.CreatePredicate()) .Delete(); return(Ok(count)); } }
public IActionResult Count([FromQuery] AddressTypeCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var count = c == null?db.AddressType.Count() : db.AddressType.Count(predicate: c.CreatePredicate()); return(Ok(count)); } }
public int Remove([FromUri] AddressTypeCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var count = db.AddressType .Where(c.CreatePredicate()) .Set(_ => _.removed_at, Sql.CurrentTimestampUtc) .Update(); return(count); } }
public IActionResult Search([FromQuery] AddressTypeCondition c, [FromQuery] string[] order, int currentPage = 1, int pageSize = 10, DateTime?p_when = null) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var q = db.AddressType .IsActiveAt(p_when) ; var filtered = c == null ? q : q.Where(c.CreatePredicate()); var ordered = order.Any() ? filtered.SortBy(order) : filtered; var result = ordered.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList(); return(Ok(result)); } }
static void Main(string[] args) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB("peppaConnectionString")) { db.Insert <AddressType>(new AddressType { address_type_id = 0, name = "現住所", display_order = 0, }); var q = from a in db.AddressType select new { a.address_type_id, a.name, a.created_at, a.created_by, a.modified_at, a.modified_by, a.row_version, }; foreach (var a in q) { Console.WriteLine(a); Debug.WriteLine(a); } var cond = new AddressTypeCondition { name_eq = "現住所" }; var pred = cond.CreatePredicate(); var list = db.AddressType.Where(pred).ToList(); foreach (var x in list) { Console.WriteLine(x); Debug.WriteLine(x); } } }