mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
- 调整 FreeSql.Provider.SqlServer 引用Microsoft.Data.SqlClient #391;
This commit is contained in:
parent
e80f179663
commit
072a8b7cfa
@ -17,6 +17,7 @@
|
|||||||
<PackageReference Include="Dapper" Version="2.0.35" />
|
<PackageReference Include="Dapper" Version="2.0.35" />
|
||||||
<PackageReference Include="IdleBus" Version="1.3.0" />
|
<PackageReference Include="IdleBus" Version="1.3.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
|
||||||
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||||
|
@ -79,7 +79,7 @@ namespace FreeSql.Tests.SqlServer
|
|||||||
var t4 = g.sqlserver.Ado.Query<(int, int, string, string DateTime)>("select * from xxx");
|
var t4 = g.sqlserver.Ado.Query<(int, int, string, string DateTime)>("select * from xxx");
|
||||||
|
|
||||||
var t5 = g.sqlserver.Ado.Query<dynamic>(System.Data.CommandType.Text, "select * from xxx where Id = @Id",
|
var t5 = g.sqlserver.Ado.Query<dynamic>(System.Data.CommandType.Text, "select * from xxx where Id = @Id",
|
||||||
new System.Data.SqlClient.SqlParameter("Id", 1));
|
new Microsoft.Data.SqlClient.SqlParameter("Id", 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -11,7 +11,7 @@ using System.Linq.Expressions;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
using kwlib;
|
using kwlib;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ public class g
|
|||||||
|
|
||||||
static Lazy<IFreeSql> sqlserverLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
|
static Lazy<IFreeSql> sqlserverLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
|
||||||
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3")
|
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3")
|
||||||
|
//.UseConnectionFactory(FreeSql.DataType.SqlServer, () => new Microsoft.Data.SqlClient.SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;"))
|
||||||
//.UseConnectionFactory(FreeSql.DataType.SqlServer, () => new System.Data.SqlClient.SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;"))
|
//.UseConnectionFactory(FreeSql.DataType.SqlServer, () => new System.Data.SqlClient.SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;"))
|
||||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=192.168.164.129;uid=sa;pwd=123456;Initial Catalog=ds_shop;Pooling=true;Max Pool Size=3")
|
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=192.168.164.129;uid=sa;pwd=123456;Initial Catalog=ds_shop;Pooling=true;Max Pool Size=3")
|
||||||
//.UseConnectionFactory(FreeSql.DataType.SqlServer, () => new System.Data.SqlClient.SqlConnection("Data Source=192.168.164.129;uid=sa;pwd=123456;Initial Catalog=ds_shop;Pooling=true;"))
|
//.UseConnectionFactory(FreeSql.DataType.SqlServer, () => new System.Data.SqlClient.SqlConnection("Data Source=192.168.164.129;uid=sa;pwd=123456;Initial Catalog=ds_shop;Pooling=true;"))
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461'">
|
||||||
<PackageReference Include="Npgsql.LegacyPostgis" Version="4.1.3" />
|
<PackageReference Include="Npgsql.LegacyPostgis" Version="4.1.4" />
|
||||||
<PackageReference Include="Npgsql.NetTopologySuite" Version="4.1.3" />
|
<PackageReference Include="Npgsql.NetTopologySuite" Version="4.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net452' or '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net45'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net452' or '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net45'">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net451;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net461;net40</TargetFrameworks>
|
||||||
<Version>1.7.0-preview0722</Version>
|
<Version>1.7.0-preview0722</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>ncc;YeXiangQin</Authors>
|
<Authors>ncc;YeXiangQin</Authors>
|
||||||
@ -25,14 +25,17 @@
|
|||||||
<None Include="../../logo.png" Pack="true" PackagePath="\" />
|
<None Include="../../logo.png" Pack="true" PackagePath="\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net451'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461'">
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461'">
|
||||||
|
<DefineConstants>microsoft</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
|
||||||
<DefineConstants>net40</DefineConstants>
|
<DefineConstants>net40</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -4,7 +4,11 @@ using FreeSql.Internal.ObjectPool;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
|
#if microsoft
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
#else
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
#endif
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -19,7 +23,9 @@ namespace FreeSql.SqlServer
|
|||||||
base._util = util;
|
base._util = util;
|
||||||
if (connectionFactory != null)
|
if (connectionFactory != null)
|
||||||
{
|
{
|
||||||
MasterPool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.SqlServer, connectionFactory);
|
var pool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.Sqlite, connectionFactory);
|
||||||
|
MasterPool = pool;
|
||||||
|
_CreateCommandConnection = pool.TestConnection;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(masterConnectionString))
|
if (!string.IsNullOrEmpty(masterConnectionString))
|
||||||
@ -76,8 +82,15 @@ namespace FreeSql.SqlServer
|
|||||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DbConnection _CreateCommandConnection;
|
||||||
protected override DbCommand CreateCommand()
|
protected override DbCommand CreateCommand()
|
||||||
{
|
{
|
||||||
|
if (_CreateCommandConnection != null)
|
||||||
|
{
|
||||||
|
var cmd = _CreateCommandConnection.CreateCommand();
|
||||||
|
cmd.Connection = null;
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
return new SqlCommand();
|
return new SqlCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,11 @@ using System.Collections.Concurrent;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
|
#if microsoft
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
#else
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
#endif
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -3,7 +3,11 @@ using FreeSql.Internal.Model;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
#if microsoft
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
#else
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
#endif
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public static partial class FreeSqlSqlServerGlobalExtensions
|
public static partial class FreeSqlSqlServerGlobalExtensions
|
||||||
|
@ -4,7 +4,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
|
#if microsoft
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
#else
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
#endif
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@ -44,7 +48,7 @@ namespace FreeSql.SqlServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) =>
|
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) =>
|
||||||
Utils.GetDbParamtersByObject<SqlParameter>(sql, obj, "@", (name, type, value) =>
|
Utils.GetDbParamtersByObject<DbParameter>(sql, obj, "@", (name, type, value) =>
|
||||||
{
|
{
|
||||||
if (value?.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
if (value?.Equals(DateTime.MinValue) == true) value = new DateTime(1970, 1, 1);
|
||||||
var ret = new SqlParameter { ParameterName = $"@{name}", Value = value };
|
var ret = new SqlParameter { ParameterName = $"@{name}", Value = value };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user