Exemple #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        internal EntityFieldFilterConstraint(SqlStatementCreator creator, EntityField field, SqlOperator filterOperator, object value) : base(creator)
        {
            // assertions...
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            // check...
            if (IsOperatorValidForType(filterOperator, field.DBType) == false)
            {
                throw new InvalidOperationException(string.Format(Cultures.Exceptions, "Operator '{0}' cannot be used with '{1}' fields.", filterOperator, field.DBType));
            }

            // is the field encrypted?
            //if(field.IsEncrypted)
            //{
            //	// switch...
            //	if(filterOperator != SqlOperator.EqualTo)
            //		throw new NotSupportedException(string.Format("'{0}' is encrypted.  Encrypted fields cannot support the '{1}' operator.",
            //			field, filterOperator));
            //}

            // set...
            _field          = field;
            _filterOperator = filterOperator;
            _value          = value;
        }
 public override void AddExtendedPropertyToSelectStatement(SqlStatementCreator creator, SqlStatement statement,
                                                           System.Text.StringBuilder builder, BootFX.Common.Entities.EntityField field)
 {
     // add it...
     builder.Append(statement.Dialect.FormatTableName(field.EntityType.NativeNameExtended));
     builder.Append(".");
     builder.Append(statement.Dialect.FormatColumnName(field.Name));
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 internal FilterConstraintCollection(SqlStatementCreator creator)
 {
     if (creator == null)
     {
         throw new ArgumentNullException("creator");
     }
     _creator = creator;
 }
Exemple #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        internal FilterConstraint(SqlStatementCreator creator)
        {
            // assertions...
            if (creator == null)
            {
                throw new ArgumentNullException("creator");
            }

            // set...
            _creator = creator;
        }
Exemple #5
0
        internal ValueListConstraint(SqlStatementCreator creator, EntityField field, IEnumerable values, bool useFullyQualifiedNames)
            : base(creator)
        {
            this.Field  = field;
            this.Values = new List <object>();
            foreach (var value in values)
            {
                this.Values.Add(value);
            }

            this.UseFullyQualifiedNames = useFullyQualifiedNames;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        internal FreeFilterConstraint(SqlStatementCreator creator, string sql, IEnumerable <EntityField> referencedFields) : base(creator)
        {
            if (sql == null)
            {
                throw new ArgumentNullException("sql");
            }
            if (sql.Length == 0)
            {
                throw new ArgumentOutOfRangeException("'sql' is zero-length.");
            }

            _sql = sql;
            this.ReferencedFields = new List <EntityField>(referencedFields);
        }
Exemple #7
0
        /// <summary>
        /// Append SQL to select the extended properties from the extended table for the entity
        /// </summary>
        /// <param name="statement"></param>
        /// <param name="builder"></param>
        /// <param name="field"></param>
        public override void AddExtendedPropertyToSelectStatement(SqlStatementCreator creator, SqlStatement statement, StringBuilder builder,
                                                                  EntityField field)
        {
            if (creator == null)
            {
                throw new ArgumentNullException("creator");
            }
            if (statement == null)
            {
                throw new ArgumentNullException("statement");
            }
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            // check...
            if (creator.EntityType == null)
            {
                throw new InvalidOperationException("creator.EntityType is null.");
            }

            // add...
            builder.Append("(");
            builder.Append(statement.Dialect.SelectKeyword);
            builder.Append(" ");
            builder.Append(statement.Dialect.FormatNativeName(GetColumnNameForDbType(field.DBType)));
            builder.Append(" ");
            builder.Append(statement.Dialect.FromKeyword);
            builder.Append(" ");
            builder.Append(statement.Dialect.FormatNativeName(creator.EntityType.NativeNameExtended));
            builder.Append(" ");
            builder.Append(statement.Dialect.WhereKeyword);
            builder.Append(" ");

            // where...
            creator.AppendConstraints(statement, builder);

            // create the param...
            SqlStatementParameter parameter = new SqlStatementParameter(string.Format("Extended{0}", field.NativeName), DbType.String,
                                                                        field.NativeName.Name);

            // param...
            builder.Append(" ");
            builder.Append(statement.Dialect.AndKeyword);
            builder.Append(" ");
            builder.Append(statement.Dialect.FormatNativeName(new NativeName("Name")));
            builder.Append("=");
            builder.Append(statement.Dialect.FormatVariableNameForQueryText(parameter.Name));

            // details...
            builder.Append(") AS ");
            builder.Append(statement.Dialect.FormatNativeName(field.NativeName));

            // add the parameter...
            statement.Parameters.Add(parameter);
        }
Exemple #8
0
 /// <summary>
 /// Sets the original filter.
 /// </summary>
 /// <param name="originalFilter"></param>
 internal void SetOriginalCreator(SqlStatementCreator originalCreator)
 {
     _originalCreator = originalCreator;
 }
Exemple #9
0
 /// <summary>
 /// Append SQL to select the extended properties from the extended table for the entity
 /// </summary>
 /// <param name="statement"></param>
 /// <param name="builder"></param>
 /// <param name="field"></param>
 public abstract void AddExtendedPropertyToSelectStatement(SqlStatementCreator creator, SqlStatement statement, StringBuilder builder,
                                                           EntityField field);