private void GenerateFromSql(FromSqlExpression fromSqlExpression) { var sql = fromSqlExpression.Sql; string[] substitutions = null; switch (fromSqlExpression.Arguments) { case ConstantExpression constantExpression when constantExpression.Value is CompositeRelationalParameter compositeRelationalParameter: { var subParameters = compositeRelationalParameter.RelationalParameters; substitutions = new string[subParameters.Count]; for (var i = 0; i < subParameters.Count; i++) { substitutions[i] = _sqlGenerationHelper.GenerateParameterNamePlaceholder(subParameters[i].InvariantName); } Sql.AddParameter(compositeRelationalParameter); break; } case ConstantExpression constantExpression when constantExpression.Value is object[] constantValues: { substitutions = new string[constantValues.Length]; for (var i = 0; i < constantValues.Length; i++) { var value = constantValues[i]; if (value is RawRelationalParameter rawRelationalParameter) { substitutions[i] = _sqlGenerationHelper.GenerateParameterNamePlaceholder(rawRelationalParameter.InvariantName); Sql.AddParameter(rawRelationalParameter); } else if (value is SqlConstantExpression sqlConstantExpression) { substitutions[i] = sqlConstantExpression.TypeMapping.GenerateSqlLiteral(sqlConstantExpression.Value); } } break; } } if (substitutions != null) { // ReSharper disable once CoVariantArrayConversion // InvariantCulture not needed since substitutions are all strings sql = string.Format(sql, substitutions); } Sql.AppendLines(sql); }