public int Count(ParticipantQueryPredicate predicate) { using (var cn = _connectionFactory.CreateConnection()) { int count = cn.Count <Participant>(statement => { statement.Where(_predicateFactory.Create(predicate)); statement.WithParameters(predicate); }); return(count); } }
public ActionResult Get([FromQuery] ParticipantQueryPredicate predicate) { var request = new QueryPredicateRequest <ParticipantQueryPredicate>() { Predicate = predicate, User = new UserRequest() { Principal = this.User, IpAddress = this.HttpContext.Connection.RemoteIpAddress } }; var response = _app.Query(request); var responseMessage = new ApplicationResult <Participant[]>(response); return(responseMessage); }
public FormattableString Create(ParticipantQueryPredicate predicate) { var queryFragments = new List <string>(); if (!string.IsNullOrEmpty(predicate.Name)) { queryFragments.Add($"{nameof(predicate.Name):C}=@{nameof(predicate.Name):C}"); } if (queryFragments.Count == 0) { return(null); } string query = string.Concat(string.Join(" AND ", queryFragments)); return($"{query}"); }
public Participant[] Query(ParticipantQueryPredicate predicate) { using (var cn = _connectionFactory.CreateConnection()) { return(cn.Find <Participant>(statement => { statement.Where(_predicateFactory.Create(predicate)); if (predicate.Offset > 0) { statement.Skip(predicate.Offset); } if (predicate.Limit > 0) { statement.Top(predicate.Limit); } statement.WithParameters(predicate); }).ToArray()); } }