public void FilterByColumn(Query query, QueryConfig queryConfig, IRequestParameterAdapter parameter) { var queryFilters = parameter.Query; foreach (QueryFilter prop in queryFilters) { if (prop.Value == null || prop.Value.ToString().IsBlank()) { continue; } var name = prop.Name; var value = prop.Value; switch (prop.Operator) { case OperatorType.EndWith: query.OrWhereEnds(name, value.ToString()); break; case OperatorType.StartWith: query.OrWhereStarts(name, value.ToString()); break; case OperatorType.Equals: query.OrWhere(name, "=", value); break; case OperatorType.NotEquals: query.OrWhere(name, "!=", value); break; case OperatorType.LessThan: query.OrWhere(name, "<", value); break; case OperatorType.LessOrEqual: query.OrWhere(name, "<=", value); break; case OperatorType.GreaterThan: query.OrWhere(name, ">", value); break; case OperatorType.GreaterOrEqual: query.OrWhere(name, ">=", value); break; //case OperatorType.DateWithoutTime: // query.OrWhereBetween(name, prop.DateLogicalOperator, value); // break; default: query.OrWhereContains(name, value.ToString()); break; } } }
private void ProcessQuery(Query query, QueryConfig queryConfig, IRequestParameterAdapter parameter) { PerPage = parameter.PerPage; Filter(query, queryConfig, parameter); OrderBy(query, queryConfig, parameter.OrderBy); Paginate(query, parameter.Page); }
public void FilterByColumn(Query query, QueryConfig queryConfig, IRequestParameterAdapter parameter) { var queryFilters = parameter.Query; foreach (QueryFilter prop in queryFilters) { if (prop.Value == null || prop.Value.ToString().IsBlank()) { continue; } var name = prop.Name; var value = prop.Value; var propConfig = queryConfig.GetQueryFieldByName(name); if (propConfig.Type == typeof(DateTime)) { //OnConstruction.... //var date = ((JObject)value).ToObject<VueDateValueObject>(); //query // .OrWhereDate(name, ">=", date.Start.ToString("mm/dd/yyyy")) // .OrWhereDate(name, "<=", date.End.ToString("yyyy-mm-dd")); } else { query.OrWhereLike(name, $"%{value}%"); } } }
private void FilterByAllFields(Query query, QueryConfig queryConfig, IRequestParameterAdapter parameter) { var value = parameter.Query; var fields = queryConfig.Fields.Where(p => p.IsFilter); foreach (QueryField field in fields) { query = query.OrWhereLike(field.Name, $"%{value}%"); } }
public async static Task <object> Build(string configName, IRequestParameterAdapter parameter) { var config = TablePluginOptions.QueryRepositoryInstance.GetByConfig(configName); config.ConnectionString = TablePluginOptions.SQLConnectionName; config.Provider = TablePluginOptions.DatabaseProvider; var paginator = new QueryPaginatorBasic(); var result = await paginator.GetAsync(config, parameter); return(result); }
private void Filter(Query query, QueryConfig queryConfig, IRequestParameterAdapter parameter) { if (parameter.IsFilterByColumn == false || parameter.Query == null || parameter.Query.Count() == 0) { return; } if (parameter.IsFilterByColumn) { FilterByColumnStrategy.FilterByColumn(query, queryConfig, parameter); } else { FilterByAllFields(query, queryConfig, parameter); } }
public async Task <DataResponse <TData> > GetAsync <TData>(QueryConfig queryConfig, IRequestParameterAdapter parameter) { Query query = queryConfig.Query.Clone(); queryFactory = QueryFactorySqlKata.Build(queryConfig); ProcessQuery(query, queryConfig, parameter); var count = await GetCount(query); var data = await GetRecords <TData>(query); return(new DataResponse <TData> { Data = data, Count = count }); }
/// <summary> /// /// </summary> /// <param name="queryConfig"></param> /// <param name="parameter"></param> /// <returns></returns> public async Task <object> GetAsync(QueryConfig queryConfig, IRequestParameterAdapter parameter) => await GetAsync <object>(queryConfig, parameter);