From c0f14d708db125b37c3989e59a906b19be5fca73 Mon Sep 17 00:00:00 2001
From: db2222 <36240951+db2222@users.noreply.github.com>
Date: Sat, 4 Jun 2022 11:54:02 +0200
Subject: [PATCH 1/5] Updated Oracle to fix vulnerability from dependency (#64)
---
Directory.Packages.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 32ffb0e..a0d246a 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -18,7 +18,7 @@
-
+
From f2d9b52355cd477b121d9bb3b013fc29346a5260 Mon Sep 17 00:00:00 2001
From: Stuart Turner
Date: Sat, 4 Jun 2022 13:45:45 -0500
Subject: [PATCH 2/5] Fix bug in pluralization code
---
Source/Pluralization.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Source/Pluralization.cs b/Source/Pluralization.cs
index ce2d6f0..a02f66c 100644
--- a/Source/Pluralization.cs
+++ b/Source/Pluralization.cs
@@ -26,7 +26,7 @@ public static string ToPlural(string str)
var word = GetLastWord(str);
var newWord = word.Pluralize();
- if (string.Equals(word, newWord, StringComparison.OrdinalIgnoreCase))
+ if (!string.Equals(word, newWord, StringComparison.OrdinalIgnoreCase))
{
if (char.IsUpper(word[0]))
newWord = char.ToUpper(newWord[0]) + newWord.Substring(1, newWord.Length - 1);
@@ -46,7 +46,7 @@ public static string ToSingular(string str)
var word = GetLastWord(str);
var newWord = word.Singularize();
- if (string.Equals(word, newWord, StringComparison.OrdinalIgnoreCase))
+ if (!string.Equals(word, newWord, StringComparison.OrdinalIgnoreCase))
{
if (char.IsUpper(word[0]))
newWord = char.ToUpper(newWord[0]) + newWord.Substring(1, newWord.Length - 1);
From 1a8044b326647229da4d9a053c79bb384c4e76f3 Mon Sep 17 00:00:00 2001
From: Stuart Turner
Date: Mon, 6 Jun 2022 10:07:23 -0500
Subject: [PATCH 3/5] Update to v4.0.0 (#66)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Update to v4.0.0
* code review
* remove?
* 🤦🏼♂️
* versions
* ...
* ...
---
Build/BuildNuspecs.ps1 | 2 +-
Build/azure-pipelines.yml | 8 +++----
Build/linq2db.LINQPad.nuspec | 26 +++++++++++-----------
Directory.Packages.props | 38 ++++++++++++++++----------------
MIT-LICENSE.txt | 2 +-
Source/DriverHelper.cs | 2 +-
Source/LinqToDBDriver.cs | 2 +-
Source/SchemaAndCodeGenerator.cs | 22 +++++++++---------
Source/XmlFormatter.cs | 2 +-
Source/linq2db.LINQPad.csproj | 4 ++--
release-notes.md | 19 ++++++++++++++++
11 files changed, 72 insertions(+), 55 deletions(-)
diff --git a/Build/BuildNuspecs.ps1 b/Build/BuildNuspecs.ps1
index f35254e..b4dd672 100644
--- a/Build/BuildNuspecs.ps1
+++ b/Build/BuildNuspecs.ps1
@@ -10,7 +10,7 @@ Set-StrictMode -Version Latest
if ($version) {
$nsUri = 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'
- $authors = 'Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko'
+ $authors = 'linq2db Developers'
$ns = @{ns=$nsUri}
$dotlessVersion = $version -replace '\.',''
$commit = (git rev-parse HEAD)
diff --git a/Build/azure-pipelines.yml b/Build/azure-pipelines.yml
index 4d66dc3..1bf7c94 100644
--- a/Build/azure-pipelines.yml
+++ b/Build/azure-pipelines.yml
@@ -1,10 +1,10 @@
variables:
solution: 'linq2db.LINQPad.sln'
build_configuration: 'Release'
- assemblyVersion: 3.6.0.0
- nugetVersion: 3.6.0
- nugetDevVersion: 3.6.1
- nugetPRVersion: 3.6.1
+ assemblyVersion: 4.0.0.0
+ nugetVersion: 4.0.0
+ nugetDevVersion: 4.0.1
+ nugetPRVersion: 4.0.1
artifact_lpx: 'lpx'
artifact_lpx6: 'lpx6'
artifact_nuget: 'nuget'
diff --git a/Build/linq2db.LINQPad.nuspec b/Build/linq2db.LINQPad.nuspec
index 6eda00c..7533add 100644
--- a/Build/linq2db.LINQPad.nuspec
+++ b/Build/linq2db.LINQPad.nuspec
@@ -11,26 +11,26 @@
README.md
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
-
+
+
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
index a0d246a..296a144 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,42 +1,42 @@
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt
index 4fcd75b..00d7aa0 100644
--- a/MIT-LICENSE.txt
+++ b/MIT-LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2016-2020 Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko
+Copyright (c) 2016-2022 linq2db Developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Source/DriverHelper.cs b/Source/DriverHelper.cs
index 94ba225..8b8f42d 100644
--- a/Source/DriverHelper.cs
+++ b/Source/DriverHelper.cs
@@ -20,7 +20,7 @@ namespace LinqToDB.LINQPad
{
static class DriverHelper
{
- public const string Author = "Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko";
+ public const string Author = "linq2db Developers";
public static void Init()
{
diff --git a/Source/LinqToDBDriver.cs b/Source/LinqToDBDriver.cs
index 04b1f6d..14eb8a5 100644
--- a/Source/LinqToDBDriver.cs
+++ b/Source/LinqToDBDriver.cs
@@ -110,7 +110,7 @@ public override List GetSchemaAndBuildAssembly(
// hack to overwrite provider assembly references that target wrong runtime
// e.g. gen.References contains path to net5 MySqlConnector
// but GetCoreFxReferenceAssemblies returns netcoreapp3.1 runtime references
- var coreAssemblies = GetCoreFxReferenceAssemblies();
+ var coreAssemblies = GetCoreFxReferenceAssemblies(cxInfo);
var runtimeToken = _runtimeTokenExtractor.Match(coreAssemblies[0]).Groups["token"].Value;
references.AddRange(coreAssemblies.Select(path => MetadataReference.CreateFromFile(path)));
diff --git a/Source/SchemaAndCodeGenerator.cs b/Source/SchemaAndCodeGenerator.cs
index 9303982..e44b753 100644
--- a/Source/SchemaAndCodeGenerator.cs
+++ b/Source/SchemaAndCodeGenerator.cs
@@ -465,13 +465,12 @@ ExplorerItem GetProcedures(string header, ExplorerIcon icon, List
{
- var sprocSqlName = _sqlBuilder!.BuildTableName(
+ var sprocSqlName = _sqlBuilder!.BuildObjectName(
new StringBuilder(),
- null,
- null,
- p.SchemaName == null ? null : _sqlBuilder.ConvertInline(p.SchemaName, ConvertType.NameToSchema),
- _sqlBuilder.ConvertInline(p.ProcedureName, ConvertType.NameToQueryTable),
- TableOptions.NotSet).ToString();
+ new SqlQuery.SqlObjectName(
+ Name: p.ProcedureName,
+ Schema: p.SchemaName),
+ tableOptions: TableOptions.NotSet).ToString();
var memberName = p.MemberName;
@@ -696,13 +695,12 @@ ExplorerItem GetTables(string header, ExplorerIcon icon, IEnumerable(Func add, Func> avr)
{
c.MemberType,
c.MemberName,
- GetValue = (Func)((ms, v) => c.GetValue(v)),
+ GetValue = (Func)((ms, v) => c.GetProviderValue(v)),
Total = new Total(),
})
.ToArray();
diff --git a/Source/linq2db.LINQPad.csproj b/Source/linq2db.LINQPad.csproj
index 3b8c885..63c0ada 100644
--- a/Source/linq2db.LINQPad.csproj
+++ b/Source/linq2db.LINQPad.csproj
@@ -7,10 +7,10 @@
linq2db
linq2db.LINQPad
$(Product)
- 3.6.0.0
+ 4.0.0.0
$(Version)
$(Version)
- Copyright © 2016-2021 Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko
+ Copyright © 2016-2022 linq2db Developers
linq2db.snk
true
true
diff --git a/release-notes.md b/release-notes.md
index 5ba0814..e27bdba 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -1,3 +1,22 @@
+# Release 4.0.0
+- [#63](https://github.com/linq2db/linq2db.LINQPad/pull/63) Update Oracle.ManagedDataAccess.Core dependency to fix warning (thanks @db2222)
+- [#65](https://github.com/linq2db/linq2db.LINQPad/pull/65) Fix bug in pluralization/singularization code
+- [ALL] dependency update: linq2db 3.6.0 -> 4.0.1
+- [ALL] dependency update: LINQPAD.Reference 1.1.0 -> 1.3.0
+- [ALL] dependency update: Humanizer.Core 2.13.14 -> 2.14.1
+- [ALL] dependency update: CodeJam 4.0.1 -> 4.1.0
+- [ALL] dependency update: System.Memory 4.5.4 -> 4.5.5
+- [ALL] dependency update: MySqlConnector 2.0.0 -> 2.1.10
+- [ALL] dependency update: System.Data.SQLite.Core 1.0.115.5 -> 1.0.116
+- [LINQPAD7] dependency update: Oracle.ManagedDataAccess.Core 3.21.4 -> 3.21.61
+- [LINQPAD7] dependency update: IBM.Data.DB2.Core 3.1.0.500 -> 3.1.0.600
+- [LINQPAD7] dependency update: dotMorten.Microsoft.SqlServer.Types 1.3.0 -> 1.5.0
+- [LINQPAD7] dependency update: Microsoft.CodeAnalysis.CSharp 4.0.1 -> 4.2.0
+- [LINQPAD7] dependency update: Npgsql 6.0.0 -> 6.0.4
+- [LINQPAD7] dependency update: FirebirdSql.Data.FirebirdClient 8.5.4 -> 9.0.1
+- [LINQPAD7] dependency update: System.Text.Json 6.0.0 -> 6.0.4
+- [LINQPAD5] dependency update: Oracle.ManagedDataAccess 19.13.0 -> 19.14.0
+
# Release 3.6.0
- starting from this release we use LINQPad 7 instead of 6 for testing, so LINQPad 6 compatibility not guarantied
- [#57](https://github.com/linq2db/linq2db.LINQPad/pull/57) use stable ordering of custom context properties. Thanks to [@RoyChase](https://github.com/RoyChase) for fix
From b2eb53d21597d84dc44be198f5278291d8362784 Mon Sep 17 00:00:00 2001
From: Stuart Turner
Date: Fri, 10 Jun 2022 05:08:42 -0500
Subject: [PATCH 4/5] Addl update fixes (#69)
* Force using System.Data.SqlClient
* Update generation code
---
Source/ConnectionViewModel.cs | 2 +-
Source/DriverHelper.cs | 4 +-
Source/ProviderHelper.cs | 70 ++++++------------
Source/SchemaAndCodeGenerator.cs | 120 ++++++++++++++++++++-----------
4 files changed, 102 insertions(+), 94 deletions(-)
diff --git a/Source/ConnectionViewModel.cs b/Source/ConnectionViewModel.cs
index c078e64..2f85276 100644
--- a/Source/ConnectionViewModel.cs
+++ b/Source/ConnectionViewModel.cs
@@ -19,7 +19,7 @@ public ProviderInfo(string name, string description)
public ConnectionViewModel()
{
_providers = new ObservableCollection(
- ProviderHelper.DynamicProviders.Select(p => new ProviderInfo(p.ProviderName, p.Description))
+ ProviderHelper.DynamicProviders.Select(p => new ProviderInfo(p.Name, p.Description))
.OrderBy(s => s.Description.ToLower()));
_optimizeJoins = true;
diff --git a/Source/DriverHelper.cs b/Source/DriverHelper.cs
index 8b8f42d..e2792bb 100644
--- a/Source/DriverHelper.cs
+++ b/Source/DriverHelper.cs
@@ -116,9 +116,9 @@ public static bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnec
};
cxInfo.DatabaseInfo.Provider = db.Connection.GetType().Namespace;
- cxInfo.DatabaseInfo.Server = ((DbConnection)db.Connection).DataSource;
+ cxInfo.DatabaseInfo.Server = db.Connection.DataSource;
cxInfo.DatabaseInfo.Database = db.Connection.Database;
- cxInfo.DatabaseInfo.DbVersion = ((DbConnection)db.Connection).ServerVersion;
+ cxInfo.DatabaseInfo.DbVersion = db.Connection.ServerVersion;
}
}
catch
diff --git a/Source/ProviderHelper.cs b/Source/ProviderHelper.cs
index 10dd544..1c996d4 100644
--- a/Source/ProviderHelper.cs
+++ b/Source/ProviderHelper.cs
@@ -25,7 +25,7 @@ internal class ProviderHelper
static void AddDataProvider(DynamicProviderRecord providerInfo)
{
if (providerInfo == null) throw new ArgumentNullException(nameof(providerInfo));
- _dynamicProviders.Add(providerInfo.ProviderName, providerInfo);
+ _dynamicProviders.Add(providerInfo.Name, providerInfo);
}
static ProviderHelper()
@@ -33,60 +33,38 @@ static ProviderHelper()
InitializeDataProviders();
}
- //static class DB2iSeriesProviderName
- //{
- // public const string DB2 = "DB2.iSeries";
- //}
-
static void InitializeDataProviders()
{
- AddDataProvider(new DynamicProviderRecord(ProviderName.Access , "Microsoft Access (OleDb)" , "System.Data.OleDb.OleDbConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.AccessOdbc , "Microsoft Access (ODBC)" , "System.Data.Odbc.OdbcConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.Firebird , "Firebird" , "FirebirdSql.Data.FirebirdClient.FbConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.MySqlConnector, "MySql" , "MySql.Data.MySqlClient.MySqlConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.PostgreSQL , "PostgreSQL" , "Npgsql.NpgsqlConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.SybaseManaged , "SAP/Sybase ASE" , "AdoNetCore.AseClient.AseConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.SQLiteClassic , "SQLite" , "System.Data.SQLite.SQLiteConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.SqlCe , "Microsoft SQL Server Compact" , "System.Data.SqlServerCe.SqlCeConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.DB2LUW , "DB2 for Linux, UNIX and Windows", "IBM.Data.DB2.DB2Connection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.DB2zOS , "DB2 for z/OS" , "IBM.Data.DB2.DB2Connection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.InformixDB2 , "Informix (IDS)" , "IBM.Data.DB2.DB2Connection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.SapHanaNative , "SAP HANA (Native)" , "Sap.Data.Hana.HanaConnection"));
- AddDataProvider(new DynamicProviderRecord(ProviderName.SapHanaOdbc , "SAP HANA (ODBC)" , "System.Data.Odbc.OdbcConnection"));
-
- AddDataProvider(new DynamicProviderRecord(ProviderName.OracleManaged , "Oracle (Managed)" , "Oracle.ManagedDataAccess.Client.OracleConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.Access , ProviderName.Access , "Microsoft Access (OleDb)" , "System.Data.OleDb.OleDbConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.AccessOdbc , ProviderName.AccessOdbc , "Microsoft Access (ODBC)" , "System.Data.Odbc.OdbcConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.Firebird , ProviderName.Firebird , "Firebird" , "FirebirdSql.Data.FirebirdClient.FbConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.MySqlConnector, ProviderName.MySqlConnector, "MySql" , "MySql.Data.MySqlClient.MySqlConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.PostgreSQL , ProviderName.PostgreSQL , "PostgreSQL" , "Npgsql.NpgsqlConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.SybaseManaged , ProviderName.SybaseManaged , "SAP/Sybase ASE" , "AdoNetCore.AseClient.AseConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.SQLiteClassic , ProviderName.SQLiteClassic , "SQLite" , "System.Data.SQLite.SQLiteConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.SqlCe , ProviderName.SqlCe , "Microsoft SQL Server Compact" , "System.Data.SqlServerCe.SqlCeConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.DB2LUW , ProviderName.DB2LUW , "DB2 for Linux, UNIX and Windows", "IBM.Data.DB2.DB2Connection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.DB2zOS , ProviderName.DB2zOS , "DB2 for z/OS" , "IBM.Data.DB2.DB2Connection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.InformixDB2 , ProviderName.InformixDB2 , "Informix (IDS)" , "IBM.Data.DB2.DB2Connection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.SapHanaNative , ProviderName.SapHanaNative , "SAP HANA (Native)" , "Sap.Data.Hana.HanaConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.SapHanaOdbc , ProviderName.SapHanaOdbc , "SAP HANA (ODBC)" , "System.Data.Odbc.OdbcConnection"));
+ AddDataProvider(new DynamicProviderRecord(ProviderName.OracleManaged , ProviderName.OracleManaged , "Oracle (Managed)" , "Oracle.ManagedDataAccess.Client.OracleConnection"));
+
// we use System.Data.SqlClient to be able to use Microsoft.SqlServer.Types
- AddDataProvider(new DynamicProviderRecord(ProviderName.SqlServer , "Microsoft SQL Server" , "System.Data.SqlClient.SqlConnection"));
-
- //AddDataProvider(
- // new DynamicProviderRecord(
- // ProviderName.SqlServer,
- // "Microsoft SQL Server",
- // "System.Data.SqlClient.SqlConnection")
- // {
- // AdditionalNamespaces = new[] { "Microsoft.SqlServer.Types" },
- // ProviderLibraries = "Microsoft.SqlServer.Types.dll"
- // });
-
- //AddDataProvider(new DynamicProviderRecord(DB2iSeriesProviderName.DB2, "DB2 iSeries (Requires iAccess 7.1 .NET Provider)", "IBM.Data.DB2.iSeries.iDB2Connection")
- //{
- // InitializationClassName = "LinqToDB.DataProvider.DB2iSeries.DB2iSeriesTools, LinqToDB.DataProvider.DB2iSeries",
- // ProviderLibraries = "LinqToDB.DataProvider.DB2iSeries.dll;IBM.Data.DB2.iSeries.dll"
- //});
+ AddDataProvider(new DynamicProviderRecord(ProviderName.SqlServer , "System.Data.SqlClient" , "Microsoft SQL Server" , "System.Data.SqlClient.SqlConnection"));
}
public class DynamicProviderRecord
{
+ public string Name { get; }
public string ProviderName { get; }
public string Description { get; }
public string ConnectionTypeName { get; }
public IReadOnlyCollection Libraries { get; }
- public string? InitializationClassName { get; set; }
- public NamedValue[]? ProviderNamedValues { get; set; }
- public string[]? AdditionalNamespaces { get; set; }
- public DynamicProviderRecord(string providerName, string description, string connectionTypeName, params string[] providerLibraries)
+ public DynamicProviderRecord(string name, string providerName, string description, string connectionTypeName, params string[] providerLibraries)
{
+ Name = name;
ProviderName = providerName;
Description = description;
ConnectionTypeName = connectionTypeName;
@@ -136,14 +114,6 @@ public void Load(string connectionString)
.Concat(new[] { typeof(DataConnection).Assembly })
.ToArray();
-
- var typeName = Provider.InitializationClassName;
- if (!string.IsNullOrEmpty(typeName))
- {
- var initType = Type.GetType(typeName, true)!;
- RuntimeHelpers.RunClassConstructor(initType.TypeHandle);
- }
-
var provider = ProviderHelper.GetDataProvider(Provider.ProviderName, connectionString);
var connectionAssemblies = new List() { provider.GetType().Assembly };
diff --git a/Source/SchemaAndCodeGenerator.cs b/Source/SchemaAndCodeGenerator.cs
index e44b753..6724905 100644
--- a/Source/SchemaAndCodeGenerator.cs
+++ b/Source/SchemaAndCodeGenerator.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Text;
using CodeJam.Strings;
@@ -110,11 +111,6 @@ public IEnumerable GetItemsAndCode(string nameSpace, string typeNa
Code.AppendLine($"using {_schema.ProviderSpecificTypeNamespace};");
References.AddRange(providerInfo.GetAssemblyLocation(connectionString));
- if (providerInfo.Provider.AdditionalNamespaces != null)
- foreach (var ns in providerInfo.Provider.AdditionalNamespaces)
- {
- Code.AppendLine($"using {ns};");
- }
Code
.AppendLine($"namespace {nameSpace}")
@@ -249,6 +245,8 @@ void CodeProcedure(StringBuilder code, ProcedureSchema p, string sprocSqlName)
{
code.Append($" [Sql.TableFunction(Name={CSharpTools.ToStringLiteral(p.ProcedureName)}");
+ if (p.PackageName != null)
+ code.Append($", Package={CSharpTools.ToStringLiteral(p.PackageName)})");
if (p.SchemaName != null)
code.Append($", Schema={CSharpTools.ToStringLiteral(p.SchemaName)})");
@@ -335,8 +333,6 @@ void CodeProcedure(StringBuilder code, ProcedureSchema p, string sprocSqlName)
spName = CSharpTools.ToStringLiteral($"{{ CALL {p.ProcedureName}({paramTokens}) }}");
}
- spName += inOrOutputParameters.Count == 0 ? ");" : ",";
-
var retName = "__ret__";
var retNo = 0;
@@ -346,9 +342,78 @@ void CodeProcedure(StringBuilder code, ProcedureSchema p, string sprocSqlName)
var hasOut = outputParameters.Any(pr => pr.IsOut || pr.IsResult);
var prefix = hasOut ? $"var {retName} =" : "return";
+ var cnt = 0;
+ var parametersVarName = "parameters";
+ while (p.Parameters.Where(par => !par.IsResult || !p.IsFunction).Any(par => par.ParameterName == parametersVarName))
+ parametersVarName = string.Format("parameters{0}", cnt++);
+
+ if (inOrOutputParameters.Count > 0)
+ {
+ code.AppendLine($" var {parametersVarName} = new[]");
+ code.AppendLine(" {");
+
+ for (var i = 0; i < inOrOutputParameters.Count; i++)
+ {
+ var pr = inOrOutputParameters[i];
+ var hasInputValue = pr.IsIn || (pr.IsOut && pr.IsResult);
+
+ var extraInitializers = new List<(string, string)>();
+ extraInitializers.Add(("DbType", CSharpTools.ToStringLiteral(pr.SchemaType)));
+
+ if (pr.IsOut || pr.IsResult)
+ extraInitializers.Add(("Direction", pr.IsIn ? "ParameterDirection.InputOutput" : pr.IsResult ? "ParameterDirection.ReturnValue" : "ParameterDirection.Output"));
+
+ if (pr.Size != null && pr.Size.Value != 0 && pr.Size.Value >= int.MinValue && pr.Size.Value <= int.MaxValue)
+ extraInitializers.Add(("Size", pr.Size.Value.ToString(CultureInfo.InvariantCulture)));
+
+ var endLine = i < inOrOutputParameters.Count - 1 && extraInitializers.Count == 0 ? "," : "";
+
+ if (hasInputValue)
+ {
+ code.AppendLine(string.Format(
+ "\tnew DataParameter({0}, {1}, {2}){3}",
+ CSharpTools.ToStringLiteral(pr.SchemaName),
+ pr.ParameterName,
+ "LinqToDB.DataType." + pr.DataType,
+ endLine));
+ }
+ else
+ {
+ code.AppendLine(string.Format(
+ "\tnew DataParameter({0}, null, {1}){2}",
+ CSharpTools.ToStringLiteral(pr.SchemaName),
+ "LinqToDB.DataType." + pr.DataType,
+ endLine));
+ }
+
+ if (extraInitializers.Count > 0)
+ {
+ code.AppendLine("\t{");
+
+ for (var j = 0; j < extraInitializers.Count; j++)
+ code.AppendLine(string.Format(
+ "\t\t{0} = {1},",
+ extraInitializers[j].Item1,
+ extraInitializers[j].Item2));
+
+ code.AppendLine("\t},");
+ }
+ }
+
+ code.AppendLine("};");
+ code.AppendLine("");
+ }
+
+ // we need to call ToList(), because otherwise output parameters will not be updated
+ // with values. See https://docs.microsoft.com/en-us/previous-versions/dotnet/articles/ms971497(v=msdn.10)#capturing-the-gazoutas
+ var terminator = outputParameters.Count > 0 && p.ResultTable != null ? ").ToList();" : ");";
+
+ if (inOrOutputParameters.Count > 0)
+ terminator = string.Format(", {0}{1}", parametersVarName, terminator);
+
if (p.ResultTable == null)
{
- code.Append($" {prefix} this.ExecuteProc({spName}");
+ code.Append($" {prefix} this.ExecuteProc({spName}{terminator}");
}
else
{
@@ -381,50 +446,21 @@ void CodeProcedure(StringBuilder code, ProcedureSchema p, string sprocSqlName)
}
code.AppendLine( " },");
- code.AppendLine($" {spName}");
+ code.AppendLine($" {spName}{terminator}");
}
else
{
- code.AppendLine($" {prefix} this.QueryProc<{p.ResultTable.TypeName}>({spName}");
+ code.AppendLine($" {prefix} this.QueryProc<{p.ResultTable.TypeName}>({spName}{terminator}");
}
}
- for (var i = 0; i < inOrOutputParameters.Count; i++)
- {
- var pr = inOrOutputParameters[i];
-
- var str = string.Format(
- !pr.IsIn && (pr.IsOut || pr.IsResult)
- ? " new DataParameter({0}, null, LinqToDB.DataType.{2})"
- : " new DataParameter({0}, {1}, LinqToDB.DataType.{2})",
- CSharpTools.ToStringLiteral(pr.SchemaName),
- pr.ParameterName,
- pr.DataType);
-
- if (pr.IsOut || pr.IsResult)
- {
- str += " { Direction = " + (pr.IsIn ? "ParameterDirection.InputOutput" : (pr.IsResult ? "ParameterDirection.ReturnValue" : "ParameterDirection.Output"));
-
- if (pr.Size != null && pr.Size.Value != 0)
- str += ", Size = " + pr.Size.Value;
-
- str += " }";
- }
-
- // we need to call ToList(), because otherwise output parameters will not be updated
- // with values. See https://msdn.microsoft.com/en-us/library/ms971497#gazoutas_topic6
- str += i + 1 == inOrOutputParameters.Count ? (outputParameters.Count > 0 && p.ResultTable != null ? ").ToList();" : ");") : ",";
-
- code.AppendLine(str);
- }
-
if (hasOut)
{
code.AppendLine();
foreach (var pr in p.Parameters.Where(_ => _.IsOut || _.IsResult))
{
- var str = $" {pr.ParameterName} = Converter.ChangeTypeTo<{pr.ParameterType}>(((IDbDataParameter)this.Command.Parameters[\"{pr.SchemaName}\"]).Value);";
+ var str = $" {pr.ParameterName} = Converter.ChangeTypeTo<{pr.ParameterType}>({parametersVarName}[{inOrOutputParameters.IndexOf(pr)}].Value);";
code.AppendLine(str);
}
@@ -531,7 +567,9 @@ void CodeTable(StringBuilder classCode, TableSchema table, bool addTableAttribut
{
classCode.Append($" [Table(Name={CSharpTools.ToStringLiteral(table.TableName)}");
- if (table.SchemaName.NotNullNorEmpty())
+ if (table.GroupName.NotNullNorEmpty())
+ classCode.Append($", Schema={CSharpTools.ToStringLiteral(table.GroupName)}");
+ else if (table.SchemaName.NotNullNorEmpty())
classCode.Append($", Schema={CSharpTools.ToStringLiteral(table.SchemaName)}");
classCode.AppendLine(")]");
From 8c69972cb901247b46d33a67f8f541e0a82fa945 Mon Sep 17 00:00:00 2001
From: MaceWindu
Date: Fri, 10 Jun 2022 12:28:26 +0200
Subject: [PATCH 5/5] linq2db -> Linq To DB
---
Build/BuildNuspecs.ps1 | 2 +-
MIT-LICENSE.txt | 2 +-
Source/DriverHelper.cs | 2 +-
Source/linq2db.LINQPad.csproj | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Build/BuildNuspecs.ps1 b/Build/BuildNuspecs.ps1
index b4dd672..9c1e861 100644
--- a/Build/BuildNuspecs.ps1
+++ b/Build/BuildNuspecs.ps1
@@ -10,7 +10,7 @@ Set-StrictMode -Version Latest
if ($version) {
$nsUri = 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'
- $authors = 'linq2db Developers'
+ $authors = 'Linq To DB Team'
$ns = @{ns=$nsUri}
$dotlessVersion = $version -replace '\.',''
$commit = (git rev-parse HEAD)
diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt
index 00d7aa0..6223674 100644
--- a/MIT-LICENSE.txt
+++ b/MIT-LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2016-2022 linq2db Developers
+Copyright (c) 2016-2022 Linq To DB Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Source/DriverHelper.cs b/Source/DriverHelper.cs
index e2792bb..21760bb 100644
--- a/Source/DriverHelper.cs
+++ b/Source/DriverHelper.cs
@@ -20,7 +20,7 @@ namespace LinqToDB.LINQPad
{
static class DriverHelper
{
- public const string Author = "linq2db Developers";
+ public const string Author = "Linq To DB Team";
public static void Init()
{
diff --git a/Source/linq2db.LINQPad.csproj b/Source/linq2db.LINQPad.csproj
index 63c0ada..c9d27b2 100644
--- a/Source/linq2db.LINQPad.csproj
+++ b/Source/linq2db.LINQPad.csproj
@@ -10,7 +10,7 @@
4.0.0.0
$(Version)
$(Version)
- Copyright © 2016-2022 linq2db Developers
+ Copyright © 2016-2022 Linq To DB Team
linq2db.snk
true
true