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="mapProperty">The map property.</param>
/// <returns></returns>
Generates the join save query.
Generates the join save query .
private string GenerateJoinSaveQuery(IEnumerable<IIDProperty> foreignIDProperties, IMapProperty mapProperty)
        {
            var Builder = ObjectPool.Get();
            var WhereList = ObjectPool.Get();
            var ParametersList = ObjectPool.Get();
            var FromList = ObjectPool.Get();
            var Splitter2 = string.Empty;
            foreach (var ForeignID in foreignIDProperties.Distinct())
            {
                ParametersList
                    .Append(Splitter2)
                    .Append(GetTableName(mapProperty.ParentMapping))
                    .Append(".[")
                    .Append(ForeignID.ParentMapping?.TableName)
                    .Append(mapProperty.ParentMapping.Prefix)
                    .Append(mapProperty.Name)
                    .Append(mapProperty.ParentMapping.Suffix)
                    .Append(ForeignID.ColumnName)
                    .Append("] = @")
                    .Append(ForeignID.ParentMapping?.TableName)
                    .Append(mapProperty.ParentMapping.Prefix)
                    .Append(mapProperty.Name)
                    .Append(mapProperty.ParentMapping.Suffix)
                    .Append(ForeignID.ColumnName);
                Splitter2 = ", ";
            }
            Splitter2 = string.Empty;
            foreach (var IDProperty in IDProperties)
            {
                WhereList.Append(Splitter2).Append(GetColumnName(IDProperty)).Append(" = ").Append(GetParameterName(IDProperty));
                Splitter2 = " AND ";
            }
            FromList.Append(GetTableName(mapProperty.ParentMapping))
                .Append(GenerateFromClause(MappingInformation.TypeGraphs[mapProperty.ParentMapping.ObjectType]?.Root));
            Builder.AppendFormat("UPDATE {0} SET {1} FROM {2} WHERE {3};", GetTableName(mapProperty.ParentMapping), ParametersList, FromList, WhereList);
            var ReturnValue = Builder.ToString();
            ObjectPool.Return(Builder);
            ObjectPool.Return(WhereList);
            ObjectPool.Return(ParametersList);
            ObjectPool.Return(FromList);
            return ReturnValue;
        }
private string GenerateJoinSaveQuery ( IEnumerable < IIDProperty > foreignIDProperties , IMapProperty mapProperty ) { var Builder = ObjectPool . Get ( ) ; var WhereList = ObjectPool . Get ( ) ; var ParametersList = ObjectPool . Get ( ) ; var FromList = ObjectPool . Get ( ) ; var Splitter2 = string . Empty ; foreach ( var ForeignID in foreignIDProperties . Distinct ( ) ) { ParametersList . Append ( Splitter2 ) . Append ( GetTableName ( mapProperty . ParentMapping ) ) . Append ( " " ) . Append ( ForeignID . ParentMapping ? . TableName ) . Append ( mapProperty . ParentMapping . Prefix ) . Append ( mapProperty . Name ) . Append ( mapProperty . ParentMapping . Suffix ) . Append ( ForeignID . ColumnName ) . Append ( " " ) . Append ( ForeignID . ParentMapping ? . TableName ) . Append ( mapProperty . ParentMapping . Prefix ) . Append ( mapProperty . Name ) . Append ( mapProperty . ParentMapping . Suffix ) . Append ( ForeignID . ColumnName ) ; Splitter2 = " " ; } Splitter2 = string . Empty ; foreach ( var IDProperty in IDProperties ) { WhereList . Append ( Splitter2 ) . Append ( GetColumnName ( IDProperty ) ) . Append ( " " ) . Append ( GetParameterName ( IDProperty ) ) ; Splitter2 = " " ; } FromList . Append ( GetTableName ( mapProperty . ParentMapping ) ) . Append ( GenerateFromClause ( MappingInformation . TypeGraphs [ mapProperty . ParentMapping . ObjectType ] ? . Root ) ) ; Builder . AppendFormat ( " " , GetTableName ( mapProperty . ParentMapping ) , ParametersList , FromList , WhereList ) ; var ReturnValue = Builder . ToString ( ) ; ObjectPool . Return ( Builder ) ; ObjectPool . Return ( WhereList ) ; ObjectPool . Return ( ParametersList ) ; ObjectPool . Return ( FromList ) ; return ReturnValue ; }
Generates the join save query.
Generates the join save query .
None
foreignIDProperties
IEnumerable<IIDProperty>
The foreign identifier properties.
The foreign identifier properties .
mapProperty
IMapProperty
The map property.
The map property .