// Standard single value node public QueryNode(QueryNodeType type, string column, QueryOp op, JSONObj value) { this.Type = type; this.Column = column; this.Operator = op; this.Value = value; this.Children = new QueryNodeList(); }
/// <summary> /// Returns collection of entites given query condition. /// </summary> public static IEnumerable <TEntity> GetByAny(string columnName, QueryOp queryOp, object value) { // Create query condition. QueryCondition queryCondition = new QueryCondition(columnName, queryOp, value); // Return collection. return(GetByAny(queryCondition)); }
// Overload for grouping nodes (AND, OR) public QueryNode(QueryNodeType type, QueryOp op, QueryNodeList childNodes) { this.Type = type; this.Operator = op; this.Column = ""; this.Value = JSONObj.nullJO; this.Children = childNodes; }
// Overload for BETWEEN query nodes public QueryNode(QueryNodeType type, string column, QueryOp op, JSONObj value1, JSONObj value2) { // Between and In operators are the only ones that know to look at the values array Debug.Assert(op == QueryOp.Btwn || op == QueryOp.In); this.Type = type; this.Column = column; this.Operator = op; this.Children = new QueryNodeList(); this.Value = JSONObj.obj; Value.Add(value1); Value.Add(value2); }
/// <summary> /// Creates query condition. /// </summary> /// <param name="leftExpression">Left expression</param> /// <param name="queryOperator">Query operator</param> /// <param name="rightExpression">Right expression</param> public QueryCondition( object leftExpression, QueryOp queryOperator, object rightExpression, bool enclosed = false, QueryOp lastOperator = QueryOp.And) { // Initialization. LeftExpression = leftExpression; RightExpression = rightExpression; QueryOperator = queryOperator; QueryOperatorLast = lastOperator; Enclosed = enclosed; }
/// <summary> /// Creates query condition. /// </summary> /// <param name="leftCondition">Left query condition</param> /// <param name="queryOperator">Query operator</param> /// <param name="rightCondition">Right query condition</param> public QueryCondition( QueryCondition leftCondition, QueryOp queryOperator, QueryCondition rightCondition, bool enclosed = true, QueryOp lastOperator = QueryOp.And) { // Initialization. LeftExpression = leftCondition; RightExpression = rightCondition; QueryOperator = queryOperator; QueryOperatorLast = lastOperator; Enclosed = enclosed; }
public static async Task <IEnumerable <TransactionHistory> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <TransactionHistory>(columnName, queryOp, value)); }
// Nodes for comparing a column to multiple values (e.g. between) private QueryNode CreateComparisonNode <T>(string column, QueryOp op, T value1, T value2) { return(new QueryNode(QueryNodeType.Comparison, column, op, JSONObj.Create(value1), JSONObj.Create(value2))); }
public Enumerator(QueryOp op) { _op = op; _current = default(QueryType); }
public static async Task <IEnumerable <SpecialOffer> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <SpecialOffer>(columnName, queryOp, value)); }
public static async Task <IEnumerable <EmployeeTerritories> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <EmployeeTerritories>(columnName, queryOp, value)); }
public static async Task <IEnumerable <PurchaseOrderHeader> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <PurchaseOrderHeader>(columnName, queryOp, value)); }
public static async Task <IEnumerable <CountryRegion> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <CountryRegion>(columnName, queryOp, value)); }
public static async Task <IEnumerable <SalesOrderHeaderSalesReason> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <SalesOrderHeaderSalesReason>(columnName, queryOp, value)); }
public static async Task <IEnumerable <Products> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <Products>(columnName, queryOp, value)); }
/// <summary> /// Returns collection of entites given query condition async. /// </summary> public static async Task <IEnumerable <TEntity> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { // Create query condition. QueryCondition queryCondition = new QueryCondition(columnName, queryOp, value); // Return collection. return(await GetByAnyAsync(queryCondition)); }
public static async Task <IEnumerable <SalesTerritory> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <SalesTerritory>(columnName, queryOp, value)); }
/// <summary> /// Returns collection of entites given query condition. /// </summary> protected static IEnumerable <TEntity> GetByAny <TEntity>(string columnName, QueryOp queryOp, object value) where TEntity : Entity, new() { return(EntityMechanic <TEntity> .GetByAny(columnName, queryOp, value)); }
public static async Task<IEnumerable<Store>> GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return await GetByAnyAsync<Store>(columnName, queryOp, value); }
public static async Task <IEnumerable <EmployeeDepartmentHistory> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <EmployeeDepartmentHistory>(columnName, queryOp, value)); }
public static async Task <IEnumerable <CurrencyRate> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <CurrencyRate>(columnName, queryOp, value)); }
public static async Task <IEnumerable <ShoppingCartItem> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <ShoppingCartItem>(columnName, queryOp, value)); }
//Translates query UI in to query nodes for execution public void SubmitQuery() { QueryNodeList andNodes = new QueryNodeList(); QueryNodeList orNodes = new QueryNodeList(); queryCollection[0].isAnd = true; for (int i = 0; i < queryCollection.Count; i++) { QueryOp op = QueryOp.Eq; switch ((Globals.QueryOperator)queryCollection[i].Operator) { case Globals.QueryOperator.Not_Equal: op = QueryOp.Neq; break; case Globals.QueryOperator.GreaterThan: op = QueryOp.Gt; break; case Globals.QueryOperator.LessThan: op = QueryOp.Lt; break; case Globals.QueryOperator.GreaterThanOrEqual: op = QueryOp.Gte; break; case Globals.QueryOperator.LessThanOrEqual: op = QueryOp.Lte; break; } JSONObj finalValue; float tempValue; if (queryCollection[i].Value.ToLower() == "true") { finalValue = new JSONObj(true); } else if (queryCollection[i].Value.ToLower() == "false") { finalValue = new JSONObj(false); } else if (float.TryParse(queryCollection[i].Value, out tempValue)) { finalValue = new JSONObj(tempValue); } else { finalValue = new JSONObj($"\"{queryCollection[i].Value}\""); } if (queryCollection[i].isAnd) { if (queryCollection[i].Field == Globals.QueryField.Other) { andNodes.Add(new QueryNode(QueryNodeType.Comparison, queryCollection[i].OtherField, op, finalValue)); } else { andNodes.Add(new QueryNode(QueryNodeType.Comparison, Globals.QueryExpectedStrings[(int)queryCollection[i].Field], op, new JSONObj($"\"{queryCollection[i].Value}\""))); } } else { if (queryCollection[i].Field == Globals.QueryField.Other) { orNodes.Add(new QueryNode(QueryNodeType.Comparison, queryCollection[i].OtherField, op, finalValue)); } else { orNodes.Add(new QueryNode(QueryNodeType.Comparison, Globals.QueryExpectedStrings[(int)queryCollection[i].Field], op, new JSONObj($"\"{queryCollection[i].Value}\""))); } } } if (queryCollection.Count == 1) { CollectEvents(andNodes[0]); } else { if (orNodes.Count == 1) { andNodes.Add(orNodes[0]); CollectEvents(new QueryNode(QueryNodeType.Group, QueryOp.Or, andNodes)); } else { if (orNodes.Count > 1) { andNodes.Add(new QueryNode(QueryNodeType.Group, QueryOp.Or, orNodes)); } CollectEvents(new QueryNode(QueryNodeType.Group, QueryOp.And, andNodes)); } } }
/// <summary> /// Returns collection of entites given query condition. /// </summary> protected static async Task <IEnumerable <TEntity> > GetByAnyAsync <TEntity>(string columnName, QueryOp queryOp, object value) where TEntity : Entity, new() { return(await EntityMechanic <TEntity> .GetByAnyAsync(columnName, queryOp, value)); }
public static async Task <IEnumerable <WorkOrderRouting> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <WorkOrderRouting>(columnName, queryOp, value)); }
public static async Task <IEnumerable <ProductModelProductDescriptionCulture> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <ProductModelProductDescriptionCulture>(columnName, queryOp, value)); }
public static async Task <IEnumerable <BusinessEntityAddress> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <BusinessEntityAddress>(columnName, queryOp, value)); }
// Nodes for grouping multiple nodes together with a common query operator (e.g. and, or) private QueryNode CreateGroupNode(QueryOp op, QueryNodeList childNodes) { return(new QueryNode(QueryNodeType.Group, op, childNodes)); }
public static async Task <IEnumerable <PersonCreditCard> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <PersonCreditCard>(columnName, queryOp, value)); }
public static async Task <IEnumerable <CustomerDemographics> > GetByAnyAsync(string columnName, QueryOp queryOp, object value) { return(await GetByAnyAsync <CustomerDemographics>(columnName, queryOp, value)); }