src/Inflatable/QueryProvider/Providers/SQLServer/QueryGenerators/SavePropertiesQuery.cs
/// <summary>
/// Generates the join save query.
/// </summary>
/// <param name="foreignIDProperties">The foreign identifier properties.</param>
/// <param name="property">The property.</param>
/// <returns></returns>
Generates the join save query.
Generates the join save query .
private string GenerateJoinSaveQuery(IEnumerable<IIDProperty> foreignIDProperties, IManyToManyProperty property)
        {
            var Builder = ObjectPool.Get();
            var PropertyNames = ObjectPool.Get();
            var PropertyValues = ObjectPool.Get();
            var ParametersList = ObjectPool.Get();
            var Splitter = string.Empty;
            foreach (var ForeignID in foreignIDProperties.Distinct())
            {
                PropertyNames.Append(Splitter).Append("[").Append(property.ParentMapping.SchemaName).Append("].[").Append(property.TableName).Append("].[").Append(ForeignID.ParentMapping.TableName).Append(ForeignID.ColumnName).Append("]");
                PropertyValues.Append(Splitter).Append("@").Append(ForeignID.ParentMapping.TableName).Append(ForeignID.ColumnName);
                Splitter = ", ";
            }
            var Prefix = string.Empty;
            if (IDProperties.Any(x => property.ForeignMapping.Any(TempMapping => x.ParentMapping == TempMapping)))
            {
                Prefix = "Parent_";
            }
            foreach (var IDProperty in IDProperties)
            {
                PropertyNames.Append(Splitter).Append("[").Append(property.ParentMapping.SchemaName).Append("].[").Append(property.TableName).Append("].[").Append(Prefix).Append(IDProperty.ParentMapping.TableName).Append(IDProperty.ColumnName).Append("]");
                PropertyValues.Append(Splitter).Append("@").Append(Prefix).Append(IDProperty.ParentMapping.TableName).Append(IDProperty.ColumnName);
                Splitter = ", ";
            }
            Builder.AppendFormat("INSERT INTO {0}({1}) VALUES ({2});", GetTableName(property), PropertyNames, PropertyValues);
            var ReturnValue = Builder.ToString();
            ObjectPool.Return(Builder);
            ObjectPool.Return(PropertyNames);
            ObjectPool.Return(PropertyValues);
            ObjectPool.Return(ParametersList);
            return ReturnValue;
        }
private string GenerateJoinSaveQuery ( IEnumerable < IIDProperty > foreignIDProperties , IManyToManyProperty property ) { var Builder = ObjectPool . Get ( ) ; var PropertyNames = ObjectPool . Get ( ) ; var PropertyValues = ObjectPool . Get ( ) ; var ParametersList = ObjectPool . Get ( ) ; var Splitter = string . Empty ; foreach ( var ForeignID in foreignIDProperties . Distinct ( ) ) { PropertyNames . Append ( Splitter ) . Append ( " " ) . Append ( property . ParentMapping . SchemaName ) . Append ( " " ) . Append ( property . TableName ) . Append ( " " ) . Append ( ForeignID . ParentMapping . TableName ) . Append ( ForeignID . ColumnName ) . Append ( " " ) ; PropertyValues . Append ( Splitter ) . Append ( " " ) . Append ( ForeignID . ParentMapping . TableName ) . Append ( ForeignID . ColumnName ) ; Splitter = " " ; } var Prefix = string . Empty ; if ( IDProperties . Any ( x => property . ForeignMapping . Any ( TempMapping => x . ParentMapping == TempMapping ) ) ) { Prefix = " " ; } foreach ( var IDProperty in IDProperties ) { PropertyNames . Append ( Splitter ) . Append ( " " ) . Append ( property . ParentMapping . SchemaName ) . Append ( " " ) . Append ( property . TableName ) . Append ( " " ) . Append ( Prefix ) . Append ( IDProperty . ParentMapping . TableName ) . Append ( IDProperty . ColumnName ) . Append ( " " ) ; PropertyValues . Append ( Splitter ) . Append ( " " ) . Append ( Prefix ) . Append ( IDProperty . ParentMapping . TableName ) . Append ( IDProperty . ColumnName ) ; Splitter = " " ; } Builder . AppendFormat ( " " , GetTableName ( property ) , PropertyNames , PropertyValues ) ; var ReturnValue = Builder . ToString ( ) ; ObjectPool . Return ( Builder ) ; ObjectPool . Return ( PropertyNames ) ; ObjectPool . Return ( PropertyValues ) ; ObjectPool . Return ( ParametersList ) ; return ReturnValue ; }
Generates the join save query.
Generates the join save query .
None
foreignIDProperties
IEnumerable<IIDProperty>
The foreign identifier properties.
The foreign identifier properties .
property
IManyToManyProperty
None