mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 增加 IAdo.CommandFluent(sql) 方法执行 SQL 命令;
- 修复 SqlServer SqlBulkCopy IgnoreColumns 无效的 bug;
This commit is contained in:
parent
9b93200237
commit
8a0862d6fe
@ -12,7 +12,7 @@
|
||||
<Description>使用 FreeSql 快速生成数据库的实体类,安装:dotnet tool install -g FreeSql.Generator</Description>
|
||||
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
||||
<Version>1.8.1.330</Version>
|
||||
<Version>1.9.0-preview0920</Version>
|
||||
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -130,13 +130,6 @@
|
||||
清空状态数据
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
|
||||
<summary>
|
||||
根据 lambda 条件删除数据
|
||||
</summary>
|
||||
<param name="predicate"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||
<summary>
|
||||
添加
|
||||
|
@ -171,6 +171,7 @@ namespace FreeSql.Tests.SqlServer
|
||||
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100, CreateTime = DateTime.Now });
|
||||
|
||||
insert.AppendData(items).InsertIdentity().ExecuteSqlBulkCopy();
|
||||
insert.AppendData(items).IgnoreColumns(a => new { a.CreateTime, a.Clicks }).ExecuteSqlBulkCopy();
|
||||
// System.NotSupportedException:“DataSet does not support System.Nullable<>.”
|
||||
}
|
||||
|
||||
|
@ -2805,6 +2805,21 @@
|
||||
<param name="obj">new { id = 1 } 或者 Dictionary<string, object></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.IAdo.CommandFluent(System.String,System.Object)">
|
||||
<summary>
|
||||
SQL 命令执行类,fsql.Ado.CommandFluent("select * from user where age > ?age", new { age = 25 })<para></para>
|
||||
.WithConnection(connection)<para></para>
|
||||
.WithTransaction(transaction)<para></para>
|
||||
.WithParameter("age", 25)<para></para>
|
||||
.WithParameter("id", 11)<para></para>
|
||||
.CommandType(CommandType.Text)<para></para>
|
||||
.CommandTimeout(60)<para></para>
|
||||
.Query<T>(); 或者 ExecuteNonQuery/ExecuteScalar/ExecuteDataTable/ExecuteDataSet/ExecuteArray
|
||||
</summary>
|
||||
<param name="cmdText"></param>
|
||||
<param name="parms"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.IAdo.ExecuteConnectTest(System.Int32)">
|
||||
<summary>
|
||||
测试数据库是否连接正确,本方法执行如下命令:<para></para>
|
||||
@ -3674,6 +3689,43 @@
|
||||
<param name="where">表达式</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.Internal.Model.AdoCommandFluent.WithConnection(System.Data.Common.DbConnection)">
|
||||
<summary>
|
||||
使用指定 DbConnection 连接执行
|
||||
</summary>
|
||||
<param name="conn"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.Internal.Model.AdoCommandFluent.WithTransaction(System.Data.Common.DbTransaction)">
|
||||
<summary>
|
||||
使用指定 DbTransaction 事务执行
|
||||
</summary>
|
||||
<param name="tran"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.Internal.Model.AdoCommandFluent.WithParameter(System.String,System.Object,System.Action{System.Data.Common.DbParameter})">
|
||||
<summary>
|
||||
增加参数化对象
|
||||
</summary>
|
||||
<param name="parameterName">参数名</param>
|
||||
<param name="value">参数值</param>
|
||||
<param name="modify">修改本次创建好的参数化对象,比如将 parameterName 参数修改为 Output 类型</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.Internal.Model.AdoCommandFluent.CommandType(System.Data.CommandType)">
|
||||
<summary>
|
||||
设置执行的命令类型,SQL文本、或存储过程
|
||||
</summary>
|
||||
<param name="commandType"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.Internal.Model.AdoCommandFluent.CommandTimeout(System.Int32)">
|
||||
<summary>
|
||||
设置命令执行超时(秒)
|
||||
</summary>
|
||||
<param name="commandTimeout"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:FreeSql.Internal.Model.BatchProgressStatus`1.Data">
|
||||
<summary>
|
||||
当前操作的数据
|
||||
|
@ -62,6 +62,21 @@ namespace FreeSql
|
||||
/// <returns></returns>
|
||||
DbParameter[] GetDbParamtersByObject(object obj);
|
||||
|
||||
/// <summary>
|
||||
/// SQL 命令执行类,fsql.Ado.CommandFluent("select * from user where age > ?age", new { age = 25 })<para></para>
|
||||
/// .WithConnection(connection)<para></para>
|
||||
/// .WithTransaction(transaction)<para></para>
|
||||
/// .WithParameter("age", 25)<para></para>
|
||||
/// .WithParameter("id", 11)<para></para>
|
||||
/// .CommandType(CommandType.Text)<para></para>
|
||||
/// .CommandTimeout(60)<para></para>
|
||||
/// .Query<T>(); 或者 ExecuteNonQuery/ExecuteScalar/ExecuteDataTable/ExecuteDataSet/ExecuteArray
|
||||
/// </summary>
|
||||
/// <param name="cmdText"></param>
|
||||
/// <param name="parms"></param>
|
||||
/// <returns></returns>
|
||||
AdoCommandFluent CommandFluent(string cmdText, object parms = null);
|
||||
|
||||
/// <summary>
|
||||
/// 测试数据库是否连接正确,本方法执行如下命令:<para></para>
|
||||
/// MySql/SqlServer/PostgreSQL/达梦/人大金仓/神通: SELECT 1<para></para>
|
||||
|
@ -16,8 +16,8 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
|
||||
protected abstract void ReturnConnection(IObjectPool<DbConnection> pool, Object<DbConnection> conn, Exception ex);
|
||||
protected abstract DbCommand CreateCommand();
|
||||
protected abstract DbParameter[] GetDbParamtersByObject(string sql, object obj);
|
||||
public abstract DbCommand CreateCommand();
|
||||
public abstract DbParameter[] GetDbParamtersByObject(string sql, object obj);
|
||||
public DbParameter[] GetDbParamtersByObject(object obj) => GetDbParamtersByObject("*", obj);
|
||||
|
||||
protected bool IsTracePerformance => _util?._orm?.Aop.CommandAfterHandler != null;
|
||||
@ -28,6 +28,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
public string ConnectionString { get; }
|
||||
public string[] SlaveConnectionStrings { get; }
|
||||
public Guid Identifier { get; }
|
||||
|
||||
protected CommonUtils _util { get; set; }
|
||||
protected int slaveUnavailables = 0;
|
||||
private object slaveLock = new object();
|
||||
@ -97,6 +98,8 @@ namespace FreeSql.Internal.CommonProvider
|
||||
//return props;
|
||||
}
|
||||
|
||||
public AdoCommandFluent CommandFluent(string cmdText, object parms = null) => new AdoCommandFluent(this, cmdText, parms);
|
||||
|
||||
public bool ExecuteConnectTest(int commandTimeout = 0)
|
||||
{
|
||||
try
|
||||
|
113
FreeSql/Internal/Model/AdoCommandFluent.cs
Normal file
113
FreeSql/Internal/Model/AdoCommandFluent.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql.Internal.Model
|
||||
{
|
||||
public class AdoCommandFluent
|
||||
{
|
||||
internal protected AdoProvider Ado { get; protected set; }
|
||||
internal protected DbConnection Connection { get; protected set; }
|
||||
internal protected DbTransaction Transaction { get; protected set; }
|
||||
internal protected CommandType CmdType { get; protected set; } = System.Data.CommandType.Text;
|
||||
internal protected string CmdText { get; protected set; }
|
||||
internal protected int CmdTimeout { get; protected set; }
|
||||
internal protected List<DbParameter> CmdParameters { get; } = new List<DbParameter>();
|
||||
|
||||
public AdoCommandFluent(AdoProvider ado, string commandText, object parms)
|
||||
{
|
||||
this.Ado = ado;
|
||||
this.CmdText = commandText;
|
||||
this.CmdParameters.AddRange(this.Ado.GetDbParamtersByObject(parms));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用指定 DbConnection 连接执行
|
||||
/// </summary>
|
||||
/// <param name="conn"></param>
|
||||
/// <returns></returns>
|
||||
public AdoCommandFluent WithConnection(DbConnection conn)
|
||||
{
|
||||
this.Transaction = null;
|
||||
this.Connection = conn;
|
||||
return this;
|
||||
}
|
||||
/// <summary>
|
||||
/// 使用指定 DbTransaction 事务执行
|
||||
/// </summary>
|
||||
/// <param name="tran"></param>
|
||||
/// <returns></returns>
|
||||
public AdoCommandFluent WithTransaction(DbTransaction tran)
|
||||
{
|
||||
this.Transaction = tran;
|
||||
if (tran != null) this.Connection = tran.Connection;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加参数化对象
|
||||
/// </summary>
|
||||
/// <param name="parameterName">参数名</param>
|
||||
/// <param name="value">参数值</param>
|
||||
/// <param name="modify">修改本次创建好的参数化对象,比如将 parameterName 参数修改为 Output 类型</param>
|
||||
/// <returns></returns>
|
||||
public AdoCommandFluent WithParameter(string parameterName, object value, Action<DbParameter> modify = null)
|
||||
{
|
||||
var param = this.Ado.GetDbParamtersByObject(new Dictionary<string, object> { [parameterName] = value }).FirstOrDefault();
|
||||
modify?.Invoke(param);
|
||||
this.CmdParameters.Add(param);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置执行的命令类型,SQL文本、或存储过程
|
||||
/// </summary>
|
||||
/// <param name="commandType"></param>
|
||||
/// <returns></returns>
|
||||
public AdoCommandFluent CommandType(CommandType commandType)
|
||||
{
|
||||
this.CmdType = commandType;
|
||||
return this;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置命令执行超时(秒)
|
||||
/// </summary>
|
||||
/// <param name="commandTimeout"></param>
|
||||
/// <returns></returns>
|
||||
public AdoCommandFluent CommandTimeout(int commandTimeout)
|
||||
{
|
||||
this.CmdTimeout = commandTimeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery() => this.Ado.ExecuteNonQuery(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public object ExecuteScalar() => this.Ado.ExecuteScalar(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public DataTable ExecuteDataTable() => this.Ado.ExecuteDataTable(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public DataSet ExecuteDataSet() => this.Ado.ExecuteDataSet(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public object[][] ExecuteArray() => this.Ado.ExecuteArray(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public List<T> Query<T>() => this.Ado.Query<T>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public NativeTuple<List<T1>, List<T2>> Query<T1, T2>() => this.Ado.Query<T1, T2>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public NativeTuple<List<T1>, List<T2>, List<T3>> Query<T1, T2, T3>() => this.Ado.Query<T1, T2, T3>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public NativeTuple<List<T1>, List<T2>, List<T3>, List<T4>> Query<T1, T2, T3, T4>() => this.Ado.Query<T1, T2, T3, T4>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public NativeTuple<List<T1>, List<T2>, List<T3>, List<T4>, List<T5>> Query<T1, T2, T3, T4, T5>() => this.Ado.Query<T1, T2, T3, T4, T5>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
|
||||
#if net40
|
||||
#else
|
||||
public Task<int> ExecuteNonQueryAsync() => this.Ado.ExecuteNonQueryAsync(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<object> ExecuteScalarAsync() => this.Ado.ExecuteScalarAsync(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<DataTable> ExecuteDataTableAsync() => this.Ado.ExecuteDataTableAsync(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<DataSet> ExecuteDataSetAsync() => this.Ado.ExecuteDataSetAsync(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<object[][]> ExecuteArrayAsync() => this.Ado.ExecuteArrayAsync(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<List<T>> QueryAsync<T>() => this.Ado.QueryAsync<T>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<NativeTuple<List<T1>, List<T2>>> QueryAsync<T1, T2>() => this.Ado.QueryAsync<T1, T2>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<NativeTuple<List<T1>, List<T2>, List<T3>>> QueryAsync<T1, T2, T3>() => this.Ado.QueryAsync<T1, T2, T3>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<NativeTuple<List<T1>, List<T2>, List<T3>, List<T4>>> QueryAsync<T1, T2, T3, T4>() => this.Ado.QueryAsync<T1, T2, T3, T4>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
public Task<NativeTuple<List<T1>, List<T2>, List<T3>, List<T4>, List<T5>>> QueryAsync<T1, T2, T3, T4, T5>() => this.Ado.QueryAsync<T1, T2, T3, T4, T5>(this.Connection, this.Transaction, this.CmdType, this.CmdText, this.CmdTimeout, this.CmdParameters.ToArray());
|
||||
#endif
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ namespace FreeSql.Dameng
|
||||
//if (param is string) return string.Concat('N', nparms[a]);
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new DmCommand();
|
||||
}
|
||||
@ -72,6 +72,6 @@ namespace FreeSql.Dameng
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ namespace FreeSql.Firebird
|
||||
}
|
||||
|
||||
DbConnection _CreateCommandConnection;
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
if (_CreateCommandConnection != null)
|
||||
{
|
||||
@ -80,6 +80,6 @@ namespace FreeSql.Firebird
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace FreeSql.KingbaseES
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new KdbndpCommand();
|
||||
}
|
||||
@ -73,6 +73,6 @@ namespace FreeSql.KingbaseES
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace FreeSql.MsAccess
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OleDbCommand();
|
||||
}
|
||||
@ -77,6 +77,6 @@ namespace FreeSql.MsAccess
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
@ -67,7 +67,7 @@ namespace FreeSql.MySql
|
||||
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new MySqlCommand();
|
||||
}
|
||||
@ -79,6 +79,6 @@ namespace FreeSql.MySql
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace FreeSql.Odbc.Dameng
|
||||
//if (param is string) return string.Concat('N', nparms[a]);
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OdbcCommand();
|
||||
}
|
||||
@ -73,6 +73,6 @@ namespace FreeSql.Odbc.Dameng
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ namespace FreeSql.Odbc.Default
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OdbcCommand();
|
||||
}
|
||||
@ -74,6 +74,6 @@ namespace FreeSql.Odbc.Default
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@ namespace FreeSql.Odbc.KingbaseES
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OdbcCommand();
|
||||
}
|
||||
@ -73,6 +73,6 @@ namespace FreeSql.Odbc.KingbaseES
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace FreeSql.Odbc.MySql
|
||||
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OdbcCommand();
|
||||
}
|
||||
@ -73,6 +73,6 @@ namespace FreeSql.Odbc.MySql
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace FreeSql.Odbc.Oracle
|
||||
//if (param is string) return string.Concat('N', nparms[a]);
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OdbcCommand();
|
||||
}
|
||||
@ -73,6 +73,6 @@ namespace FreeSql.Odbc.Oracle
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ namespace FreeSql.Odbc.PostgreSQL
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OdbcCommand();
|
||||
}
|
||||
@ -74,6 +74,6 @@ namespace FreeSql.Odbc.PostgreSQL
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
@ -75,7 +75,7 @@ namespace FreeSql.Odbc.SqlServer
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OdbcCommand();
|
||||
}
|
||||
@ -87,6 +87,6 @@ namespace FreeSql.Odbc.SqlServer
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@ namespace FreeSql.Oracle
|
||||
//if (param is string) return string.Concat('N', nparms[a]);
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
var cmd = new OracleCommand();
|
||||
cmd.BindByName = true;
|
||||
@ -75,6 +75,6 @@ namespace FreeSql.Oracle
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace FreeSql.PostgreSQL
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new NpgsqlCommand();
|
||||
}
|
||||
@ -91,6 +91,6 @@ namespace FreeSql.PostgreSQL
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
@ -62,7 +62,7 @@ namespace FreeSql.ShenTong
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
}
|
||||
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new OscarCommand();
|
||||
}
|
||||
@ -74,6 +74,6 @@ namespace FreeSql.ShenTong
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
@ -83,7 +83,7 @@ namespace FreeSql.SqlServer
|
||||
}
|
||||
|
||||
DbConnection _CreateCommandConnection;
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
if (_CreateCommandConnection != null)
|
||||
{
|
||||
@ -101,6 +101,6 @@ namespace FreeSql.SqlServer
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
@ -82,6 +82,8 @@ public static partial class FreeSqlSqlServerGlobalExtensions
|
||||
if (batchSize.HasValue) bulkCopy.BatchSize = batchSize.Value;
|
||||
if (bulkCopyTimeout.HasValue) bulkCopy.BulkCopyTimeout = bulkCopyTimeout.Value;
|
||||
bulkCopy.DestinationTableName = dt.TableName;
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
bulkCopy.ColumnMappings.Add(dt.Columns[i].ColumnName, dt.Columns[i].ColumnName);
|
||||
bulkCopy.WriteToServer(dt);
|
||||
};
|
||||
|
||||
@ -157,6 +159,8 @@ public static partial class FreeSqlSqlServerGlobalExtensions
|
||||
if (batchSize.HasValue) bulkCopy.BatchSize = batchSize.Value;
|
||||
if (bulkCopyTimeout.HasValue) bulkCopy.BulkCopyTimeout = bulkCopyTimeout.Value;
|
||||
bulkCopy.DestinationTableName = dt.TableName;
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
bulkCopy.ColumnMappings.Add(dt.Columns[i].ColumnName, dt.Columns[i].ColumnName);
|
||||
return bulkCopy.WriteToServerAsync(dt);
|
||||
};
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace FreeSql.Sqlite
|
||||
}
|
||||
|
||||
DbConnection _CreateCommandConnection;
|
||||
protected override DbCommand CreateCommand()
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
if (_CreateCommandConnection != null)
|
||||
{
|
||||
@ -82,6 +82,6 @@ namespace FreeSql.Sqlite
|
||||
else pool.Return(conn);
|
||||
}
|
||||
|
||||
protected override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) => _util.GetDbParamtersByObject(sql, obj);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user