Exemplo n.º 1
0
 /// <summary>
 /// Creates a WHERE clause equality comparison for a field and value in the form ([fieldName] = [value]), where the value data type is <see cref="String"/>.
 /// </summary>
 /// <param name="where">The query builder instance</param>
 /// <param name="fieldName">The name of the field to use as the expression on the left of the operator.</param>
 /// <param name="equalsValue">The value of the parameter created for the right side of the operator.</param>
 /// <param name="isAnsi">Is the database field an ANSI string or Unicode string?</param>
 /// <param name="length">Is the database field fixed length or variable length?</param>
 /// <returns></returns>
 public static IDbQueryWhereClause FieldEquals(this IDbQueryWhereClause where, string fieldName, string equalsValue, bool isAnsi = false, int?length = null)
 {
     return(where.FieldMatch(fieldName, SqlOperator.Equal, equalsValue, isAnsi, length));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a WHERE clause equality comparison for a field and value in the form ([fieldName] = [equalsValue])
 /// </summary>
 /// <typeparam name="TValue">The data type of the right operand</typeparam>
 /// <param name="where">The query builder instance</param>
 /// <param name="fieldName">The name of the field to use as the expression on the left of the operator.</param>
 /// <param name="equalsValue">The value of the parameter created for the right side of the operator.</param>
 /// <param name="dbType">The data type of the database field.</param>
 /// <param name="size">The size of the database field (for fixed length data types).</param>
 /// <returns></returns>
 public static IDbQueryWhereClause FieldEquals <TValue>(this IDbQueryWhereClause where, string fieldName, TValue equalsValue, DbType?dbType = null, int?size = null)
 {
     return(where.FieldMatch <TValue>(fieldName, SqlOperator.Equal, equalsValue, dbType: dbType, size: size));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a WHERE clause comparison for a field and value in the form ([fieldName] &gt;= [begin] AND [fieldName] &lt;= [end]), where the value data type is <see cref="DateTimeOffset"/>.
 /// </summary>
 /// <param name="where">The query builder instance</param>
 /// <param name="fieldName">The name of the field to use as the expression on the left of the operator.</param>
 /// <param name="begin">The begin date/time of the range.</param>
 /// <param name="end">The end date/time of the range.</param>
 /// <returns></returns>
 public static IDbQueryWhereClause FieldBetween(this IDbQueryWhereClause where, string fieldName, DateTimeOffset begin, DateTimeOffset end)
 {
     return(where
            .FieldMatch(fieldName, SqlOperator.GreaterThanOrEqual, begin)
            .FieldMatch(fieldName, SqlOperator.LessThanOrEqual, end));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a WHERE clause comparison for a field and value in the form ([fieldName] &gt;= [begin] AND [fieldName] &lt;= [end]), where the value data type is <see cref="DateTime"/>.
 /// </summary>
 /// <param name="where">The query builder instance</param>
 /// <param name="fieldName">The name of the field to use as the expression on the left of the operator.</param>
 /// <param name="begin">The begin value of the range.</param>
 /// <param name="end">The end value of the range.</param>
 /// <param name="dbType">The data type of the database field.</param>
 /// <param name="size">The size of the database field (for fixed length data types).</param>
 /// <returns></returns>
 public static IDbQueryWhereClause FieldBetween <TValue>(this IDbQueryWhereClause where, string fieldName, TValue begin, TValue end, DbType?dbType = null, int?size = null)
 {
     return(where
            .FieldMatch(fieldName, SqlOperator.GreaterThanOrEqual, begin, dbType: dbType, size: size)
            .FieldMatch(fieldName, SqlOperator.LessThanOrEqual, end, dbType: dbType, size: size));
 }
 /// <summary>
 /// Adds an equals condition to the given query's where clause for the given field and string value.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="fieldName"></param>
 /// <param name="equalsValue"></param>
 /// <returns></returns>
 public static IDbQueryWhereClause FieldEquals(this IDbQueryWhereClause query, string fieldName, DbString equalsValue)
 {
     return(query.FieldMatch(fieldName, SqlOperator.Equal, equalsValue));
 }
        /// <summary>
        /// Adds a range condition to the given query's where clause.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query"></param>
        /// <param name="fieldName"></param>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static IDbQueryWhereClause FieldBetween <T>(this IDbQueryWhereClause query, string fieldName, DbDate <T> begin, DbDate <T> end) where T : struct
        {
            query.FieldMatch(fieldName, SqlOperator.GreaterThanOrEqual, begin).FieldMatch(fieldName, SqlOperator.LessThanOrEqual, end);

            return(query);
        }