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))); }
/// <summary> /// Append insert into extended table /// </summary> /// <param name="context"></param> /// <param name="extendedField"></param> /// <param name="builder"></param> /// <param name="statement"></param> protected void AppendInsertIntoExtendedTable(WorkUnitProcessingContext context, EntityField extendedField, StringBuilder builder, SqlStatement statement) { if (context == null) { throw new ArgumentNullException("context"); } EntityField[] keyFields = GetKeyFields(); string propertyName = AddPropertyNameParameter(extendedField, statement); string propertyNameParameter = FlatTableExtensibilityProvider.AddNameParameter(extendedField, statement); // Append the inssert statements builder.Append(statement.Dialect.InsertIntoKeyword); builder.Append(" "); // mbr - 08-12-2005 - changed... // builder.Append(statement.Dialect.FormatNativeName(ExtendedPropertySettings.GetExtendedNativeNameForEntityType(EntityType))); builder.Append(statement.Dialect.FormatNativeName(this.EntityType.NativeNameExtended)); builder.Append(" ("); builder.Append(statement.Dialect.FormatNativeName(FlatTableExtensibilityProvider.GetColumnNameForDbType(extendedField.DBType))); builder.Append(statement.Dialect.IdentifierSeparator); builder.Append(statement.Dialect.FormatNativeName(ExtendedPropertySettings.GetExtendedNativeNameForNameColumn())); for (int index = 0; index < keyFields.Length; index++) { builder.Append(statement.Dialect.IdentifierSeparator); builder.Append(statement.Dialect.FormatNativeName(keyFields[index].NativeName)); } builder.Append(") "); builder.Append(statement.Dialect.ValuesKeyword); builder.Append(" ("); // create the param... builder.Append(statement.Dialect.FormatVariableNameForQueryText(propertyName)); builder.Append(statement.Dialect.IdentifierSeparator); builder.Append(statement.Dialect.FormatVariableNameForQueryText(propertyNameParameter)); for (int index = 0; index < keyFields.Length; index++) { // create the param... SqlStatementParameter param = null; if (!statement.Parameters.Contains(keyFields[index].NativeName.Name)) { AddPropertyNameParameter(keyFields[index], statement); } // Get the parameter param = statement.Parameters[keyFields[index].Name]; // We need to get the id of the field if it is auto generated from the context if (context.Bag.LastCreatedId != null) { param.Value = context.Bag.LastCreatedId; } // add... builder.Append(statement.Dialect.IdentifierSeparator); builder.Append(statement.Dialect.FormatVariableNameForQueryText(param.Name)); } }
/// <summary> /// Loads configuration from whichever store the application wishes to use. /// </summary> public virtual void LoadConfiguration(ExtendedPropertySettings settings) { // this should never be called. inheriting classes need to override UseDefaultSerialization, this method and the save method. throw new NotImplementedException(string.Format("Not implemented for '{0}'.", this.GetType())); }