Example #1
0
 /// <summary>
 /// Find the query default.
 /// </summary>
 /// <param name="queryItems">The query list.</param>
 /// <param name="query">The current query.</param>
 private void FindQueryExAllDefault(
     Dictionary <Enum.EnumDataStoreTableName, Nequeo.Model.QueryModel[]> queryItems,
     Nequeo.Model.QueryModel query)
 {
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.A);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.B);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.C);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.D);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.E);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.F);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.G);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.H);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.I);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.J);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.K);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.L);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.M);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.N);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.O);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.P);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.Q);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.R);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.S);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.T);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.U);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.V);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.W);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.X);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.Y);
     AddQuery(queryItems, query, Enum.EnumDataStoreTableName.Z);
 }
Example #2
0
 /// <summary>
 /// Find the query
 /// </summary>
 /// <param name="queryItems">The query list.</param>
 /// <param name="query">The current query.</param>
 private void FindQuery(
     Dictionary <Enum.EnumDataStoreTableName, Nequeo.Model.QueryModel[]> queryItems,
     Nequeo.Model.QueryModel query)
 {
     // If is number.
     if (query.QueryType == Model.QueryType.Number)
     {
         // Add the number query.
         AddQuery(queryItems, query, Enum.EnumDataStoreTableName.Number);
     }
     else
     {
         // If is special.
         if (query.QueryType == Model.QueryType.Special)
         {
             // Add the special query.
             AddQuery(queryItems, query, Enum.EnumDataStoreTableName.Special);
         }
         else
         {
             // If match partial
             if (query.MatchPartialQuery)
             {
                 // Look in all the data stores A - Z
                 FindQueryExAllDefault(queryItems, query);
             }
             else
             {
                 // Only look in the appropriate.
                 FindQueryExDefault(queryItems, query);
             }
         }
     }
 }
Example #3
0
        /// <summary>
        /// Create the expression.
        /// </summary>
        /// <param name="query">The current query.</param>
        /// <param name="propertyMember">The current property member.</param>
        /// <param name="operand">The operand.</param>
        /// <returns>The new expression.</returns>
        private Expression CreateExpression(Nequeo.Model.QueryModel query, Expression propertyMember, ExpressionType operand)
        {
            switch (operand)
            {
            case ExpressionType.Equal:
                return(Expression.Equal(propertyMember, Expression.Constant(query.Query, typeof(string))));

            case ExpressionType.GreaterThan:
                return(Expression.GreaterThan(propertyMember, Expression.Constant(query.Query, typeof(string))));

            case ExpressionType.GreaterThanOrEqual:
                return(Expression.GreaterThanOrEqual(propertyMember, Expression.Constant(query.Query, typeof(string))));

            case ExpressionType.LessThan:
                return(Expression.LessThan(propertyMember, Expression.Constant(query.Query, typeof(string))));

            case ExpressionType.LessThanOrEqual:
                return(Expression.LessThanOrEqual(propertyMember, Expression.Constant(query.Query, typeof(string))));

            case ExpressionType.NotEqual:
                return(Expression.NotEqual(propertyMember, Expression.Constant(query.Query, typeof(string))));

            case ExpressionType.Call:
                return(Expression.Call(
                           propertyMember,
                           typeof(string).GetMethod("Contains", new Type[] { typeof(string) }),
                           Expression.Constant(query.Query)));

            default:
                return(null);
            }
        }
Example #4
0
 /// <summary>
 /// Create the expression.
 /// </summary>
 /// <param name="query">The current query.</param>
 /// <param name="propertyMember">The current property member.</param>
 /// <returns>The new expression.</returns>
 private Expression CreateExpression(Nequeo.Model.QueryModel query, Expression propertyMember)
 {
     // If match partial
     if (query.MatchPartialQuery)
     {
         // Call the contains method.
         return(CreateExpression(query, propertyMember, ExpressionType.Call));
     }
     else
     {
         // Call the equal method.
         return(CreateExpression(query, propertyMember, ExpressionType.Equal));
     }
 }
Example #5
0
 /// <summary>
 /// Add the query
 /// </summary>
 /// <param name="queryItems">The query list.</param>
 /// <param name="query">The current query.</param>
 /// <param name="tableName">The query table name.</param>
 private void AddQuery(
     Dictionary <Enum.EnumDataStoreTableName, Nequeo.Model.QueryModel[]> queryItems,
     Nequeo.Model.QueryModel query, Enum.EnumDataStoreTableName tableName)
 {
     // If the query does not exist.
     if (queryItems[tableName] == null)
     {
         // Add the new query.
         queryItems.Add(tableName, new Model.QueryModel[] { query });
     }
     else
     {
         // Combine the queries.
         Model.QueryModel[] model       = queryItems[tableName];
         Model.QueryModel[] modelResult = model.CombineParallel(new Model.QueryModel[] { query });
         queryItems[tableName] = modelResult;
     }
 }
Example #6
0
        /// <summary>
        /// Find the query default.
        /// </summary>
        /// <param name="queryItems">The query list.</param>
        /// <param name="query">The current query.</param>
        private void FindQueryExDefault(
            Dictionary <Enum.EnumDataStoreTableName, Nequeo.Model.QueryModel[]> queryItems,
            Nequeo.Model.QueryModel query)
        {
            // Find all letters and default all special chars.
            switch (query.Query[0])
            {
            case 'A':
            case 'a':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.A);
                break;

            case 'B':
            case 'b':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.B);
                break;

            case 'C':
            case 'c':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.C);
                break;

            case 'D':
            case 'd':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.D);
                break;

            case 'E':
            case 'e':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.E);
                break;

            case 'F':
            case 'f':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.F);
                break;

            case 'G':
            case 'g':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.G);
                break;

            case 'H':
            case 'h':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.H);
                break;

            case 'I':
            case 'i':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.I);
                break;

            case 'J':
            case 'j':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.J);
                break;

            case 'K':
            case 'k':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.K);
                break;

            case 'L':
            case 'l':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.L);
                break;

            case 'M':
            case 'm':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.M);
                break;

            case 'N':
            case 'n':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.N);
                break;

            case 'O':
            case 'o':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.O);
                break;

            case 'P':
            case 'p':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.P);
                break;

            case 'Q':
            case 'q':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.Q);
                break;

            case 'R':
            case 'r':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.R);
                break;

            case 'S':
            case 's':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.S);
                break;

            case 'T':
            case 't':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.T);
                break;

            case 'U':
            case 'u':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.U);
                break;

            case 'V':
            case 'v':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.V);
                break;

            case 'W':
            case 'w':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.W);
                break;

            case 'X':
            case 'x':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.X);
                break;

            case 'Y':
            case 'y':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.Y);
                break;

            case 'Z':
            case 'z':
                AddQuery(queryItems, query, Enum.EnumDataStoreTableName.Z);
                break;
            }
        }