Exemple #1
0
        /// <summary>
        /// Add a condition with 'and'
        /// </summary>
        /// <param name="sourceQuery">Source query</param>
        /// <param name="eachFieldConnectOperator">each field codition connect operator</param>
        /// <param name="operator">Condition operator</param>
        /// <param name="value">Value</param>
        /// <param name="converter">Criteria converter</param>
        /// <param name="fieldNames">Field names</param>
        /// <returns>Return the newest IQuery object</returns>
        public static IQuery And(this IQuery sourceQuery, QueryOperator eachFieldConnectOperator, CriteriaOperator @operator, dynamic value, ICriteriaConverter converter, params string[] fieldNames)
        {
            if (fieldNames.IsNullOrEmpty())
            {
                return(sourceQuery);
            }
            IQuery groupQuery = QueryManager.Create();

            foreach (string field in fieldNames)
            {
                switch (eachFieldConnectOperator)
                {
                case QueryOperator.AND:
                default:
                    groupQuery = And(groupQuery, field, @operator, value, converter);
                    break;

                case QueryOperator.OR:
                    groupQuery = OrExtensions.Or(groupQuery, field, @operator, value, converter);
                    break;
                }
            }
            return(sourceQuery.AddQueryItem(QueryOperator.AND, groupQuery));
        }
 /// <summary>
 /// Greater than or equal condition
 /// </summary>
 /// <typeparam name="TQueryModel">Query model</typeparam>
 /// <param name="sourceQuery">Source query</param>
 /// <param name="field">Field</param>
 /// <param name="subquery">Subquery</param>
 /// <param name="or">Connect with 'and'(true/default) or 'or'(false)</param>
 /// <returns>Return the newest IQuery object</returns>
 public static IQuery GreaterThanOrEqual <TQueryModel>(this IQuery sourceQuery, Expression <Func <TQueryModel, dynamic> > field, IQuery subquery, bool or = false) where TQueryModel : IQueryModel <TQueryModel>
 {
     return(or ? OrExtensions.Or(sourceQuery, field, CriteriaOperator.GreaterThanOrEqual, subquery) : AndExtensions.And(sourceQuery, field, CriteriaOperator.GreaterThanOrEqual, subquery));
 }