/// <summary> /// Adds a string pattern matching filter to the query's where clause. /// </summary> /// <param name="query"></param> /// <param name="fieldName"></param> /// <param name="operator"></param> /// <param name="value"></param> /// <returns></returns> public static IDbQueryWhereClause StringMatch(this IDbQueryWhereClause query, string fieldName, Csg.Data.Sql.SqlWildcardDecoration @operator, DbString value) { var filter = new Csg.Data.Sql.SqlStringMatchFilter(query.Root, fieldName, @operator, value.Value); if (value.IsAnsi && value.IsFixedLength) { filter.DataType = DbType.AnsiStringFixedLength; } else if (value.IsAnsi) { filter.DataType = DbType.AnsiString; } else if (value.IsFixedLength) { filter.DataType = DbType.StringFixedLength; } else { filter.DataType = DbType.String; } if (value.Length >= 0) { filter.Size = value.Length; } query.AddFilter(filter); return(query); }
/// <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)); }