mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 增加 pgsql numeric -> BigInteger 映射;#1100
This commit is contained in:
parent
7ed2d87b8d
commit
fc32710421
@ -14,10 +14,12 @@ using System.Data.SQLite;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Numerics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -158,8 +160,11 @@ namespace base_entity
|
|||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public DateTime CreateTime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
}
|
}
|
||||||
|
class tuint256tb_01
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public BigInteger Number { get; set; }
|
||||||
|
}
|
||||||
class CommandTimeoutCascade : IDisposable
|
class CommandTimeoutCascade : IDisposable
|
||||||
{
|
{
|
||||||
public static AsyncLocal<int> _asyncLocalTimeout = new AsyncLocal<int>();
|
public static AsyncLocal<int> _asyncLocalTimeout = new AsyncLocal<int>();
|
||||||
@ -177,7 +182,7 @@ namespace base_entity
|
|||||||
//.UseSlave("data source=test1.db", "data source=test2.db", "data source=test3.db", "data source=test4.db")
|
//.UseSlave("data source=test1.db", "data source=test2.db", "data source=test3.db", "data source=test4.db")
|
||||||
//.UseSlaveWeight(10, 1, 1, 5)
|
//.UseSlaveWeight(10, 1, 1, 5)
|
||||||
|
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5")
|
//.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5")
|
||||||
|
|
||||||
|
|
||||||
@ -185,8 +190,8 @@ namespace base_entity
|
|||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
|
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
|
.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
|
||||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower)
|
.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower)
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=2")
|
//.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=2")
|
||||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||||
@ -211,6 +216,56 @@ namespace base_entity
|
|||||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
if (fsql.Ado.DataType == DataType.PostgreSQL)
|
||||||
|
{
|
||||||
|
fsql.CodeFirst.IsNoneCommandParameter = false;
|
||||||
|
fsql.Aop.AuditDataReader += (_, e) =>
|
||||||
|
{
|
||||||
|
var dbtype = e.DataReader.GetDataTypeName(e.Index);
|
||||||
|
var m = Regex.Match(dbtype, @"numeric\((\d+)\)", RegexOptions.IgnoreCase);
|
||||||
|
if (m.Success && int.Parse(m.Groups[1].Value) > 19)
|
||||||
|
e.Value = e.DataReader.GetFieldValue<BigInteger>(e.Index); //否则会报溢出错误
|
||||||
|
};
|
||||||
|
|
||||||
|
var num = BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003956564819968");
|
||||||
|
fsql.Delete<tuint256tb_01>().Where("1=1").ExecuteAffrows();
|
||||||
|
if (1 != fsql.Insert(new tuint256tb_01()).ExecuteAffrows()) throw new Exception("not equal");
|
||||||
|
var find = fsql.Select<tuint256tb_01>().ToList();
|
||||||
|
if (find.Count != 1) throw new Exception("not single");
|
||||||
|
if ("0" != find[0].Number.ToString()) throw new Exception("not equal");
|
||||||
|
var item = new tuint256tb_01 { Number = num };
|
||||||
|
if (1 != fsql.Insert(item).ExecuteAffrows()) throw new Exception("not equal");
|
||||||
|
find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList();
|
||||||
|
if (find.Count != 1) throw new Exception("not single");
|
||||||
|
if (item.Number != find[0].Number) throw new Exception("not equal");
|
||||||
|
num = num - 1;
|
||||||
|
item.Number = num;
|
||||||
|
if (1 != fsql.Update<tuint256tb_01>().SetSource(item).ExecuteAffrows()) throw new Exception("not equal");
|
||||||
|
find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList();
|
||||||
|
if (find.Count != 1) throw new Exception("not single");
|
||||||
|
if ("57896044618658097711785492504343953926634992332820282019728792003956564819967" != find[0].Number.ToString()) throw new Exception("not equal");
|
||||||
|
|
||||||
|
num = BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003956564819968");
|
||||||
|
fsql.Delete<tuint256tb_01>().Where("1=1").ExecuteAffrows();
|
||||||
|
if (1 != fsql.Insert(new tuint256tb_01()).NoneParameter().ExecuteAffrows()) throw new Exception("not equal");
|
||||||
|
find = fsql.Select<tuint256tb_01>().ToList();
|
||||||
|
if (find.Count != 1) throw new Exception("not single");
|
||||||
|
if ("0" != find[0].Number.ToString()) throw new Exception("not equal");
|
||||||
|
item = new tuint256tb_01 { Number = num };
|
||||||
|
if (1 != fsql.Insert(item).NoneParameter().ExecuteAffrows()) throw new Exception("not equal");
|
||||||
|
find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList();
|
||||||
|
if (find.Count != 1) throw new Exception("not single");
|
||||||
|
if (item.Number != find[0].Number) throw new Exception("not equal");
|
||||||
|
num = num - 1;
|
||||||
|
item.Number = num;
|
||||||
|
if (1 != fsql.Update<tuint256tb_01>().NoneParameter().SetSource(item).ExecuteAffrows()) throw new Exception("not equal");
|
||||||
|
find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList();
|
||||||
|
if (find.Count != 1) throw new Exception("not single");
|
||||||
|
if ("57896044618658097711785492504343953926634992332820282019728792003956564819967" != find[0].Number.ToString()) throw new Exception("not equal");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fsql.Aop.CommandBefore += (_, e) =>
|
fsql.Aop.CommandBefore += (_, e) =>
|
||||||
{
|
{
|
||||||
if (CommandTimeoutCascade._asyncLocalTimeout.Value > 0)
|
if (CommandTimeoutCascade._asyncLocalTimeout.Value > 0)
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
<PackageReference Include="Npgsql.NetTopologySuite" Version="6.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<RootNamespace>FreeSql.Tests.VB</RootNamespace>
|
<RootNamespace>FreeSql.Tests.VB</RootNamespace>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net5.0;netcoreapp3.1;</TargetFrameworks>
|
<TargetFrameworks>net6.0;netcoreapp3.1;</TargetFrameworks>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@ -12,6 +11,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Npgsql.NetTopologySuite" Version="6.0.4" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using NetTopologySuite.Geometries;
|
using NetTopologySuite.Geometries;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@ -11,7 +11,9 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
|
namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
|
||||||
@ -19,11 +21,65 @@ namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
|
|||||||
public class PostgreSQLCodeFirstTest
|
public class PostgreSQLCodeFirstTest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void UInt256Crud2()
|
||||||
|
{
|
||||||
|
var fsql = g.pgsql;
|
||||||
|
fsql.Aop.AuditDataReader += (_, e) =>
|
||||||
|
{
|
||||||
|
var dbtype = e.DataReader.GetDataTypeName(e.Index);
|
||||||
|
var m = Regex.Match(dbtype, @"numeric\((\d+)\)", RegexOptions.IgnoreCase);
|
||||||
|
if (m.Success && int.Parse(m.Groups[1].Value) > 19)
|
||||||
|
e.Value = e.DataReader.GetFieldValue<BigInteger>(e.Index); //否则会报溢出错误
|
||||||
|
};
|
||||||
|
|
||||||
|
var num = BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003956564819968");
|
||||||
|
fsql.Delete<tuint256tb_01>().Where("1=1").ExecuteAffrows();
|
||||||
|
Assert.Equal(1, fsql.Insert(new tuint256tb_01()).ExecuteAffrows());
|
||||||
|
var find = fsql.Select<tuint256tb_01>().ToList();
|
||||||
|
Assert.Single(find);
|
||||||
|
Assert.Equal("0", find[0].Number.ToString());
|
||||||
|
var item = new tuint256tb_01 { Number = num };
|
||||||
|
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
|
||||||
|
find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList();
|
||||||
|
Assert.Single(find);
|
||||||
|
Assert.Equal(item.Number, find[0].Number);
|
||||||
|
num = num - 1;
|
||||||
|
item.Number = num;
|
||||||
|
Assert.Equal(1, fsql.Update<tuint256tb_01>().SetSource(item).ExecuteAffrows());
|
||||||
|
find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList();
|
||||||
|
Assert.Single(find);
|
||||||
|
Assert.Equal("57896044618658097711785492504343953926634992332820282019728792003956564819967", find[0].Number.ToString());
|
||||||
|
|
||||||
|
num = BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003956564819968");
|
||||||
|
fsql.Delete<tuint256tb_01>().Where("1=1").ExecuteAffrows();
|
||||||
|
Assert.Equal(1, fsql.Insert(new tuint256tb_01()).NoneParameter().ExecuteAffrows());
|
||||||
|
find = fsql.Select<tuint256tb_01>().ToList();
|
||||||
|
Assert.Single(find);
|
||||||
|
Assert.Equal("0", find[0].Number.ToString());
|
||||||
|
item = new tuint256tb_01 { Number = num };
|
||||||
|
Assert.Equal(1, fsql.Insert(item).NoneParameter().ExecuteAffrows());
|
||||||
|
find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList();
|
||||||
|
Assert.Single(find);
|
||||||
|
Assert.Equal(item.Number, find[0].Number);
|
||||||
|
num = num - 1;
|
||||||
|
item.Number = num;
|
||||||
|
Assert.Equal(1, fsql.Update<tuint256tb_01>().NoneParameter().SetSource(item).ExecuteAffrows());
|
||||||
|
find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList();
|
||||||
|
Assert.Single(find);
|
||||||
|
Assert.Equal("57896044618658097711785492504343953926634992332820282019728792003956564819967", find[0].Number.ToString());
|
||||||
|
}
|
||||||
|
class tuint256tb_01
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public BigInteger Number { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetComparisonDDLStatements()
|
public void GetComparisonDDLStatements()
|
||||||
{
|
{
|
||||||
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
|
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
|
||||||
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
|
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
|
||||||
g.pgsql.Select<TableAllType>();
|
g.pgsql.Select<TableAllType>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,8 +99,8 @@ namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
|
|||||||
|
|
||||||
var item2 = new TableAllType
|
var item2 = new TableAllType
|
||||||
{
|
{
|
||||||
testFieldBitArray = new BitArray(Encoding.UTF8.GetBytes("我是")),
|
testFieldBitArray = new BitArray(Encoding.UTF8.GetBytes("我是")),
|
||||||
testFieldBitArrayArray = new[] { new BitArray(Encoding.UTF8.GetBytes("中国")), new BitArray(Encoding.UTF8.GetBytes("公民")) },
|
testFieldBitArrayArray = new[] { new BitArray(Encoding.UTF8.GetBytes("中国")), new BitArray(Encoding.UTF8.GetBytes("公民")) },
|
||||||
testFieldBool = true,
|
testFieldBool = true,
|
||||||
testFieldBoolArray = new[] { true, true, false, false },
|
testFieldBoolArray = new[] { true, true, false, false },
|
||||||
testFieldBoolArrayNullable = new bool?[] { true, true, null, false, false },
|
testFieldBoolArrayNullable = new bool?[] { true, true, null, false, false },
|
||||||
@ -53,8 +109,8 @@ namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
|
|||||||
testFieldByteArray = new byte[] { 0, 1, 2, 3, 4, 5, 6 },
|
testFieldByteArray = new byte[] { 0, 1, 2, 3, 4, 5, 6 },
|
||||||
testFieldByteArrayNullable = new byte?[] { 0, 1, 2, 3, null, 4, 5, 6 },
|
testFieldByteArrayNullable = new byte?[] { 0, 1, 2, 3, null, 4, 5, 6 },
|
||||||
testFieldByteNullable = byte.MinValue,
|
testFieldByteNullable = byte.MinValue,
|
||||||
testFieldBytes = Encoding.UTF8.GetBytes("我是中国人"),
|
testFieldBytes = Encoding.UTF8.GetBytes("我是中国人"),
|
||||||
testFieldBytesArray = new[] { Encoding.UTF8.GetBytes("我是中国人"), Encoding.UTF8.GetBytes("我是中国人") },
|
testFieldBytesArray = new[] { Encoding.UTF8.GetBytes("我是中国人"), Encoding.UTF8.GetBytes("我是中国人") },
|
||||||
testFieldCidr = (IPAddress.Parse("10.0.0.0"), 8),
|
testFieldCidr = (IPAddress.Parse("10.0.0.0"), 8),
|
||||||
testFieldCidrArray = new[] { (IPAddress.Parse("10.0.0.0"), 8), (IPAddress.Parse("192.168.0.0"), 16) },
|
testFieldCidrArray = new[] { (IPAddress.Parse("10.0.0.0"), 8), (IPAddress.Parse("192.168.0.0"), 16) },
|
||||||
testFieldCidrArrayNullable = new (IPAddress, int)?[] { (IPAddress.Parse("10.0.0.0"), 8), null, (IPAddress.Parse("192.168.0.0"), 16) },
|
testFieldCidrArrayNullable = new (IPAddress, int)?[] { (IPAddress.Parse("10.0.0.0"), 8), null, (IPAddress.Parse("192.168.0.0"), 16) },
|
||||||
@ -229,9 +285,9 @@ namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
|
|||||||
testFieldShortArray = new short[] { 1, 2, 3, 4, 5 },
|
testFieldShortArray = new short[] { 1, 2, 3, 4, 5 },
|
||||||
testFieldShortArrayNullable = new short?[] { 1, 2, 3, null, 4, 5 },
|
testFieldShortArrayNullable = new short?[] { 1, 2, 3, null, 4, 5 },
|
||||||
testFieldShortNullable = short.MinValue,
|
testFieldShortNullable = short.MinValue,
|
||||||
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
|
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
|
||||||
testFieldChar = 'X',
|
testFieldChar = 'X',
|
||||||
testFieldStringArray = new[] { "我是中国人String1", "我是中国人String2", null, "我是中国人String3" },
|
testFieldStringArray = new[] { "我是中国人String1", "我是中国人String2", null, "我是中国人String3" },
|
||||||
testFieldTimeSpan = TimeSpan.FromDays(1),
|
testFieldTimeSpan = TimeSpan.FromDays(1),
|
||||||
testFieldTimeSpanArray = new[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60) },
|
testFieldTimeSpanArray = new[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60) },
|
||||||
testFieldTimeSpanArrayNullable = new TimeSpan?[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), null, TimeSpan.FromSeconds(60) },
|
testFieldTimeSpanArrayNullable = new TimeSpan?[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), null, TimeSpan.FromSeconds(60) },
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.Internal;
|
||||||
using FreeSql;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using FreeSql.Internal;
|
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace FreeSql.ExpressionTree
|
namespace FreeSql.ExpressionTree
|
||||||
{
|
{
|
||||||
|
@ -1,23 +1,10 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql;
|
||||||
using FreeSql;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using kwlib;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using FreeSql.Internal;
|
using FreeSql.Internal;
|
||||||
using FreeSql.Internal.CommonProvider;
|
using FreeSql.Internal.CommonProvider;
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace FreeSql.InternalTests
|
namespace FreeSql.InternalTests
|
||||||
{
|
{
|
||||||
|
@ -1,21 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using Xunit;
|
||||||
using FreeSql;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using kwlib;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests.Issues
|
namespace FreeSql.Tests.Issues
|
||||||
{
|
{
|
||||||
|
@ -1,22 +1,8 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using FreeSql;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using kwlib;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests.Issues
|
namespace FreeSql.Tests.Issues
|
||||||
{
|
{
|
||||||
|
@ -1,21 +1,7 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using FreeSql;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Data.SqlClient;
|
using Xunit;
|
||||||
using kwlib;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests.Issues
|
namespace FreeSql.Tests.Issues
|
||||||
{
|
{
|
||||||
|
@ -1,22 +1,5 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using System.Linq.Expressions;
|
||||||
using FreeSql;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using kwlib;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using FreeSql.Extensions.Linq;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests.Linq
|
namespace FreeSql.Tests.Linq
|
||||||
{
|
{
|
||||||
|
@ -1,21 +1,7 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using FreeSql;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Xunit;
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using kwlib;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests.Linq
|
namespace FreeSql.Tests.Linq
|
||||||
{
|
{
|
||||||
|
@ -1,21 +1,9 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql;
|
||||||
using FreeSql;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Xunit;
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using kwlib;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests.Linq
|
namespace FreeSql.Tests.Linq
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
using Npgsql.LegacyPostgis;
|
using Npgsql.LegacyPostgis;
|
||||||
@ -11,6 +10,7 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@ -18,12 +18,13 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
{
|
{
|
||||||
public class PostgreSQLCodeFirstTest
|
public class PostgreSQLCodeFirstTest
|
||||||
{
|
{
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void InsertUpdateParameter()
|
public void InsertUpdateParameter()
|
||||||
{
|
{
|
||||||
var fsql = g.pgsql;
|
var fsql = g.pgsql;
|
||||||
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
|
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
|
||||||
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
|
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
|
||||||
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
|
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
|
||||||
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
|
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
|
||||||
Assert.NotNull(find);
|
Assert.NotNull(find);
|
||||||
@ -91,7 +92,7 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Blob()
|
public void Blob()
|
||||||
{
|
{
|
||||||
var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "我是中国人"));
|
var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "我是中国人"));
|
||||||
var data1 = Encoding.UTF8.GetBytes(str1);
|
var data1 = Encoding.UTF8.GetBytes(str1);
|
||||||
|
|
||||||
var item1 = new TS_BLB01 { Data = data1 };
|
var item1 = new TS_BLB01 { Data = data1 };
|
||||||
@ -137,57 +138,57 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void 中文表_字段()
|
public void 中文表_字段()
|
||||||
{
|
{
|
||||||
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<测试中文表>();
|
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<测试中文表>();
|
||||||
g.pgsql.CodeFirst.SyncStructure<测试中文表>();
|
g.pgsql.CodeFirst.SyncStructure<测试中文表>();
|
||||||
|
|
||||||
var item = new 测试中文表
|
var item = new 测试中文表
|
||||||
{
|
{
|
||||||
标题 = "测试标题",
|
标题 = "测试标题",
|
||||||
创建时间 = DateTime.Now
|
创建时间 = DateTime.Now
|
||||||
};
|
};
|
||||||
Assert.Equal(1, g.pgsql.Insert<测试中文表>().AppendData(item).ExecuteAffrows());
|
Assert.Equal(1, g.pgsql.Insert<测试中文表>().AppendData(item).ExecuteAffrows());
|
||||||
Assert.NotEqual(Guid.Empty, item.编号);
|
Assert.NotEqual(Guid.Empty, item.编号);
|
||||||
var item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
var item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
item.标题 = "测试标题更新";
|
item.标题 = "测试标题更新";
|
||||||
Assert.Equal(1, g.pgsql.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
Assert.Equal(1, g.pgsql.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||||
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
item.标题 = "测试标题更新_repo";
|
item.标题 = "测试标题更新_repo";
|
||||||
var repo = g.pgsql.GetRepository<测试中文表>();
|
var repo = g.pgsql.GetRepository<测试中文表>();
|
||||||
Assert.Equal(1, repo.Update(item));
|
Assert.Equal(1, repo.Update(item));
|
||||||
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
|
|
||||||
item.标题 = "测试标题更新_repo22";
|
item.标题 = "测试标题更新_repo22";
|
||||||
Assert.Equal(1, repo.Update(item));
|
Assert.Equal(1, repo.Update(item));
|
||||||
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
item2 = g.pgsql.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||||
Assert.NotNull(item2);
|
Assert.NotNull(item2);
|
||||||
Assert.Equal(item.编号, item2.编号);
|
Assert.Equal(item.编号, item2.编号);
|
||||||
Assert.Equal(item.标题, item2.标题);
|
Assert.Equal(item.标题, item2.标题);
|
||||||
}
|
}
|
||||||
class 测试中文表
|
class 测试中文表
|
||||||
{
|
{
|
||||||
[Column(IsPrimary = true)]
|
[Column(IsPrimary = true)]
|
||||||
public Guid 编号 { get; set; }
|
public Guid 编号 { get; set; }
|
||||||
|
|
||||||
public string 标题 { get; set; }
|
public string 标题 { get; set; }
|
||||||
|
|
||||||
[Column(ServerTime = DateTimeKind.Local, CanUpdate = false)]
|
[Column(ServerTime = DateTimeKind.Local, CanUpdate = false)]
|
||||||
public DateTime 创建时间 { get; set; }
|
public DateTime 创建时间 { get; set; }
|
||||||
|
|
||||||
[Column(ServerTime = DateTimeKind.Local)]
|
[Column(ServerTime = DateTimeKind.Local)]
|
||||||
public DateTime 更新时间 { get; set; }
|
public DateTime 更新时间 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -215,7 +216,7 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
public void AddField()
|
public void AddField()
|
||||||
{
|
{
|
||||||
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<TopicAddField>();
|
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<TopicAddField>();
|
||||||
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
|
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
|
||||||
g.pgsql.Select<TopicAddField>();
|
g.pgsql.Select<TopicAddField>();
|
||||||
var id = g.pgsql.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteIdentity();
|
var id = g.pgsql.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteIdentity();
|
||||||
}
|
}
|
||||||
@ -259,8 +260,6 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void CurdAllField()
|
public void CurdAllField()
|
||||||
{
|
{
|
||||||
NpgsqlConnection.GlobalTypeMapper.UseLegacyPostgis();
|
|
||||||
|
|
||||||
var sql1 = select.Where(a => a.testFieldIntArray.Contains(1)).ToSql();
|
var sql1 = select.Where(a => a.testFieldIntArray.Contains(1)).ToSql();
|
||||||
var sql2 = select.Where(a => a.testFieldIntArray.Contains(1)).ToSql();
|
var sql2 = select.Where(a => a.testFieldIntArray.Contains(1)).ToSql();
|
||||||
|
|
||||||
@ -271,8 +270,8 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
|
|
||||||
var item2 = new TableAllType
|
var item2 = new TableAllType
|
||||||
{
|
{
|
||||||
testFieldBitArray = new BitArray(Encoding.UTF8.GetBytes("我是")),
|
testFieldBitArray = new BitArray(Encoding.UTF8.GetBytes("我是")),
|
||||||
testFieldBitArrayArray = new[] { new BitArray(Encoding.UTF8.GetBytes("中国")), new BitArray(Encoding.UTF8.GetBytes("公民")) },
|
testFieldBitArrayArray = new[] { new BitArray(Encoding.UTF8.GetBytes("中国")), new BitArray(Encoding.UTF8.GetBytes("公民")) },
|
||||||
testFieldBool = true,
|
testFieldBool = true,
|
||||||
testFieldBoolArray = new[] { true, true, false, false },
|
testFieldBoolArray = new[] { true, true, false, false },
|
||||||
testFieldBoolArrayNullable = new bool?[] { true, true, null, false, false },
|
testFieldBoolArrayNullable = new bool?[] { true, true, null, false, false },
|
||||||
@ -281,8 +280,8 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
testFieldByteArray = new byte[] { 0, 1, 2, 3, 4, 5, 6 },
|
testFieldByteArray = new byte[] { 0, 1, 2, 3, 4, 5, 6 },
|
||||||
testFieldByteArrayNullable = new byte?[] { 0, 1, 2, 3, null, 4, 5, 6 },
|
testFieldByteArrayNullable = new byte?[] { 0, 1, 2, 3, null, 4, 5, 6 },
|
||||||
testFieldByteNullable = byte.MinValue,
|
testFieldByteNullable = byte.MinValue,
|
||||||
testFieldBytes = Encoding.UTF8.GetBytes("我是中国人"),
|
testFieldBytes = Encoding.UTF8.GetBytes("我是中国人"),
|
||||||
testFieldBytesArray = new[] { Encoding.UTF8.GetBytes("我是中国人"), Encoding.UTF8.GetBytes("我是中国人") },
|
testFieldBytesArray = new[] { Encoding.UTF8.GetBytes("我是中国人"), Encoding.UTF8.GetBytes("我是中国人") },
|
||||||
testFieldCidr = (IPAddress.Parse("10.0.0.0"), 8),
|
testFieldCidr = (IPAddress.Parse("10.0.0.0"), 8),
|
||||||
testFieldCidrArray = new[] { (IPAddress.Parse("10.0.0.0"), 8), (IPAddress.Parse("192.168.0.0"), 16) },
|
testFieldCidrArray = new[] { (IPAddress.Parse("10.0.0.0"), 8), (IPAddress.Parse("192.168.0.0"), 16) },
|
||||||
testFieldCidrArrayNullable = new (IPAddress, int)?[] { (IPAddress.Parse("10.0.0.0"), 8), null, (IPAddress.Parse("192.168.0.0"), 16) },
|
testFieldCidrArrayNullable = new (IPAddress, int)?[] { (IPAddress.Parse("10.0.0.0"), 8), null, (IPAddress.Parse("192.168.0.0"), 16) },
|
||||||
@ -457,9 +456,9 @@ namespace FreeSql.Tests.PostgreSQL
|
|||||||
testFieldShortArray = new short[] { 1, 2, 3, 4, 5 },
|
testFieldShortArray = new short[] { 1, 2, 3, 4, 5 },
|
||||||
testFieldShortArrayNullable = new short?[] { 1, 2, 3, null, 4, 5 },
|
testFieldShortArrayNullable = new short?[] { 1, 2, 3, null, 4, 5 },
|
||||||
testFieldShortNullable = short.MinValue,
|
testFieldShortNullable = short.MinValue,
|
||||||
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
|
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
|
||||||
testFieldChar = 'X',
|
testFieldChar = 'X',
|
||||||
testFieldStringArray = new[] { "我是中国人String1", "我是中国人String2", null, "我是中国人String3" },
|
testFieldStringArray = new[] { "我是中国人String1", "我是中国人String2", null, "我是中国人String3" },
|
||||||
testFieldTimeSpan = TimeSpan.FromDays(1),
|
testFieldTimeSpan = TimeSpan.FromDays(1),
|
||||||
testFieldTimeSpanArray = new[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60) },
|
testFieldTimeSpanArray = new[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60) },
|
||||||
testFieldTimeSpanArrayNullable = new TimeSpan?[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), null, TimeSpan.FromSeconds(60) },
|
testFieldTimeSpanArrayNullable = new TimeSpan?[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), null, TimeSpan.FromSeconds(60) },
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Npgsql;
|
|
||||||
using Npgsql.LegacyPostgis;
|
using Npgsql.LegacyPostgis;
|
||||||
using NpgsqlTypes;
|
using NpgsqlTypes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
@ -19,11 +17,6 @@ namespace FreeSql.Tests.PostgreSQLExpression
|
|||||||
|
|
||||||
ISelect<TableAllType> select => g.pgsql.Select<TableAllType>();
|
ISelect<TableAllType> select => g.pgsql.Select<TableAllType>();
|
||||||
|
|
||||||
public OtherTest()
|
|
||||||
{
|
|
||||||
NpgsqlConnection.GlobalTypeMapper.UseLegacyPostgis();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Div()
|
public void Div()
|
||||||
{
|
{
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using FreeSql;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
using Zeus;
|
using Zeus;
|
||||||
using Zeus.Domain.Enum;
|
using Zeus.Domain.Enum;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests
|
namespace FreeSql.Tests
|
||||||
{
|
{
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql;
|
||||||
using FreeSql;
|
using FreeSql.DataAnnotations;
|
||||||
|
using kwlib;
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Data.SqlClient;
|
using Xunit;
|
||||||
using kwlib;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests
|
namespace FreeSql.Tests
|
||||||
{
|
{
|
||||||
|
@ -1,25 +1,13 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql;
|
||||||
using FreeSql;
|
using FreeSql.DataAnnotations;
|
||||||
|
using kwlib;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Xunit;
|
|
||||||
using System.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NpgsqlTypes;
|
|
||||||
using Npgsql.LegacyPostgis;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using kwlib;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Newtonsoft.Json;
|
using System.Threading;
|
||||||
using System.Net.NetworkInformation;
|
using Xunit;
|
||||||
using System.Net;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace FreeSql.Tests
|
namespace FreeSql.Tests
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,7 @@ using System.Data;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
{ typeof(bool).FullName, CsToDb.New(NpgsqlDbType.Boolean, "bool","bool NOT NULL", null, false, false) },{ typeof(bool?).FullName, CsToDb.New(NpgsqlDbType.Boolean, "bool","bool", null, true, null) },
|
{ typeof(bool).FullName, CsToDb.New(NpgsqlDbType.Boolean, "bool","bool NOT NULL", null, false, false) },{ typeof(bool?).FullName, CsToDb.New(NpgsqlDbType.Boolean, "bool","bool", null, true, null) },
|
||||||
{ typeof(Byte[]).FullName, CsToDb.New(NpgsqlDbType.Bytea, "bytea", "bytea", false, null, new byte[0]) },
|
{ typeof(Byte[]).FullName, CsToDb.New(NpgsqlDbType.Bytea, "bytea", "bytea", false, null, new byte[0]) },
|
||||||
{ typeof(BitArray).FullName, CsToDb.New(NpgsqlDbType.Varbit, "varbit", "varbit(64)", false, null, new BitArray(new byte[64])) },
|
{ typeof(BitArray).FullName, CsToDb.New(NpgsqlDbType.Varbit, "varbit", "varbit(64)", false, null, new BitArray(new byte[64])) },
|
||||||
|
{ typeof(BigInteger).FullName, CsToDb.New(NpgsqlDbType.Numeric, "numeric", "numeric(78,0) NOT NULL", false, false, 0) },{ typeof(BigInteger?).FullName, CsToDb.New(NpgsqlDbType.Numeric, "numeric", "numeric(78,0)", false, true, null) },
|
||||||
|
|
||||||
{ typeof(NpgsqlPoint).FullName, CsToDb.New(NpgsqlDbType.Point, "point", "point NOT NULL", false, false, new NpgsqlPoint(0, 0)) },{ typeof(NpgsqlPoint?).FullName, CsToDb.New(NpgsqlDbType.Point, "point", "point", false, true, null) },
|
{ typeof(NpgsqlPoint).FullName, CsToDb.New(NpgsqlDbType.Point, "point", "point NOT NULL", false, false, new NpgsqlPoint(0, 0)) },{ typeof(NpgsqlPoint?).FullName, CsToDb.New(NpgsqlDbType.Point, "point", "point", false, true, null) },
|
||||||
{ typeof(NpgsqlLine).FullName, CsToDb.New(NpgsqlDbType.Line, "line", "line NOT NULL", false, false, new NpgsqlLine(0, 0, 1)) },{ typeof(NpgsqlLine?).FullName, CsToDb.New(NpgsqlDbType.Line, "line", "line", false, true, null) },
|
{ typeof(NpgsqlLine).FullName, CsToDb.New(NpgsqlDbType.Line, "line", "line NOT NULL", false, false, new NpgsqlLine(0, 0, 1)) },{ typeof(NpgsqlLine?).FullName, CsToDb.New(NpgsqlDbType.Line, "line", "line", false, true, null) },
|
||||||
|
@ -3,12 +3,10 @@ using FreeSql.Internal;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Npgsql.LegacyPostgis;
|
using Npgsql.LegacyPostgis;
|
||||||
using NpgsqlTypes;
|
using NpgsqlTypes;
|
||||||
using FreeSql.Internal.ObjectPool;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
|
@ -12,6 +12,7 @@ using System.Data.Common;
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Numerics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
|
|
||||||
static PostgreSQLProvider()
|
static PostgreSQLProvider()
|
||||||
{
|
{
|
||||||
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(NpgsqlPoint)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(NpgsqlPoint)] = true;
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(NpgsqlLine)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(NpgsqlLine)] = true;
|
||||||
@ -121,6 +123,14 @@ namespace FreeSql.PostgreSQL
|
|||||||
|
|
||||||
this.DbFirst = new PostgreSQLDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
this.DbFirst = new PostgreSQLDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
this.CodeFirst = new PostgreSQLCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
this.CodeFirst = new PostgreSQLCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
|
|
||||||
|
//this.Aop.AuditDataReader += (_, e) =>
|
||||||
|
//{
|
||||||
|
// var dbtype = e.DataReader.GetDataTypeName(e.Index);
|
||||||
|
// var m = Regex.Match(dbtype, @"numeric\((\d+)\)", RegexOptions.IgnoreCase);
|
||||||
|
// if (m.Success && int.Parse(m.Groups[1].Value) > 19)
|
||||||
|
// e.Value = e.DataReader.GetFieldValue<BigInteger>(e.Index);
|
||||||
|
//};
|
||||||
}
|
}
|
||||||
|
|
||||||
~PostgreSQLProvider() => this.Dispose();
|
~PostgreSQLProvider() => this.Dispose();
|
||||||
|
@ -12,6 +12,7 @@ using System.Data.Common;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace FreeSql.PostgreSQL
|
namespace FreeSql.PostgreSQL
|
||||||
@ -45,6 +46,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
{ typeof(byte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(byte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(byte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
|
{ typeof(byte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(byte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(byte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
|
||||||
{ typeof(sbyte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(sbyte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(sbyte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
|
{ typeof(sbyte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(sbyte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(sbyte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
|
||||||
{ typeof(char).FullName, a => string.Concat(a).Replace('\0', ' ').ToCharArray().FirstOrDefault() },
|
{ typeof(char).FullName, a => string.Concat(a).Replace('\0', ' ').ToCharArray().FirstOrDefault() },
|
||||||
|
{ typeof(BigInteger).FullName, a => BigInteger.Parse(string.Concat(a), System.Globalization.NumberStyles.Any) }, { typeof(BigInteger[]).FullName, a => getParamterArrayValue(typeof(BigInteger), a, 0) }, { typeof(BigInteger?[]).FullName, a => getParamterArrayValue(typeof(BigInteger?), a, null) },
|
||||||
|
|
||||||
{ typeof(NpgsqlPath).FullName, a => {
|
{ typeof(NpgsqlPath).FullName, a => {
|
||||||
var path = (NpgsqlPath)a;
|
var path = (NpgsqlPath)a;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user