Exemplo n.º 1
0
        public override void AppendColumnNameForEntityFieldFilterConstraint(FilterConstraintAppendContext context,
                                                                            EntityFieldFilterConstraint constraint, SqlStatement statement, StringBuilder builder, EntityField field)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (constraint == null)
            {
                throw new ArgumentNullException("constraint");
            }
            if (statement == null)
            {
                throw new ArgumentNullException("statement");
            }
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            // Add the name paramter for the extended field
            string nameField = AddNameParameter(field, statement);

            if (nameField == null)
            {
                throw new InvalidOperationException("'nameField' is null.");
            }
            if (nameField.Length == 0)
            {
                throw new InvalidOperationException("'nameField' is zero-length.");
            }

            // This could cause a problem, it assumes the first key field is the primary key and that there is only one
            builder.Append(statement.Dialect.FormatNativeName(context.Creator.EntityType.GetKeyFields()[0].NativeName));
            builder.Append(" IN (");
            builder.Append(statement.Dialect.SelectKeyword);
            builder.Append(" ");
            builder.Append(statement.Dialect.FormatNativeName(context.Creator.EntityType.GetKeyFields()[0].NativeName));
            builder.Append(" ");
            builder.Append(statement.Dialect.FromKeyword);
            builder.Append(" ");
            builder.Append(statement.Dialect.FormatNativeName(context.Creator.EntityType.NativeNameExtended));
            builder.Append(" ");
            builder.Append(statement.Dialect.WhereKeyword);
            builder.Append(" ");
            builder.Append(statement.Dialect.FormatNativeName(ExtendedPropertySettings.GetExtendedNativeNameForNameColumn()));
            builder.Append(" ");
            builder.Append(statement.Dialect.GetOperatorKeyword(SqlOperator.EqualTo, field.DBType));
            builder.Append(" ");
            builder.Append(statement.Dialect.FormatVariableNameForQueryText(nameField));
            builder.Append(" ");
            builder.Append(statement.Dialect.AndKeyword);
            builder.Append(" ");

            // do the bitwise...
            constraint.AppendBitwiseOperators(builder, statement);
            builder.Append(statement.Dialect.FormatNativeName(GetColumnNameForDbType(field.DBType)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a constraint.
        /// </summary>
        /// <param name="item"></param>
        public EntityFieldFilterConstraint Add(EntityField field, SqlOperator filterOperator, object value)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            // create...
            if (Creator == null)
            {
                throw new ArgumentNullException("Creator");
            }
            EntityFieldFilterConstraint constraint = new EntityFieldFilterConstraint(this.Creator, field, filterOperator, value);

            // add...
            this.Add(constraint);

            // return...
            return(constraint);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a constraint.
        /// </summary>
        /// <param name="item"></param>
        public EntityFieldFilterConstraint Add(string fieldName, SqlOperator filterOperator, object value)
        {
            if (fieldName == null)
            {
                throw new ArgumentNullException("fieldName");
            }
            if (fieldName.Length == 0)
            {
                throw ExceptionHelper.CreateZeroLengthArgumentException("fieldName");
            }

            // check...
            if (Creator == null)
            {
                throw new ArgumentNullException("Creator");
            }

            // get the field...
            if (EntityType == null)
            {
                throw new ArgumentNullException("EntityType");
            }
            EntityField field = this.EntityType.Fields.GetField(fieldName, OnNotFound.ThrowException);

            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            // create...
            EntityFieldFilterConstraint constraint = new EntityFieldFilterConstraint(this.Creator, field, filterOperator, value);

            // add and return...
            this.Add(constraint);
            return(constraint);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Appends the column name for a field constraint.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="statement"></param>
 /// <param name="builder"></param>
 /// <param name="field"></param>
 public virtual void AppendColumnNameForEntityFieldFilterConstraint(FilterConstraintAppendContext context,
                                                                    EntityFieldFilterConstraint constraint, SqlStatement statement, StringBuilder builder, EntityField field)
 {
     // defer...
     this.AddExtendedPropertyToSelectStatement(context.Creator, statement, builder, field);
 }