mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-22 00:00:57 +08:00
@@ -12,7 +12,7 @@
|
||||
<!--
|
||||
经常出于版本交叉问题,暂时关闭,在每个项目上设置版本号
|
||||
<PropertyGroup>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
</PropertyGroup>
|
||||
-->
|
||||
|
||||
|
||||
@@ -574,39 +574,39 @@ namespace base_entity
|
||||
//.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")
|
||||
//.UseQuoteSqlName(false)
|
||||
|
||||
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")
|
||||
|
||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
|
||||
//.UseAdoConnectionPool(false)
|
||||
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
|
||||
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower)
|
||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
|
||||
//.UseAdoConnectionPool(false)
|
||||
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
|
||||
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=127.0.0.1;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
|
||||
//.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")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||
//.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)
|
||||
|
||||
//.UseConnectionString(FreeSql.DataType.Dameng, "server=127.0.0.1;port=5236;user=2user;password=123456789;database=2user;poolsize=5;")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||
//.UseConnectionString(FreeSql.DataType.Dameng, "server=127.0.0.1;port=5236;user=2user;password=123456789;database=2user;poolsize=5;")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcMySql, "Driver={MySQL ODBC 8.0 Unicode Driver};Server=127.0.0.1;Persist Security Info=False;Trusted_Connection=Yes;UID=root;PWD=root;DATABASE=cccddd_odbc;Charset=utf8;SslMode=none;Max pool size=2")
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcMySql, "Driver={MySQL ODBC 8.0 Unicode Driver};Server=127.0.0.1;Persist Security Info=False;Trusted_Connection=Yes;UID=root;PWD=root;DATABASE=cccddd_odbc;Charset=utf8;SslMode=none;Max pool size=2")
|
||||
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcSqlServer, "Driver={SQL Server};Server=.;Persist Security Info=False;Trusted_Connection=Yes;Integrated Security=True;DATABASE=freesqlTest_odbc;Pooling=true;Max pool size=3")
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcSqlServer, "Driver={SQL Server};Server=.;Persist Security Info=False;Trusted_Connection=Yes;Integrated Security=True;DATABASE=freesqlTest_odbc;Pooling=true;Max pool size=3")
|
||||
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcPostgreSQL, "Driver={PostgreSQL Unicode(x64)};Server=127.0.0.1;Port=5432;UID=postgres;PWD=123456;Database=tedb_odbc;Pooling=true;Maximum Pool Size=2")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower)
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcPostgreSQL, "Driver={PostgreSQL Unicode(x64)};Server=127.0.0.1;Port=5432;UID=postgres;PWD=123456;Database=tedb_odbc;Pooling=true;Maximum Pool Size=2")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToLower)
|
||||
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcOracle, "Driver={Oracle in XE};Server=//127.0.0.1:1521/XE;Persist Security Info=False;Trusted_Connection=Yes;UID=odbc1;PWD=123456")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcOracle, "Driver={Oracle in XE};Server=//127.0.0.1:1521/XE;Persist Security Info=False;Trusted_Connection=Yes;UID=odbc1;PWD=123456")
|
||||
//.UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
|
||||
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcDameng, "Driver={DM8 ODBC DRIVER};Server=127.0.0.1:5236;Persist Security Info=False;Trusted_Connection=Yes;UID=USER1;PWD=123456789")
|
||||
//.UseConnectionString(DataType.QuestDb, "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
|
||||
//.UseConnectionString(FreeSql.DataType.OdbcDameng, "Driver={DM8 ODBC DRIVER};Server=127.0.0.1:5236;Persist Security Info=False;Trusted_Connection=Yes;UID=USER1;PWD=123456789")
|
||||
//.UseConnectionString(DataType.QuestDb, "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
|
||||
|
||||
//.UseConnectionString(DataType.ClickHouse, "DataCompress=False;BufferSize=32768;SocketTimeout=10000;CheckCompressedHash=False;Encrypt=False;Compressor=lz4;Host=192.168.0.121;Port=8125;Database=PersonnelLocation;Username=root;Password=123")
|
||||
//.UseConnectionString(DataType.ClickHouse, "DataCompress=False;BufferSize=32768;SocketTimeout=10000;CheckCompressedHash=False;Encrypt=False;Compressor=lz4;Host=192.168.0.121;Port=8125;Database=PersonnelLocation;Username=root;Password=123")
|
||||
//.UseConnectionFactory(DataType.ClickHouse, () => null)
|
||||
.UseMonitorCommand(cmd =>
|
||||
.UseMonitorCommand(cmd =>
|
||||
{
|
||||
Console.WriteLine(cmd.CommandText + "\r\n");
|
||||
//cmd.CommandText = null; //不执行
|
||||
@@ -619,6 +619,77 @@ namespace base_entity
|
||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||
#endregion
|
||||
|
||||
fsql.CodeFirst.SyncStructure<Account>();
|
||||
|
||||
|
||||
var dbpars = new List<DbParameter>();
|
||||
|
||||
var a1id1 = Guid.NewGuid();
|
||||
var a1id2 = Guid.NewGuid();
|
||||
//fsql.CodeFirst.IsGenerateCommandParameterWithLambda = true;
|
||||
var sql1a0 = fsql.Select<User1>()
|
||||
.WithParameters(dbpars)
|
||||
.Where(a => a.Id == a1id1)
|
||||
.OrderBy(a => a.Id)
|
||||
|
||||
.UnionAll(
|
||||
fsql.Select<User1>()
|
||||
.WithParameters(dbpars)
|
||||
.Where(a => a.Id == a1id2)
|
||||
.OrderByDescending(a => a.Id),
|
||||
|
||||
fsql.Select<User1>()
|
||||
.WithParameters(dbpars)
|
||||
.Where(a => a.Id == a1id2)
|
||||
.OrderByDescending(a => a.Id)
|
||||
)
|
||||
.Where(a => a.Id == a1id1 || a.Id == a1id2)
|
||||
.ToList();
|
||||
var sql1a1 = fsql.Select<User1>()
|
||||
.Where(a => a.Id == a1id1)
|
||||
.UnionAll(
|
||||
fsql.Select<User1>()
|
||||
.Where(a => a.Id == a1id2)
|
||||
)
|
||||
.Where(a => a.Id == a1id1 || a.Id == a1id2)
|
||||
.ToList();
|
||||
var sql1a2 = fsql.Select<User1, UserGroup>()
|
||||
.InnerJoin((a, b) => a.GroupId == b.Id)
|
||||
.Where((a, b) => a.Id == a1id1)
|
||||
.WithTempQuery((a, b) => new { user = a, group = b }) //匿名类型
|
||||
|
||||
.UnionAll(
|
||||
fsql.Select<User1, UserGroup>()
|
||||
.InnerJoin((a, b) => a.GroupId == b.Id)
|
||||
.Where((a, b) => a.Id == a1id2)
|
||||
.WithTempQuery((a, b) => new { user = a, group = b }) //匿名类型
|
||||
)
|
||||
|
||||
.Where(a => a.user.Id == a1id1 || a.user.Id == a1id2)
|
||||
.ToList();
|
||||
|
||||
fsql.Aop.AuditValue += (_, e) =>
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var tt1 = new ProjectItem { ID = 1, MaxQuantity = 0, Code = null, Name = null };
|
||||
var tt2 = new ProjectItem { ID = 1, MaxQuantity = 100, Code = null, Name = null };
|
||||
var repot2 = fsql.GetRepository<ProjectItem>();
|
||||
|
||||
repot2.Attach(tt1);
|
||||
var nt1 = repot2.Update(tt2);
|
||||
|
||||
fsql.Delete<User1>().Where("1=1").ExecuteAffrows();
|
||||
fsql.Insert(new List<User1>
|
||||
{
|
||||
new User1 { Nickname = "nickname11", Username = "username11", Description = "desc11" },
|
||||
new User1 { Nickname = "n2", Username = "u2", Description = "d2" },
|
||||
new User1 { Nickname = "n3", Username = "u3", Description = "d3" },
|
||||
}).ExecuteAffrows();
|
||||
|
||||
var firebirdList01 = fsql.Select<User1>().ToList();
|
||||
|
||||
fsql.UseJsonMap();
|
||||
|
||||
fsql.Select<Table11>().Where(a => a.Options.Value1 == 100 && a.Options.Value2 == "xx").ToList();
|
||||
@@ -711,17 +782,7 @@ namespace base_entity
|
||||
|
||||
fsql.Select<User1>().Where(a => a.Id == new Guid("xxx")).ToList(a => new Guid("zzz"));
|
||||
|
||||
fsql.Aop.AuditValue += (_, e) =>
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var tt1 = new ProjectItem { ID = 1, MaxQuantity = 0, Code = null, Name = null };
|
||||
var tt2 = new ProjectItem { ID = 1, MaxQuantity = 100, Code = null, Name = null };
|
||||
var repot2 = fsql.GetRepository<ProjectItem>();
|
||||
|
||||
repot2.Attach(tt1);
|
||||
var nt1 = repot2.Update(tt2);
|
||||
|
||||
|
||||
var fsql2 = fsql;
|
||||
// 动态构建实体类型,树形结构,引用自身类型
|
||||
@@ -1664,48 +1725,6 @@ var sql11111 = fsql.Select<Class1111>()
|
||||
var sqlskdfj = fsql.Select<object>().AsType(typeof(BBB)).ToSql(a => new CCC());
|
||||
|
||||
|
||||
var dbpars = new List<DbParameter>();
|
||||
|
||||
var a1id1 = Guid.NewGuid();
|
||||
var a1id2 = Guid.NewGuid();
|
||||
//fsql.CodeFirst.IsGenerateCommandParameterWithLambda = true;
|
||||
var sql1a0 = fsql.Select<User1>()
|
||||
.WithParameters(dbpars)
|
||||
.Where(a => a.Id == a1id1)
|
||||
|
||||
.UnionAll(
|
||||
fsql.Select<User1>()
|
||||
.WithParameters(dbpars)
|
||||
.Where(a => a.Id == a1id2),
|
||||
|
||||
fsql.Select<User1>()
|
||||
.WithParameters(dbpars)
|
||||
.Where(a => a.Id == a1id2)
|
||||
)
|
||||
.Where(a => a.Id == a1id1 || a.Id == a1id2)
|
||||
.ToSql();
|
||||
var sql1a1 = fsql.Select<User1>()
|
||||
.Where(a => a.Id == a1id1)
|
||||
.UnionAll(
|
||||
fsql.Select<User1>()
|
||||
.Where(a => a.Id == a1id2)
|
||||
)
|
||||
.Where(a => a.Id == a1id1 || a.Id == a1id2)
|
||||
.ToSql();
|
||||
var sql1a2 = fsql.Select<User1, UserGroup>()
|
||||
.InnerJoin((a, b) => a.GroupId == b.Id)
|
||||
.Where((a, b) => a.Id == a1id1)
|
||||
.WithTempQuery((a, b) => new { user = a, group = b }) //匿名类型
|
||||
|
||||
.UnionAll(
|
||||
fsql.Select<User1, UserGroup>()
|
||||
.InnerJoin((a, b) => a.GroupId == b.Id)
|
||||
.Where((a, b) => a.Id == a1id2)
|
||||
.WithTempQuery((a, b) => new { user = a, group = b }) //匿名类型
|
||||
)
|
||||
|
||||
.Where(a => a.user.Id == a1id1 || a.user.Id == a1id2)
|
||||
.ToSql();
|
||||
|
||||
|
||||
var ddlsql01 = fsql.CodeFirst.GetComparisonDDLStatements<StringNulable>();
|
||||
@@ -3293,6 +3312,9 @@ public partial class ProjectItem
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 账户
|
||||
/// </summary>
|
||||
[Table(Name = "t_account")]
|
||||
public class Account
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Confluent.Kafka" Version="2.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Npgsql.NetTopologySuite" Version="6.0.4" />
|
||||
<PackageReference Include="MessagePack" Version="2.4.35" />
|
||||
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.5" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -331,6 +331,11 @@
|
||||
名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Account">
|
||||
<summary>
|
||||
账户
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:EMSServerModel.Model.Role">
|
||||
<summary>
|
||||
角色表
|
||||
|
||||
@@ -226,6 +226,16 @@ namespace FreeSql
|
||||
return affrows;
|
||||
}
|
||||
|
||||
async public virtual Task SaveManyAsync(TEntity entity, string propertyName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var tracking = new AggregateRootTrackingChangeInfo();
|
||||
var stateKey = Orm.GetEntityKeyString(EntityType, entity, false);
|
||||
if (_states.TryGetValue(stateKey, out var state) == false) throw new Exception($"AggregateRootRepository 使用仓储对象查询后,才可以保存数据 {Orm.GetEntityString(EntityType, entity)}");
|
||||
AggregateRootUtils.CompareEntityValue(_boundaryName, Orm, EntityType, state.Value, entity, propertyName, tracking);
|
||||
await SaveTrackingChangeAsync(tracking, cancellationToken);
|
||||
Attach(entity); //应该只存储 propertyName 内容
|
||||
}
|
||||
|
||||
async Task<int> SaveTrackingChangeAsync(AggregateRootTrackingChangeInfo tracking, CancellationToken cancellationToken)
|
||||
{
|
||||
var affrows = 0;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -162,5 +162,18 @@ namespace FreeSql
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
return Repository.InsertOrUpdate(this as TEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To completely save the navigation properties of the entity in the form of sub-tables. <br />
|
||||
/// 【完整】保存导航属性,子表
|
||||
/// </summary>
|
||||
/// <param name="navigatePropertyName">Navigation property name</param>
|
||||
public virtual void SaveMany(string navigatePropertyName)
|
||||
{
|
||||
if (Repository == null)
|
||||
Repository = Orm.GetRepository<TEntity>();
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
Repository.SaveMany(this as TEntity, navigatePropertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,6 +149,19 @@ namespace FreeSql
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
return Repository.InsertOrUpdateAsync(this as TEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To completely save the navigation properties of the entity in the form of sub-tables. <br />
|
||||
/// 【完整】保存导航属性,子表
|
||||
/// </summary>
|
||||
/// <param name="navigatePropertyName">Navigation property name</param>
|
||||
public virtual Task SaveManyAsync(string navigatePropertyName)
|
||||
{
|
||||
if (Repository == null)
|
||||
Repository = Orm.GetRepository<TEntity>();
|
||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||
return Repository.SaveManyAsync(this as TEntity, navigatePropertyName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -82,6 +82,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.BaseEntity`1.SaveMany(System.String)">
|
||||
<summary>
|
||||
To completely save the navigation properties of the entity in the form of sub-tables. <br />
|
||||
【完整】保存导航属性,子表
|
||||
</summary>
|
||||
<param name="navigatePropertyName">Navigation property name</param>
|
||||
</member>
|
||||
<member name="T:FreeSql.BaseEntityAsync`2">
|
||||
<summary>
|
||||
Entity base class, including CreateTime/UpdateTime/IsDeleted, the async CRUD methods, and ID primary key definition.
|
||||
@@ -152,6 +159,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSql.BaseEntityAsync`1.SaveManyAsync(System.String)">
|
||||
<summary>
|
||||
To completely save the navigation properties of the entity in the form of sub-tables. <br />
|
||||
【完整】保存导航属性,子表
|
||||
</summary>
|
||||
<param name="navigatePropertyName">Navigation property name</param>
|
||||
</member>
|
||||
<member name="T:FreeSql.BaseEntity">
|
||||
<summary>
|
||||
Entity base class, including CreateTime/UpdateTime/IsDeleted.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<Title>$(AssemblyName)</Title>
|
||||
<IsPackable>true</IsPackable>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -705,6 +705,7 @@ ManyToMany 级联删除中间表(注意不删除外部根)
|
||||
case DataType.ShenTong:
|
||||
case DataType.DuckDB:
|
||||
case DataType.Firebird: //firebird 只支持单条插入 returning
|
||||
case DataType.Xugu:
|
||||
if (_tableIdentitys.Length == 1 && _tableReturnColumns.Length == 1)
|
||||
{
|
||||
var idtval = OrmInsert(table).AppendData(data).ExecuteIdentity();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
||||
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -95,6 +95,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.Duckdb", "
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.Duckdb", "FreeSql.Tests\FreeSql.Tests.Provider.Duckdb\FreeSql.Tests.Provider.Duckdb.csproj", "{B9787A81-D537-45ED-B413-61BF03C8FEBE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.TDengine", "Providers\FreeSql.Provider.TDengine\FreeSql.Provider.TDengine.csproj", "{C89AFB35-AC56-4683-BCB5-13D3522DFED3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -537,6 +539,18 @@ Global
|
||||
{B9787A81-D537-45ED-B413-61BF03C8FEBE}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B9787A81-D537-45ED-B413-61BF03C8FEBE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B9787A81-D537-45ED-B413-61BF03C8FEBE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Release|x64.Build.0 = Release|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -573,10 +587,11 @@ Global
|
||||
{353F3732-0704-40F2-972B-036E9CC01881} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
{4367B7AC-604F-4503-A1D4-643ADBFCF703} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
|
||||
{02CFB50A-D8C4-470D-AC93-5540D6029430} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
{C89AFB35-AC56-4683-BCB5-13D3522DFED3} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {089687FA-5D21-40AC-BA8A-AA0D1E1H7F98}
|
||||
RESX_PrefixTranslations = True
|
||||
RESX_NeutralResourcesLanguage = en-US
|
||||
RESX_PrefixTranslations = True
|
||||
SolutionGuid = {089687FA-5D21-40AC-BA8A-AA0D1E1H7F98}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -12,93 +12,93 @@ namespace FreeSql
|
||||
/// <summary>
|
||||
/// AddFreeDbContext 发生错误,请检查 {dbContextTypeName} 的构造参数都已正确注入
|
||||
/// </summary>
|
||||
public static string AddFreeDbContextError_CheckConstruction(object dbContextTypeName) => string.Format(Language == "cn" ?
|
||||
@"AddFreeDbContext 发生错误,请检查 {0} 的构造参数都已正确注入" :
|
||||
@"FreeSql: An error occurred in AddFreeDbContext, check that the construction parameters of {0} have been injected correctly", dbContextTypeName);
|
||||
public static string AddFreeDbContextError_CheckConstruction(object dbContextTypeName) => Language == "cn" ?
|
||||
$@"AddFreeDbContext 发生错误,请检查 {dbContextTypeName} 的构造参数都已正确注入" :
|
||||
$@"FreeSql: An error occurred in AddFreeDbContext, check that the construction parameters of {dbContextTypeName} have been injected correctly";
|
||||
/// <summary>
|
||||
/// 不可添加,已存在于状态管理:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotAdd_AlreadyExistsInStateManagement(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可添加,已存在于状态管理:{0}" :
|
||||
@"FreeSql: Not addable, already exists in state management: {0}", entityString);
|
||||
public static string CannotAdd_AlreadyExistsInStateManagement(object entityString) => Language == "cn" ?
|
||||
$@"不可添加,已存在于状态管理:{entityString}" :
|
||||
$@"FreeSql: Not addable, already exists in state management: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可添加,实体没有主键:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotAdd_EntityHasNo_PrimaryKey(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可添加,实体没有主键:{0}" :
|
||||
@"FreeSql: Not addable, entity has no primary key: {0}", entityString);
|
||||
public static string CannotAdd_EntityHasNo_PrimaryKey(object entityString) => Language == "cn" ?
|
||||
$@"不可添加,实体没有主键:{entityString}" :
|
||||
$@"FreeSql: Not addable, entity has no primary key: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可添加,未设置主键的值:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotAdd_PrimaryKey_NotSet(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可添加,未设置主键的值:{0}" :
|
||||
@"FreeSql: Not addable, no value for primary key set: {0}", entityString);
|
||||
public static string CannotAdd_PrimaryKey_NotSet(object entityString) => Language == "cn" ?
|
||||
$@"不可添加,未设置主键的值:{entityString}" :
|
||||
$@"FreeSql: Not addable, no value for primary key set: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可添加,自增属性有值:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotAdd_SelfIncreasingHasValue(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可添加,自增属性有值:{0}" :
|
||||
@"FreeSql: Not addable, self-increasing attribute has value: {0}", entityString);
|
||||
public static string CannotAdd_SelfIncreasingHasValue(object entityString) => Language == "cn" ?
|
||||
$@"不可添加,自增属性有值:{entityString}" :
|
||||
$@"FreeSql: Not addable, self-increasing attribute has value: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可附加,实体没有主键:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotAttach_EntityHasNo_PrimaryKey(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可附加,实体没有主键:{0}" :
|
||||
@"FreeSql: Not attachable, entity has no primary key: {0}", entityString);
|
||||
public static string CannotAttach_EntityHasNo_PrimaryKey(object entityString) => Language == "cn" ?
|
||||
$@"不可附加,实体没有主键:{entityString}" :
|
||||
$@"FreeSql: Not attachable, entity has no primary key: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可附加,未设置主键的值:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotAttach_PrimaryKey_NotSet(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可附加,未设置主键的值:{0}" :
|
||||
@"FreeSql: Not attachable, no value for primary key set: {0}", entityString);
|
||||
public static string CannotAttach_PrimaryKey_NotSet(object entityString) => Language == "cn" ?
|
||||
$@"不可附加,未设置主键的值:{entityString}" :
|
||||
$@"FreeSql: Not attachable, no value for primary key set: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可删除,数据未被跟踪,应该先查询:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotDelete_DataNotTracked_ShouldQuery(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可删除,数据未被跟踪,应该先查询:{0}" :
|
||||
@"FreeSql: Not deletable, data not tracked, should query first: {0}", entityString);
|
||||
public static string CannotDelete_DataNotTracked_ShouldQuery(object entityString) => Language == "cn" ?
|
||||
$@"不可删除,数据未被跟踪,应该先查询:{entityString}" :
|
||||
$@"FreeSql: Not deletable, data not tracked, should query first: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可删除,实体没有主键:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotDelete_EntityHasNo_PrimaryKey(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可删除,实体没有主键:{0}" :
|
||||
@"FreeSql: Not deletable, entity has no primary key: {0}", entityString);
|
||||
public static string CannotDelete_EntityHasNo_PrimaryKey(object entityString) => Language == "cn" ?
|
||||
$@"不可删除,实体没有主键:{entityString}" :
|
||||
$@"FreeSql: Not deletable, entity has no primary key: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可删除,未设置主键的值:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotDelete_PrimaryKey_NotSet(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可删除,未设置主键的值:{0}" :
|
||||
@"FreeSql: Not deletable, no value for primary key set: {0}", entityString);
|
||||
public static string CannotDelete_PrimaryKey_NotSet(object entityString) => Language == "cn" ?
|
||||
$@"不可删除,未设置主键的值:{entityString}" :
|
||||
$@"FreeSql: Not deletable, no value for primary key set: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可进行编辑,实体没有主键:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotEdit_EntityHasNo_PrimaryKey(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可进行编辑,实体没有主键:{0}" :
|
||||
@"FreeSql: Not editable, entity has no primary key: {0}", entityString);
|
||||
public static string CannotEdit_EntityHasNo_PrimaryKey(object entityString) => Language == "cn" ?
|
||||
$@"不可进行编辑,实体没有主键:{entityString}" :
|
||||
$@"FreeSql: Not editable, entity has no primary key: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可更新,数据未被跟踪,应该先查询 或者 Attach:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotUpdate_DataShouldQueryOrAttach(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可更新,数据未被跟踪,应该先查询 或者 Attach:{0}" :
|
||||
@"FreeSql: Not updatable, data not tracked, should be queried first or Attach:{0}", entityString);
|
||||
public static string CannotUpdate_DataShouldQueryOrAttach(object entityString) => Language == "cn" ?
|
||||
$@"不可更新,数据未被跟踪,应该先查询 或者 Attach:{entityString}" :
|
||||
$@"FreeSql: Not updatable, data not tracked, should be queried first or Attach:{entityString}";
|
||||
/// <summary>
|
||||
/// 不可更新,实体没有主键:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotUpdate_EntityHasNo_PrimaryKey(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可更新,实体没有主键:{0}" :
|
||||
@"FreeSql: Not updatable, entity has no primary key: {0}", entityString);
|
||||
public static string CannotUpdate_EntityHasNo_PrimaryKey(object entityString) => Language == "cn" ?
|
||||
$@"不可更新,实体没有主键:{entityString}" :
|
||||
$@"FreeSql: Not updatable, entity has no primary key: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可更新,未设置主键的值:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotUpdate_PrimaryKey_NotSet(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可更新,未设置主键的值:{0}" :
|
||||
@"FreeSql: Not updatable, no value for primary key set: {0}", entityString);
|
||||
public static string CannotUpdate_PrimaryKey_NotSet(object entityString) => Language == "cn" ?
|
||||
$@"不可更新,未设置主键的值:{entityString}" :
|
||||
$@"FreeSql: Not updatable, no value for primary key set: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可更新,数据库不存在该记录:{entityString}
|
||||
/// </summary>
|
||||
public static string CannotUpdate_RecordDoesNotExist(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可更新,数据库不存在该记录:{0}" :
|
||||
@"FreeSql: Not updatable, the record does not exist in the database: {0}", entityString);
|
||||
public static string CannotUpdate_RecordDoesNotExist(object entityString) => Language == "cn" ?
|
||||
$@"不可更新,数据库不存在该记录:{entityString}" :
|
||||
$@"FreeSql: Not updatable, the record does not exist in the database: {entityString}";
|
||||
/// <summary>
|
||||
/// 请在 OnConfiguring 或 AddFreeDbContext 中配置 UseFreeSql
|
||||
/// </summary>
|
||||
@@ -110,103 +110,103 @@ namespace FreeSql
|
||||
/// </summary>
|
||||
public static string DbSetAsType_NotSupport_Object => Language == "cn" ?
|
||||
@"DbSet.AsType 参数错误,请传入正确的实体类型" :
|
||||
@"FreeSql: DbSet.AsType parameter error, please pass in the correct entity type";
|
||||
@"FreeSql: DbSet. AsType parameter error, please pass in the correct entity type";
|
||||
/// <summary>
|
||||
/// 实体类型 {EntityTypeName} 无法转换为 {name},无法使用该方法
|
||||
/// </summary>
|
||||
public static string EntityType_CannotConvert(object EntityTypeName, object name) => string.Format(Language == "cn" ?
|
||||
@"实体类型 {0} 无法转换为 {1},无法使用该方法" :
|
||||
@"FreeSql: Entity type {0} cannot be converted to {1} and cannot use this method", EntityTypeName, name);
|
||||
public static string EntityType_CannotConvert(object EntityTypeName, object name) => Language == "cn" ?
|
||||
$@"实体类型 {EntityTypeName} 无法转换为 {name},无法使用该方法" :
|
||||
$@"FreeSql: Entity type {EntityTypeName} cannot be converted to {name} and cannot use this method";
|
||||
/// <summary>
|
||||
/// 实体类型 {EntityTypeName} 主键类型不为 {fullName},无法使用该方法
|
||||
/// </summary>
|
||||
public static string EntityType_PrimaryKeyError(object EntityTypeName, object fullName) => string.Format(Language == "cn" ?
|
||||
@"实体类型 {0} 主键类型不为 {1},无法使用该方法" :
|
||||
@"FreeSql: Entity type {0} Primary key type is not {1} and cannot be used with this method", EntityTypeName, fullName);
|
||||
public static string EntityType_PrimaryKeyError(object EntityTypeName, object fullName) => Language == "cn" ?
|
||||
$@"实体类型 {EntityTypeName} 主键类型不为 {fullName},无法使用该方法" :
|
||||
$@"FreeSql: Entity type {EntityTypeName} Primary key type is not {fullName} and cannot be used with this method";
|
||||
/// <summary>
|
||||
/// 实体类型 {EntityTypeName} 主键数量不为 1,无法使用该方法
|
||||
/// </summary>
|
||||
public static string EntityType_PrimaryKeyIsNotOne(object EntityTypeName) => string.Format(Language == "cn" ?
|
||||
@"实体类型 {0} 主键数量不为 1,无法使用该方法" :
|
||||
@"FreeSql: Entity type {0} Primary key number is not 1 and cannot be used with this method", EntityTypeName);
|
||||
public static string EntityType_PrimaryKeyIsNotOne(object EntityTypeName) => Language == "cn" ?
|
||||
$@"实体类型 {EntityTypeName} 主键数量不为 1,无法使用该方法" :
|
||||
$@"FreeSql: Entity type {EntityTypeName} Primary key number is not 1 and cannot be used with this method";
|
||||
/// <summary>
|
||||
/// FreeSql.Repository 设置过滤器失败,原因是对象不属于 IRepository
|
||||
/// </summary>
|
||||
public static string FailedSetFilter_NotBelongIRpository => Language == "cn" ?
|
||||
@"FreeSql.Repository 设置过滤器失败,原因是对象不属于 IRepository" :
|
||||
@"FreeSql: FreeSql.Repository failed to set filter because object does not belong to IRepository";
|
||||
@"FreeSql: FreeSql. Repository failed to set filter because object does not belong to IRepository";
|
||||
/// <summary>
|
||||
/// 不可比较,实体没有主键:{entityString}
|
||||
/// </summary>
|
||||
public static string Incomparable_EntityHasNo_PrimaryKey(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可比较,实体没有主键:{0}" :
|
||||
@"FreeSql: Not comparable, entity has no primary key: {0}", entityString);
|
||||
public static string Incomparable_EntityHasNo_PrimaryKey(object entityString) => Language == "cn" ?
|
||||
$@"不可比较,实体没有主键:{entityString}" :
|
||||
$@"FreeSql: Not comparable, entity has no primary key: {entityString}";
|
||||
/// <summary>
|
||||
/// 不可比较,未设置主键的值:{entityString}
|
||||
/// </summary>
|
||||
public static string Incomparable_PrimaryKey_NotSet(object entityString) => string.Format(Language == "cn" ?
|
||||
@"不可比较,未设置主键的值:{0}" :
|
||||
@"FreeSql: Non-comparable, no value for primary key set: {0}", entityString);
|
||||
public static string Incomparable_PrimaryKey_NotSet(object entityString) => Language == "cn" ?
|
||||
$@"不可比较,未设置主键的值:{entityString}" :
|
||||
$@"FreeSql: Non-comparable, no value for primary key set: {entityString}";
|
||||
/// <summary>
|
||||
/// FreeSql.Repository Insert 失败,因为设置了过滤器 {filterKey}: {filterValueExpression},插入的数据不符合 {entityString}
|
||||
/// </summary>
|
||||
public static string InsertError_Filter(object filterKey, object filterValueExpression, object entityString) => string.Format(Language == "cn" ?
|
||||
@"FreeSql.Repository Insert 失败,因为设置了过滤器 {0}: {1},插入的数据不符合 {2}" :
|
||||
@"FreeSql: FreeSql.Repository Insert failed because the filter {0}: {1} was set and the inserted data does not conform to {2}", filterKey, filterValueExpression, entityString);
|
||||
public static string InsertError_Filter(object filterKey, object filterValueExpression, object entityString) => Language == "cn" ?
|
||||
$@"FreeSql.Repository Insert 失败,因为设置了过滤器 {filterKey}: {filterValueExpression},插入的数据不符合 {entityString}" :
|
||||
$@"FreeSql: FreeSql.Repository Insert failed because the filter {filterKey}: {filterValueExpression} was set and the inserted data does not conform to {entityString}";
|
||||
/// <summary>
|
||||
/// ISelect.AsType 参数不支持指定为 object
|
||||
/// </summary>
|
||||
public static string ISelectAsType_ParameterError => Language == "cn" ?
|
||||
@"ISelect.AsType 参数不支持指定为 object" :
|
||||
@"FreeSql: ISelect.AsType parameter does not support specifying as object";
|
||||
@"FreeSql: ISelect. AsType parameter does not support specifying as object";
|
||||
/// <summary>
|
||||
/// {tableTypeFullName} 不存在属性 {propertyName}
|
||||
/// </summary>
|
||||
public static string NotFound_Property(object propertyName, object tableTypeFullName) => string.Format(Language == "cn" ?
|
||||
@"{1} 不存在属性 {0}" :
|
||||
@"FreeSql: Property {0} does not exist for {1}", propertyName, tableTypeFullName);
|
||||
public static string NotFound_Property(object propertyName, object tableTypeFullName) => Language == "cn" ?
|
||||
$@"{tableTypeFullName} 不存在属性 {propertyName}" :
|
||||
$@"FreeSql: Property {propertyName} does not exist for {tableTypeFullName}";
|
||||
/// <summary>
|
||||
/// 找不到方法 DbSet&lt;&gt;.StatesRemoveByObjects
|
||||
/// </summary>
|
||||
public static string NotFoundMethod_StatesRemoveByObjects => Language == "cn" ?
|
||||
@"找不到方法 DbSet<>.StatesRemoveByObjects" :
|
||||
@"FreeSql: Method not found DbSet<>.StatesRemoveByObjects";
|
||||
@"FreeSql: Method DbSet<> not found. StatesRemoveByObjects";
|
||||
/// <summary>
|
||||
/// 参数 data 类型错误 {entityTypeFullName}
|
||||
/// </summary>
|
||||
public static string ParameterDataTypeError(object entityTypeFullName) => string.Format(Language == "cn" ?
|
||||
@"参数 data 类型错误 {0} " :
|
||||
@"FreeSql: Parameter data type error {0}", entityTypeFullName);
|
||||
public static string ParameterDataTypeError(object entityTypeFullName) => Language == "cn" ?
|
||||
$@"参数 data 类型错误 {entityTypeFullName} " :
|
||||
$@"FreeSql: Parameter data type error {entityTypeFullName}";
|
||||
/// <summary>
|
||||
/// 参数错误 {param}
|
||||
/// </summary>
|
||||
public static string ParameterError(object param) => string.Format(Language == "cn" ?
|
||||
@"参数错误 {0}" :
|
||||
@"FreeSql: Parameter error {0}", param);
|
||||
public static string ParameterError(object param) => Language == "cn" ?
|
||||
$@"参数错误 {param}" :
|
||||
$@"FreeSql: Parameter error {param}";
|
||||
/// <summary>
|
||||
/// 参数错误 {param} 不能为 null
|
||||
/// </summary>
|
||||
public static string ParameterError_CannotBeNull(object param) => string.Format(Language == "cn" ?
|
||||
@"参数错误 {0} 不能为 null" :
|
||||
@"FreeSql: Parameter error {0} cannot be null", param);
|
||||
public static string ParameterError_CannotBeNull(object param) => Language == "cn" ?
|
||||
$@"参数错误 {param} 不能为 null" :
|
||||
$@"FreeSql: Parameter error {param} cannot be null";
|
||||
/// <summary>
|
||||
/// 参数错误 {many} 不是集合属性
|
||||
/// </summary>
|
||||
public static string ParameterError_IsNot_CollectionProperties(object many) => string.Format(Language == "cn" ?
|
||||
@"参数错误 {0} 不是集合属性" :
|
||||
@"FreeSql: Parameter error {0} is not a collection property", many);
|
||||
public static string ParameterError_IsNot_CollectionProperties(object many) => Language == "cn" ?
|
||||
$@"参数错误 {many} 不是集合属性" :
|
||||
$@"FreeSql: Parameter error {many} is not a collection property";
|
||||
/// <summary>
|
||||
/// 参数错误 {many} 集合属性不存在
|
||||
/// </summary>
|
||||
public static string ParameterError_NotFound_CollectionProperties(object many) => string.Format(Language == "cn" ?
|
||||
@"参数错误 {0} 集合属性不存在" :
|
||||
@"FreeSql: Parameter error {0} Collection property does not exist", many);
|
||||
public static string ParameterError_NotFound_CollectionProperties(object many) => Language == "cn" ?
|
||||
$@"参数错误 {many} 集合属性不存在" :
|
||||
$@"FreeSql: Parameter error {many} Collection property does not exist";
|
||||
/// <summary>
|
||||
/// 参数错误 {one} 属性不存在
|
||||
/// </summary>
|
||||
public static string ParameterError_NotFound_Property(object one) => string.Format(Language == "cn" ?
|
||||
@"参数错误 {0} 属性不存在" :
|
||||
@"FreeSql: Parameter error {0} attribute does not exist", one);
|
||||
public static string ParameterError_NotFound_Property(object one) => Language == "cn" ?
|
||||
$@"参数错误 {one} 属性不存在" :
|
||||
$@"FreeSql: Parameter error {one} attribute does not exist";
|
||||
/// <summary>
|
||||
/// Propagation_Mandatory: 使用当前事务,如果没有当前事务,就抛出异常
|
||||
/// </summary>
|
||||
@@ -222,21 +222,21 @@ namespace FreeSql
|
||||
/// <summary>
|
||||
/// {tableTypeFullName} 类型的属性 {propertyName} 不是 OneToMany 或 ManyToMany 特性
|
||||
/// </summary>
|
||||
public static string PropertyOfType_IsNot_OneToManyOrManyToMany(object propertyName, object tableTypeFullName) => string.Format(Language == "cn" ?
|
||||
@"{1} 类型的属性 {0} 不是 OneToMany 或 ManyToMany 特性" :
|
||||
@"FreeSql: Property {0} of type {1} is not OneToMany or ManyToMany attribute", propertyName, tableTypeFullName);
|
||||
public static string PropertyOfType_IsNot_OneToManyOrManyToMany(object propertyName, object tableTypeFullName) => Language == "cn" ?
|
||||
$@"{tableTypeFullName} 类型的属性 {propertyName} 不是 OneToMany 或 ManyToMany 特性" :
|
||||
$@"FreeSql: Property {propertyName} of type {tableTypeFullName} is not OneToMany or ManyToMany attribute";
|
||||
/// <summary>
|
||||
/// 特别错误:批量添加失败,{dataType} 的返回数据,与添加的数目不匹配
|
||||
/// </summary>
|
||||
public static string SpecialError_BatchAdditionFailed(object dataType) => string.Format(Language == "cn" ?
|
||||
@"特别错误:批量添加失败,{0} 的返回数据,与添加的数目不匹配" :
|
||||
@"FreeSql: Special error: Bulk add failed, {0} returned data, does not match the number added", dataType);
|
||||
public static string SpecialError_BatchAdditionFailed(object dataType) => Language == "cn" ?
|
||||
$@"特别错误:批量添加失败,{dataType} 的返回数据,与添加的数目不匹配" :
|
||||
$@"FreeSql: Special error: Bulk add failed, {dataType} returned data, does not match the number added";
|
||||
/// <summary>
|
||||
/// 特别错误:更新失败,数据未被跟踪:{entityString}
|
||||
/// </summary>
|
||||
public static string SpecialError_UpdateFailedDataNotTracked(object entityString) => string.Format(Language == "cn" ?
|
||||
@"特别错误:更新失败,数据未被跟踪:{0}" :
|
||||
@"FreeSql: Special error: Update failed, data not tracked: {0}", entityString);
|
||||
public static string SpecialError_UpdateFailedDataNotTracked(object entityString) => Language == "cn" ?
|
||||
$@"特别错误:更新失败,数据未被跟踪:{entityString}" :
|
||||
$@"FreeSql: Special error: Update failed, data not tracked: {entityString}";
|
||||
/// <summary>
|
||||
/// 已开启事务,不能禁用工作单元
|
||||
/// </summary>
|
||||
@@ -246,21 +246,20 @@ namespace FreeSql
|
||||
/// <summary>
|
||||
/// {tableTypeFullName} 类型已设置属性 {propertyName} 忽略特性
|
||||
/// </summary>
|
||||
public static string TypeHasSetProperty_IgnoreAttribute(object tableTypeFullName, object propertyName) => string.Format(Language == "cn" ?
|
||||
@"{0} 类型已设置属性 {1} 忽略特性" :
|
||||
@"FreeSql: The {0} type has set the property {1} Ignore the attribute", tableTypeFullName, propertyName);
|
||||
public static string TypeHasSetProperty_IgnoreAttribute(object tableTypeFullName, object propertyName) => Language == "cn" ?
|
||||
$@"{tableTypeFullName} 类型已设置属性 {propertyName} 忽略特性" :
|
||||
$@"FreeSql: The {tableTypeFullName} type has set the property {propertyName} Ignore the attribute";
|
||||
/// <summary>
|
||||
/// {unitOfWorkManager} 构造参数 {fsql} 不能为 null
|
||||
/// </summary>
|
||||
public static string UnitOfWorkManager_Construction_CannotBeNull(object unitOfWorkManager, object fsql) => string.Format(Language == "cn" ?
|
||||
@"{0} 构造参数 {1} 不能为 null" :
|
||||
@"FreeSql: The {0} constructor parameter {1} cannot be null", unitOfWorkManager, fsql);
|
||||
public static string UnitOfWorkManager_Construction_CannotBeNull(object unitOfWorkManager, object fsql) => Language == "cn" ?
|
||||
$@"{unitOfWorkManager} 构造参数 {fsql} 不能为 null" :
|
||||
$@"FreeSql: The {unitOfWorkManager} constructor parameter {fsql} cannot be null";
|
||||
/// <summary>
|
||||
/// FreeSql.Repository Update 失败,因为设置了过滤器 {filterKey}: {filterValueExpression},更新的数据不符合{entityString}
|
||||
/// </summary>
|
||||
public static string UpdateError_Filter(object filterKey, object filterValueExpression, object entityString) => string.Format(Language == "cn" ?
|
||||
@"FreeSql.Repository Update 失败,因为设置了过滤器 {0}: {1},更新的数据不符合{2}" :
|
||||
@"FreeSql: FreeSql.Repository Update failed because the filter {0}: {1} is set and the updated data does not conform to {2}", filterKey, filterValueExpression, entityString);
|
||||
public static string UpdateError_Filter(object filterKey, object filterValueExpression, object entityString) => Language == "cn" ?
|
||||
$@"FreeSql.Repository Update 失败,因为设置了过滤器 {filterKey}: {filterValueExpression},更新的数据不符合{entityString}" :
|
||||
$@"FreeSql: FreeSql.Repository Update failed because the filter {filterKey}: {filterValueExpression} is set and the updated data does not conform to {entityString}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -225,7 +225,12 @@ namespace FreeSql
|
||||
{
|
||||
if (isAuditValue)
|
||||
{
|
||||
FreeSql.Internal.CommonProvider.UpdateProvider<TEntity>.AuditDataValue(this, item, _db.OrmOriginal, _table, null); //与 CanUpdate 同步
|
||||
foreach (var col in _table.Columns.Values) //#1746
|
||||
{
|
||||
object val = col.GetValue(item);
|
||||
if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false)
|
||||
col.SetValue(item, val = "");
|
||||
}
|
||||
_db.Options.AuditValue?.Invoke(new DbContextAuditValueEventArgs(Aop.AuditValueType.Update, _table.Type, item));
|
||||
}
|
||||
var key = _db.OrmOriginal.GetEntityKeyString(_entityType, item, false);
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace FreeSql
|
||||
case DataType.ShenTong:
|
||||
case DataType.DuckDB:
|
||||
case DataType.Firebird: //firebird 只支持单条插入 returning
|
||||
case DataType.Xugu:
|
||||
if (_tableIdentitys.Length == 1 && _tableReturnColumns.Length == 1)
|
||||
{
|
||||
await DbContextFlushCommandAsync(cancellationToken);
|
||||
@@ -149,6 +150,65 @@ namespace FreeSql
|
||||
await AddOrUpdateNavigateAsync(item, true, null, cancellationToken);
|
||||
}
|
||||
|
||||
async public Task SaveManyAsync(TEntity item, string propertyName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (item == null) return;
|
||||
if (string.IsNullOrEmpty(propertyName)) return;
|
||||
if (_table.Properties.TryGetValue(propertyName, out var prop) == false) throw new KeyNotFoundException(DbContextErrorStrings.NotFound_Property(_table.Type.FullName, propertyName));
|
||||
if (_table.ColumnsByCsIgnore.ContainsKey(propertyName)) throw new ArgumentException(DbContextErrorStrings.TypeHasSetProperty_IgnoreAttribute(_table.Type.FullName, propertyName));
|
||||
|
||||
var tref = _table.GetTableRef(propertyName, true, false);
|
||||
if (tref == null) return;
|
||||
switch (tref.RefType)
|
||||
{
|
||||
case TableRefType.OneToOne:
|
||||
case TableRefType.ManyToOne:
|
||||
case TableRefType.PgArrayToMany:
|
||||
throw new ArgumentException(DbContextErrorStrings.PropertyOfType_IsNot_OneToManyOrManyToMany(_table.Type.FullName, propertyName));
|
||||
}
|
||||
|
||||
await DbContextFlushCommandAsync(cancellationToken);
|
||||
var oldEnable = _db.Options.EnableCascadeSave;
|
||||
_db.Options.EnableCascadeSave = false;
|
||||
try
|
||||
{
|
||||
await AddOrUpdateNavigateAsync(item, false, propertyName, cancellationToken);
|
||||
if (tref.RefType == TableRefType.OneToMany)
|
||||
{
|
||||
await DbContextFlushCommandAsync(cancellationToken);
|
||||
//删除没有保存的数据,求出主体的条件
|
||||
var deleteWhereParentParam = Expression.Parameter(typeof(object), "a");
|
||||
Expression whereParentExp = null;
|
||||
for (var colidx = 0; colidx < tref.Columns.Count; colidx++)
|
||||
{
|
||||
var whereExp = Expression.Equal(
|
||||
Expression.MakeMemberAccess(Expression.Convert(deleteWhereParentParam, tref.RefEntityType), tref.RefColumns[colidx].Table.Properties[tref.RefColumns[colidx].CsName]),
|
||||
Expression.Constant(
|
||||
FreeSql.Internal.Utils.GetDataReaderValue(
|
||||
tref.Columns[colidx].CsType,
|
||||
_db.OrmOriginal.GetEntityValueWithPropertyName(_table.Type, item, tref.Columns[colidx].CsName)), tref.RefColumns[colidx].CsType)
|
||||
);
|
||||
if (whereParentExp == null) whereParentExp = whereExp;
|
||||
else whereParentExp = Expression.AndAlso(whereParentExp, whereExp);
|
||||
}
|
||||
var propValEach = GetItemValue(item, prop) as IEnumerable;
|
||||
var subDelete = _db.OrmOriginal.Delete<object>().AsType(tref.RefEntityType)
|
||||
.WithTransaction(_uow?.GetOrBeginTransaction())
|
||||
.Where(Expression.Lambda<Func<object, bool>>(whereParentExp, deleteWhereParentParam));
|
||||
foreach (var propValItem in propValEach)
|
||||
{
|
||||
subDelete.WhereDynamic(propValEach, true);
|
||||
break;
|
||||
}
|
||||
await subDelete.ExecuteAffrowsAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_db.Options.EnableCascadeSave = oldEnable;
|
||||
}
|
||||
}
|
||||
|
||||
async Task AddOrUpdateNavigateAsync(TEntity item, bool isAdd, string propertyName, CancellationToken cancellationToken)
|
||||
{
|
||||
Func<PropertyInfo, Task> action = async prop =>
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace FreeSql
|
||||
case DataType.ShenTong:
|
||||
case DataType.DuckDB:
|
||||
case DataType.Firebird: //firebird 只支持单条插入 returning
|
||||
case DataType.Xugu:
|
||||
if (_tableIdentitys.Length == 1 && _tableReturnColumns.Length == 1)
|
||||
{
|
||||
DbContextFlushCommand();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netstandard2.1;netcoreapp3.1;netstandard2.0;net45;net40</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;netstandard2.1;netstandard2.0;net45;net40</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql is the ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, Firebird, Clickhouse, DuckDB, TDengine, QuestDB, Odbc, Oledb, 达梦, 人大金仓, 南大通用, 虚谷, 神舟通用, 翰高, And Access</Description>
|
||||
@@ -17,7 +17,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -35,10 +35,13 @@
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
|
||||
<DefineConstants>net40</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<DefineConstants>netcoreapp</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
@@ -58,9 +61,4 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FreeSql\FreeSql.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -712,6 +712,15 @@
|
||||
<param name="modelBuilder"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSqlDbContextExtensions.ApplyConfigurationsFromAssembly(FreeSql.ICodeFirst,System.Reflection.Assembly,System.Func{System.Type,System.Boolean})">
|
||||
<summary>
|
||||
根据Assembly扫描所有继承IEntityTypeConfiguration<T>的配置类
|
||||
</summary>
|
||||
<param name="codeFirst"></param>
|
||||
<param name="assembly"></param>
|
||||
<param name="predicate"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSqlDbContextExtensions.CreateDbContext(IFreeSql)">
|
||||
<summary>
|
||||
创建普通数据上下文档对象
|
||||
@@ -749,5 +758,13 @@
|
||||
<param name="that"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Reflection.Assembly[])">
|
||||
<summary>
|
||||
批量注入 Repository,可以参考代码自行调整
|
||||
</summary>
|
||||
<param name="services"></param>
|
||||
<param name="assemblies"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
||||
@@ -68,6 +68,12 @@ namespace FreeSql
|
||||
await _db.SaveChangesAsync(cancellationToken);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public virtual async Task SaveManyAsync(TEntity entity, string propertyName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await _dbset.SaveManyAsync(entity, propertyName, cancellationToken);
|
||||
await _db.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
partial class BaseRepository<TEntity, TKey>
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace FreeSql
|
||||
Task<int> UpdateAsync(TEntity entity, CancellationToken cancellationToken = default);
|
||||
Task<int> UpdateAsync(IEnumerable<TEntity> entitys, CancellationToken cancellationToken = default);
|
||||
Task<TEntity> InsertOrUpdateAsync(TEntity entity, CancellationToken cancellationToken = default);
|
||||
Task SaveManyAsync(TEntity entity, string propertyName, CancellationToken cancellationToken = default);
|
||||
|
||||
Task<int> DeleteAsync(TEntity entity, CancellationToken cancellationToken = default);
|
||||
Task<int> DeleteAsync(IEnumerable<TEntity> entitys, CancellationToken cancellationToken = default);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;netstandard2.1;netstandard2.0;net45;net40</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;net5.0;netcoreapp3.1;netstandard2.1;netstandard2.0;net45;net40</TargetFrameworks>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite/Firebird/Clickhouse/DuckDB/TDengine/QuestDB/达梦/人大金仓/南大通用/虚谷/神舟通用/翰高/Access, and read/write separation、and split table.</Description>
|
||||
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>
|
||||
@@ -17,7 +17,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="xunit" Version="2.5.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.TDengine\FreeSql.Provider.TDengine.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using FreeSql.Tests.Provider.TDengine.TDengine.Tables;
|
||||
using Xunit;
|
||||
|
||||
namespace FreeSql.Tests.Provider.TDengine.TDengine.TDengineAdo
|
||||
{
|
||||
public class TDengineAdoTest
|
||||
{
|
||||
IFreeSql fsql => g.tdengine;
|
||||
|
||||
[Fact]
|
||||
void CodeFirstTest()
|
||||
{
|
||||
fsql.CodeFirst.SyncStructure<D1001>();
|
||||
fsql.CodeFirst.SyncStructure<D1002>();
|
||||
fsql.CodeFirst.SyncStructure<Users>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void InsertTest()
|
||||
{
|
||||
var insertAffrows = fsql.Insert(new D1001()
|
||||
{
|
||||
Ts = DateTime.Now,
|
||||
Current = 1,
|
||||
Voltage = 1,
|
||||
Describe = "D10021"
|
||||
}
|
||||
).ExecuteAffrows();
|
||||
|
||||
var insertAffrows2 = fsql.Insert(new D1001()
|
||||
{
|
||||
Ts = DateTime.Now,
|
||||
Current = 1,
|
||||
Voltage = 1,
|
||||
Describe = "D10021"
|
||||
}
|
||||
).ExecuteAffrows();
|
||||
|
||||
var batchInsertAffrows = fsql.Insert(new List<D1002>()
|
||||
{
|
||||
new D1002()
|
||||
{
|
||||
Ts = DateTime.Now,
|
||||
Current = 6,
|
||||
Voltage = 6,
|
||||
Describe = "D10026"
|
||||
},
|
||||
new D1002()
|
||||
{
|
||||
Ts = DateTime.Now,
|
||||
Current = 3,
|
||||
Voltage = 3,
|
||||
Describe = "D10023"
|
||||
},
|
||||
new D1002()
|
||||
{
|
||||
Ts = DateTime.Now,
|
||||
Current = 4,
|
||||
Voltage = 4,
|
||||
Describe = "D10024"
|
||||
}
|
||||
}
|
||||
).ExecuteAffrows();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void SelectTest()
|
||||
{
|
||||
var subList = fsql.Select<D1001>().ToList(d => new
|
||||
{
|
||||
GroupId = d.GroupId
|
||||
});
|
||||
|
||||
var superMetersList = fsql.Select<Meters>().ToList();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void WhereSelectTest()
|
||||
{
|
||||
var list = fsql.Select<Meters>().Where(d => d.GroupId == 2).ToList();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void DeleteTest()
|
||||
{
|
||||
var startTime = DateTime.Parse("2024-11-30T02:33:52.308+00:00");
|
||||
var endTime = DateTime.Parse("2024-11-30T02:40:58.961+00:00");
|
||||
var executeAffrows = fsql.Delete<Meters>()
|
||||
.Where(meters => meters.Ts >= startTime && meters.Ts <= endTime && meters.GroupId == 1)
|
||||
.ExecuteAffrows();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void DbFirst_GetDatabases()
|
||||
{
|
||||
var databases = fsql.DbFirst.GetDatabases();
|
||||
foreach (var database in databases)
|
||||
{
|
||||
Console.WriteLine(database);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql.Provider.TDengine.Attributes;
|
||||
|
||||
namespace FreeSql.Tests.Provider.TDengine.TDengine.Tables
|
||||
{
|
||||
[TDengineSuperTable(Name = "meters")]
|
||||
public class Meters
|
||||
{
|
||||
[Column(Name = "ts")]
|
||||
public DateTime Ts { get; set; }
|
||||
|
||||
[Column(Name = "current")]
|
||||
public float Current { get; set; }
|
||||
|
||||
[Column(Name = "voltage")]
|
||||
public int Voltage { get; set; }
|
||||
|
||||
[Column(Name = "describe", StringLength = 50)]
|
||||
public string? Describe { get; set; }
|
||||
|
||||
[TDengineTag(Name = "location")]
|
||||
public virtual string? Location { get; set; }
|
||||
|
||||
[TDengineTag(Name = "group_id")]
|
||||
public virtual int GroupId { get; set; }
|
||||
}
|
||||
|
||||
[TDengineSubTable(SuperTableName = "meters", Name = "d1001")]
|
||||
public class D1001 : Meters
|
||||
{
|
||||
[TDengineTag(Name = "location")]
|
||||
public override string Location { get; set; } = "BeiJIng.ChaoYang";
|
||||
|
||||
[TDengineTag(Name = "group_id")]
|
||||
public override int GroupId { get; set; } = 1;
|
||||
}
|
||||
|
||||
[TDengineSubTable(SuperTableName = "meters", Name = "d1002")]
|
||||
public class D1002 : Meters
|
||||
{
|
||||
[TDengineTag(Name = "location")]
|
||||
public new string Location { get; set; } = "California.SanFrancisco";
|
||||
|
||||
[TDengineTag(Name = "group_id")]
|
||||
public new int GroupId { get; set; } = 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.DataAnnotations;
|
||||
|
||||
namespace FreeSql.Tests.Provider.TDengine.TDengine.Tables
|
||||
{
|
||||
[Table(Name = "users")]
|
||||
public class Users
|
||||
{
|
||||
[Column(Name = "ts")]
|
||||
public DateTime Ts { get; set; }
|
||||
|
||||
[Column(Name = "id")]
|
||||
public float Id { get; set; }
|
||||
|
||||
[Column(Name = "address")]
|
||||
public int Address { get; set; }
|
||||
|
||||
[Column(Name = "name", StringLength = 20)]
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace FreeSql.Tests.Provider.TDengine.TDengineAdo
|
||||
{
|
||||
public class TDengineAdoTest
|
||||
{
|
||||
IFreeSql fsql => g.tdengine;
|
||||
|
||||
[Fact]
|
||||
public void AuditValue()
|
||||
{
|
||||
var executeConnectTest = fsql.Ado.ExecuteConnectTest();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
26
FreeSql.Tests/FreeSql.Tests.Provider.TDengine/g.cs
Normal file
26
FreeSql.Tests/FreeSql.Tests.Provider.TDengine/g.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql.Tests.Provider.TDengine
|
||||
{
|
||||
internal class g
|
||||
{
|
||||
private static readonly Lazy<IFreeSql> tdengineLazy = new Lazy<IFreeSql>(() =>
|
||||
{
|
||||
var fsql = new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionString(FreeSql.DataType.TDengine,
|
||||
"host=localhost;port=6030;username=root;password=taosdata;protocol=Native;db=test;")
|
||||
.UseMonitorCommand(cmd => Console.WriteLine($"Sql:{cmd.CommandText}\r\n"))
|
||||
.UseNoneCommandParameter(true)
|
||||
.Build();
|
||||
return fsql;
|
||||
});
|
||||
|
||||
public static IFreeSql tdengine => tdengineLazy.Value;
|
||||
}
|
||||
}
|
||||
29
FreeSql.sln
29
FreeSql.sln
@@ -131,6 +131,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.Duckdb", "
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.Duckdb", "FreeSql.Tests\FreeSql.Tests.Provider.Duckdb\FreeSql.Tests.Provider.Duckdb.csproj", "{DE79C012-15B1-40EC-AD19-CBD7D489DB8E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.TDengine", "Providers\FreeSql.Provider.TDengine\FreeSql.Provider.TDengine.csproj", "{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.TDengine", "FreeSql.Tests\FreeSql.Tests.Provider.TDengine\FreeSql.Tests.Provider.TDengine.csproj", "{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -789,6 +793,30 @@ Global
|
||||
{DE79C012-15B1-40EC-AD19-CBD7D489DB8E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{DE79C012-15B1-40EC-AD19-CBD7D489DB8E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{DE79C012-15B1-40EC-AD19-CBD7D489DB8E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Release|x64.Build.0 = Release|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317}.Release|x86.Build.0 = Release|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Release|x64.Build.0 = Release|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0C178F1C-0F65-47AA-A1DE-545CBF8543D1}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -831,6 +859,7 @@ Global
|
||||
{8064870C-22EA-4A58-972D-DBD57D096D91} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
{D9419896-BFB0-47C1-BEFD-A6C48394643B} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
|
||||
{4871434E-481D-4306-B6DD-73595C61A473} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
{329BA8B3-4139-4CCE-AFEC-4BE9B7BED317} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
RESX_NeutralResourcesLanguage = en-US
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace FreeSql
|
||||
|
||||
CustomOracle, CustomSqlServer, CustomMySql, CustomPostgreSQL,
|
||||
|
||||
DuckDB
|
||||
DuckDB,
|
||||
|
||||
TDengine
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,9 +253,9 @@ namespace FreeSql.Extensions.EntityUtil
|
||||
)
|
||||
});
|
||||
exps.AddRange(new Expression[] {
|
||||
Expression.Return(returnTarget, var2Ret),
|
||||
Expression.Label(returnTarget, Expression.Default(typeof(object)))
|
||||
});
|
||||
Expression.Return(returnTarget, var2Ret),
|
||||
Expression.Label(returnTarget, Expression.Default(typeof(object)))
|
||||
});
|
||||
return Expression.Lambda<Func<object, object>>(Expression.Block(new[] { var1Parm, var2Ret }, exps), new[] { parm1 }).Compile();
|
||||
});
|
||||
return func(entity);
|
||||
|
||||
@@ -68,7 +68,65 @@ public static class FreeSqlGlobalExpressionCallExtensions
|
||||
expContext.Value.ParsedContent["end"];
|
||||
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} >= {time1} and {expContext.Value.ParsedContent["that"]} < {time2}";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#region IN 与 new[]{ 1,2,3 }.Contains(a.Id) 相同
|
||||
static Dictionary<string, string> pc => expContext.Value.ParsedContent;
|
||||
/// <summary>
|
||||
/// field IN (value1)
|
||||
/// </summary>
|
||||
public static bool In<T>(this T field, T value1)
|
||||
{
|
||||
if (expContext.Value == null) return field.Equals(value1);
|
||||
expContext.Value.Result = $"{pc["field"]} = {pc["value1"]}";
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// field in (value1, value2)
|
||||
/// </summary>
|
||||
public static bool In<T>(this T field, T value1, T value2)
|
||||
{
|
||||
if (expContext.Value == null) return field.Equals(value1) || field.Equals(value2);
|
||||
expContext.Value.Result = $"{pc["field"]} IN ({pc["value1"]},{pc["value2"]})";
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// field in (value1, value2, value3)
|
||||
/// </summary>
|
||||
public static bool In<T>(this T field, T value1, T value2, T value3)
|
||||
{
|
||||
if (expContext.Value == null) return field.Equals(value1) || field.Equals(value2) || field.Equals(value3);
|
||||
expContext.Value.Result = $"{pc["field"]} IN ({pc["value1"]},{pc["value2"]},{pc["value3"]})";
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// field in (value1, value2, value3, value4)
|
||||
/// </summary>
|
||||
public static bool In<T>(this T field, T value1, T value2, T value3, T value4)
|
||||
{
|
||||
if (expContext.Value == null) return field.Equals(value1) || field.Equals(value2) || field.Equals(value3) || field.Equals(value4);
|
||||
expContext.Value.Result = $"{pc["field"]} IN ({pc["value1"]},{pc["value2"]},{pc["value3"]},{pc["value4"]})";
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// field in (value1, value2, value3, value4, value5)
|
||||
/// </summary>
|
||||
public static bool In<T>(this T field, T value1, T value2, T value3, T value4, T value5)
|
||||
{
|
||||
if (expContext.Value == null) return field.Equals(value1) || field.Equals(value2) || field.Equals(value3) || field.Equals(value4) || field.Equals(value5);
|
||||
expContext.Value.Result = $"{pc["field"]} IN ({pc["value1"]},{pc["value2"]},{pc["value3"]},{pc["value4"]},{pc["value5"]})";
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// field in (values)
|
||||
/// </summary>
|
||||
public static bool In<T>(this T field, T[] values)
|
||||
{
|
||||
if (expContext.Value == null) return values?.Contains(field) == true;
|
||||
expContext.Value.Result = $"{pc["field"]} IN {pc["values"]}";
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
namespace FreeSql
|
||||
@@ -284,13 +342,13 @@ namespace FreeSql
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// case when .. then .. end
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ICaseWhenEnd Case() => SqlExtExtensions.Case();
|
||||
/// <summary>
|
||||
/// case when .. then .. end
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ICaseWhenEnd Case() => SqlExtExtensions.Case();
|
||||
/// <summary>
|
||||
/// case when .. then .. end
|
||||
/// </summary>
|
||||
|
||||
@@ -751,6 +751,7 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
|
||||
case DataType.Firebird:
|
||||
case DataType.ClickHouse:
|
||||
case DataType.DuckDB:
|
||||
case DataType.Xugu:
|
||||
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule,
|
||||
Expression.Call(typeof(Convert).GetMethod("ToString", new Type[] { typeof(string) }), pathSelector?.Body), select._diymemexpWithTempQuery, null, null);
|
||||
break;
|
||||
@@ -847,6 +848,7 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
|
||||
case DataType.CustomMySql:
|
||||
case DataType.Firebird:
|
||||
case DataType.DuckDB:
|
||||
case DataType.Xugu:
|
||||
nsselsb.Append("RECURSIVE ");
|
||||
break;
|
||||
}
|
||||
@@ -900,6 +902,7 @@ SELECT ");
|
||||
case DataType.KingbaseES:
|
||||
case DataType.ShenTong:
|
||||
case DataType.DuckDB:
|
||||
case DataType.Xugu:
|
||||
return that.OrderBy("random()");
|
||||
case DataType.Oracle:
|
||||
case DataType.OdbcOracle:
|
||||
|
||||
@@ -385,6 +385,7 @@ namespace System.Linq.Expressions
|
||||
protected override Expression VisitMethodCall(MethodCallExpression node)
|
||||
{
|
||||
if (Result && node.IsExpressionCall()) Result = false;
|
||||
if (Result && node.Method.Name == "NewGuid" && node.Method.DeclaringType == typeof(Guid) && node.Object == null) Result = false;
|
||||
return base.VisitMethodCall(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -5559,7 +5559,7 @@
|
||||
</member>
|
||||
<member name="M:FreeSql.CoreErrorStrings.ObjectPool_GetAsync_Queue_Long(System.Object,System.Object)">
|
||||
<summary>
|
||||
【{policyName}】ObjectPool.GetAsync() The queue is too long, Policy.AsyncGetCapacity = {asyncGetCapacity}
|
||||
【{policyName}】ObjectPool.GetAsync() The queue is too long. Policy.AsyncGetCapacity = {asyncGetCapacity}
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSql.CoreErrorStrings.OneToMany_NotFound_CorrespondingField(System.Object,System.Object,System.Object,System.Object,System.Object)">
|
||||
@@ -5940,6 +5940,36 @@
|
||||
<param name="end"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:FreeSqlGlobalExpressionCallExtensions.In``1(``0,``0)">
|
||||
<summary>
|
||||
field IN (value1)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSqlGlobalExpressionCallExtensions.In``1(``0,``0,``0)">
|
||||
<summary>
|
||||
field in (value1, value2)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSqlGlobalExpressionCallExtensions.In``1(``0,``0,``0,``0)">
|
||||
<summary>
|
||||
field in (value1, value2, value3)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSqlGlobalExpressionCallExtensions.In``1(``0,``0,``0,``0,``0)">
|
||||
<summary>
|
||||
field in (value1, value2, value3, value4)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSqlGlobalExpressionCallExtensions.In``1(``0,``0,``0,``0,``0,``0)">
|
||||
<summary>
|
||||
field in (value1, value2, value3, value4, value5)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSqlGlobalExpressionCallExtensions.In``1(``0,``0[])">
|
||||
<summary>
|
||||
field in (values)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSqlGlobalExtensions.DisplayCsharp(System.Type,System.Boolean)">
|
||||
<summary>
|
||||
获取 Type 的原始 c# 文本表示
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace FreeSql
|
||||
bool _isLazyLoading = false;
|
||||
bool _isExitAutoDisposePool = true;
|
||||
bool _isQuoteSqlName = true;
|
||||
bool? _isAdoConnectionPool = false;
|
||||
bool? _isAdoConnectionPool = null;
|
||||
MappingPriorityType[] _mappingPriorityTypes;
|
||||
NameConvertType _nameConvertType = NameConvertType.None;
|
||||
Action<DbCommand> _aopCommandExecuting = null;
|
||||
@@ -385,6 +385,11 @@ namespace FreeSql
|
||||
if (type == null) throwNotFind("FreeSql.Provider.Duckdb.dll", "FreeSql.Duckdb.DuckdbProvider<>");
|
||||
break;
|
||||
|
||||
case DataType.TDengine:
|
||||
type = Type.GetType("FreeSql.TDengine.TDengineProvider`1,FreeSql.Provider.TDengine")?.MakeGenericType(typeof(TMark));
|
||||
if (type == null) throwNotFind("FreeSql.Provider.TDengine.dll", "FreeSql.TDengine.TDengineProvider<>");
|
||||
break;
|
||||
|
||||
default: throw new Exception(CoreErrorStrings.NotSpecified_UseConnectionString_UseConnectionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,15 +329,18 @@ namespace FreeSql.Internal
|
||||
//处理构造参数
|
||||
for (var a = 0; a < initExp.NewExpression.Arguments.Count; a++)
|
||||
{
|
||||
var initExpArg = initExp.NewExpression.Arguments[a];
|
||||
if (initExpArg.Type == typeof(bool) && initExpArg.NodeType == ExpressionType.Call)
|
||||
initExpArg = Expression.Condition(initExpArg, Expression.Constant(true, typeof(bool)), Expression.Constant(false, typeof(bool)));
|
||||
var child = new ReadAnonymousTypeInfo
|
||||
{
|
||||
Property = null,
|
||||
CsName = initExp.NewExpression.Members != null ? initExp.NewExpression.Members[a].Name : (initExp.NewExpression.Arguments[a] as MemberExpression)?.Member.Name,
|
||||
CsType = initExp.NewExpression.Arguments[a].Type,
|
||||
MapType = initExp.NewExpression.Arguments[a].Type
|
||||
CsName = initExp.NewExpression.Members != null ? initExp.NewExpression.Members[a].Name : (initExpArg as MemberExpression)?.Member.Name,
|
||||
CsType = initExpArg.Type,
|
||||
MapType = initExpArg.Type
|
||||
};
|
||||
parent.Childs.Add(child);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, initExp.NewExpression.Arguments[a], select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, initExpArg, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
}
|
||||
}
|
||||
else if (isAllDtoMap && _tables != null && _tables.Any() && initExp.NewExpression.Type != _tables.FirstOrDefault().Table.Type)
|
||||
@@ -424,16 +427,19 @@ namespace FreeSql.Internal
|
||||
{
|
||||
var initAssignExp = (initExp.Bindings[a] as MemberAssignment);
|
||||
if (initAssignExp == null) continue;
|
||||
var initExpArg = initAssignExp.Expression;
|
||||
if (initExpArg.Type == typeof(bool) && initExpArg.NodeType == ExpressionType.Call)
|
||||
initExpArg = Expression.Condition(initExpArg, Expression.Constant(true, typeof(bool)), Expression.Constant(false, typeof(bool)));
|
||||
var child = new ReadAnonymousTypeInfo
|
||||
{
|
||||
Property = initExp.Type.GetProperty(initExp.Bindings[a].Member.Name, BindingFlags.Public | BindingFlags.Instance), //#427 不能使用 BindingFlags.IgnoreCase
|
||||
CsName = initExp.Bindings[a].Member.Name,
|
||||
CsType = initAssignExp.Expression.Type,
|
||||
MapType = initAssignExp.Expression.Type
|
||||
CsType = initExpArg.Type,
|
||||
MapType = initExpArg.Type
|
||||
};
|
||||
if (child.Property == null) child.ReflectionField = initExp.Type.GetField(initExp.Bindings[a].Member.Name, BindingFlags.Public | BindingFlags.Instance);
|
||||
parent.Childs.Add(child);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, initAssignExp.Expression, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, initExpArg, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
}
|
||||
}
|
||||
if (parent.Childs.Any() == false) throw new Exception(CoreErrorStrings.Mapping_Exception_HasNo_SamePropertyName(initExp.NewExpression.Type.Name));
|
||||
@@ -458,16 +464,19 @@ namespace FreeSql.Internal
|
||||
//处理构造参数
|
||||
for (var a = 0; a < newExp.Arguments.Count; a++)
|
||||
{
|
||||
var csname = newExp.Members != null ? newExp.Members[a].Name : (newExp.Arguments[a] as MemberExpression)?.Member.Name;
|
||||
var initExpArg = newExp.Arguments[a];
|
||||
if (initExpArg.Type == typeof(bool) && initExpArg.NodeType == ExpressionType.Call)
|
||||
initExpArg = Expression.Condition(initExpArg, Expression.Constant(true, typeof(bool)), Expression.Constant(false, typeof(bool)));
|
||||
var csname = newExp.Members != null ? newExp.Members[a].Name : (initExpArg as MemberExpression)?.Member.Name;
|
||||
var child = new ReadAnonymousTypeInfo
|
||||
{
|
||||
Property = null,
|
||||
CsName = csname,
|
||||
CsType = newExp.Arguments[a].Type,
|
||||
MapType = newExp.Arguments[a].Type
|
||||
CsType = initExpArg.Type,
|
||||
MapType = initExpArg.Type
|
||||
};
|
||||
parent.Childs.Add(child);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, newExp.Arguments[a], select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
ReadAnonymousField(_tables, _tableRule, field, child, ref index, initExpArg, select, diymemexp, whereGlobalFilter, findIncludeMany, findSubSelectMany, false);
|
||||
if (child.CsName == null)
|
||||
child.CsName = csname;
|
||||
}
|
||||
@@ -1056,6 +1065,20 @@ namespace FreeSql.Internal
|
||||
var exp3 = exp as MethodCallExpression;
|
||||
if (exp3.IsExpressionCall())
|
||||
{
|
||||
//SqlExt.In 替换成 Array.Contains 解析,可避免 MapType 问题
|
||||
if (exp3.Method.Name == "In" && exp3.Method.DeclaringType == typeof(FreeSqlGlobalExpressionCallExtensions))
|
||||
{
|
||||
var exp3MethodGenericType = exp3.Method.GetGenericArguments().FirstOrDefault();
|
||||
if (exp3MethodGenericType != null)
|
||||
{
|
||||
var exp3ContainsMethod = Select0Provider.GetMethodEnumerable("Contains").MakeGenericMethod(exp3MethodGenericType);
|
||||
var exp3Arg1 = exp3.Arguments.Skip(1).ToArray();
|
||||
var exp3ConvertExp = exp3Arg1.Length == 1 && exp3Arg1[0].Type.IsArray ?
|
||||
Expression.Call(exp3ContainsMethod, exp3Arg1[0], exp3.Arguments[0]) :
|
||||
Expression.Call(exp3ContainsMethod, Expression.NewArrayInit(exp3MethodGenericType, exp3Arg1), exp3.Arguments[0]);
|
||||
return ExpressionLambdaToSql(exp3ConvertExp, tsc.CloneDisableDiyParse());
|
||||
}
|
||||
}
|
||||
var ecc = new ExpressionCallContext
|
||||
{
|
||||
_commonExp = this,
|
||||
|
||||
@@ -609,10 +609,10 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
public virtual string ToSql() => ToSqlValuesOrSelectUnionAllExtension103(true, null, null, false);
|
||||
|
||||
public string ToSqlValuesOrSelectUnionAll(bool isValues = true) => ToSqlValuesOrSelectUnionAllExtension103(isValues, null, null, false);
|
||||
public string ToSqlValuesOrSelectUnionAll(bool isValues = true, List<string> ignoreColumn = null) => ToSqlValuesOrSelectUnionAllExtension103(isValues, null, null, false, ignoreColumn);
|
||||
public string ToSqlValuesOrSelectUnionAllExtension101(bool isValues, Action<object, int, StringBuilder> onrow) => ToSqlValuesOrSelectUnionAllExtension103(isValues, null, onrow, false);
|
||||
public string ToSqlValuesOrSelectUnionAllExtension102(bool isValues, Action<object, int, StringBuilder> onrowPre, Action<object, int, StringBuilder> onrow) => ToSqlValuesOrSelectUnionAllExtension103(isValues, onrowPre, onrow, false);
|
||||
string ToSqlValuesOrSelectUnionAllExtension103(bool isValues, Action<object, int, StringBuilder> onrowPre, Action<object, int, StringBuilder> onrow, bool isAsTableSplited)
|
||||
string ToSqlValuesOrSelectUnionAllExtension103(bool isValues, Action<object, int, StringBuilder> onrowPre, Action<object, int, StringBuilder> onrow, bool isAsTableSplited, List<string> ignoreColumn = null)
|
||||
{
|
||||
if (_source == null || _source.Any() == false) return null;
|
||||
var sb = new StringBuilder();
|
||||
@@ -631,7 +631,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
foreach (var item in atarr)
|
||||
{
|
||||
_source = item.ToList();
|
||||
sb.Append(ToSqlValuesOrSelectUnionAllExtension103(isValues, onrowPre, onrow, true)).Append("\r\n\r\n;\r\n\r\n");
|
||||
sb.Append(ToSqlValuesOrSelectUnionAllExtension103(isValues, onrowPre, onrow, true, ignoreColumn)).Append("\r\n\r\n;\r\n\r\n");
|
||||
}
|
||||
_source = oldSource;
|
||||
if (sb.Length > 0) sb.Remove(sb.Length - 9, 9);
|
||||
@@ -643,6 +643,8 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var colidx = 0;
|
||||
foreach (var col in _table.Columns.Values)
|
||||
{
|
||||
//增加忽略插入的列
|
||||
if (ignoreColumn?.Contains(col.CsName) == true) continue;
|
||||
if (col.Attribute.IsIdentity && _insertIdentity == false && string.IsNullOrEmpty(col.DbInsertValue)) continue;
|
||||
if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name)) continue;
|
||||
|
||||
@@ -663,6 +665,8 @@ namespace FreeSql.Internal.CommonProvider
|
||||
var colidx2 = 0;
|
||||
foreach (var col in _table.Columns.Values)
|
||||
{
|
||||
//增加忽略插入的列
|
||||
if (ignoreColumn?.Contains(col.CsName) == true) continue;
|
||||
if (col.Attribute.IsIdentity && _insertIdentity == false && string.IsNullOrEmpty(col.DbInsertValue)) continue;
|
||||
if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name)) continue;
|
||||
|
||||
|
||||
@@ -1291,6 +1291,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case DataType.OdbcPostgreSQL:
|
||||
case DataType.CustomPostgreSQL:
|
||||
case DataType.KingbaseES:
|
||||
case DataType.Xugu:
|
||||
_tosqlAppendContent = $"{_tosqlAppendContent} for update{(noawait ? " nowait" : "")}";
|
||||
break;
|
||||
case DataType.Oracle:
|
||||
|
||||
@@ -271,9 +271,9 @@ namespace FreeSql.Internal.CommonProvider
|
||||
querys = querys?.Where(q => q != null).ToArray();
|
||||
if (querys?.Any() != true) return this;
|
||||
var ret = (_orm as BaseDbProvider).CreateSelectProvider<T1>(null) as Select1Provider<T1>;
|
||||
var sb = new StringBuilder().Append(LocalGetQuerySql(this));
|
||||
var sb = new StringBuilder().Append(this._select).Append(" * from (").Append(LocalGetQuerySql(this)).Append(") ftb");
|
||||
foreach (var select2 in querys)
|
||||
sb.Append(" \r\nUNION ALL \r\n").Append(LocalGetQuerySql(select2));
|
||||
sb.Append(" \r\nUNION ALL \r\nselect * from (").Append(LocalGetQuerySql(select2)).Append(") ftb");
|
||||
ret.WithSql(sb.ToString());
|
||||
sb.Clear();
|
||||
ret._commandTimeout = _commandTimeout;
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case DataType.KingbaseES:
|
||||
case DataType.ShenTong:
|
||||
case DataType.DuckDB:
|
||||
case DataType.Xugu:
|
||||
InterceptPostgreSQL?.Invoke(); break;
|
||||
case DataType.Oracle:
|
||||
case DataType.OdbcOracle:
|
||||
@@ -216,6 +217,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case DataType.CustomPostgreSQL:
|
||||
case DataType.KingbaseES:
|
||||
case DataType.ShenTong:
|
||||
case DataType.Xugu:
|
||||
break;
|
||||
default:
|
||||
var tbalias = _query2Provider._tables.Where(tb => tb.Table == col.Table).FirstOrDefault()?.Alias ?? _query2Provider._tables[0].Alias;
|
||||
|
||||
@@ -1197,6 +1197,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
case DataType.CustomPostgreSQL:
|
||||
case DataType.KingbaseES:
|
||||
case DataType.ShenTong:
|
||||
case DataType.Xugu:
|
||||
vcvalue = $"{_tableAlias}.{vcname}"; //set name = b.name
|
||||
break;
|
||||
default:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -228,7 +228,9 @@ namespace FreeSql.Internal
|
||||
if (common.CodeFirst.IsSyncStructureToLower) colattr.Name = colattr.Name.ToLower();
|
||||
if (common.CodeFirst.IsSyncStructureToUpper) colattr.Name = colattr.Name.ToUpper();
|
||||
|
||||
if ((colattr.IsNullable != true || colattr.IsIdentity == true || colattr.IsPrimary == true) && colattr.DbType.Contains("NOT NULL") == false && common._orm.Ado.DataType != DataType.ClickHouse)
|
||||
if ((colattr.IsNullable != true || colattr.IsIdentity == true || colattr.IsPrimary == true) && colattr.DbType.Contains("NOT NULL") == false &&
|
||||
common._orm.Ado.DataType != DataType.ClickHouse &&
|
||||
common._orm.Ado.DataType != DataType.TDengine)
|
||||
{
|
||||
colattr.IsNullable = false;
|
||||
colattr.DbType = Regex.Replace(colattr.DbType, @"\bNULL\b", "").Trim() + " NOT NULL";
|
||||
@@ -397,6 +399,7 @@ namespace FreeSql.Internal
|
||||
case DataType.CustomPostgreSQL:
|
||||
case DataType.KingbaseES:
|
||||
case DataType.ShenTong:
|
||||
case DataType.Xugu:
|
||||
if (strlen < 0) colattr.DbType = $"TEXT{strNotNull}";
|
||||
else colattr.DbType = Regex.Replace(colattr.DbType, charPattern, m =>
|
||||
replaceCounter++ == 0 ? $"{m.Groups[1].Value}({strlen})" : m.Groups[0].Value);
|
||||
@@ -424,6 +427,10 @@ namespace FreeSql.Internal
|
||||
else colattr.DbType = Regex.Replace(colattr.DbType, charPattern, m =>
|
||||
replaceCounter++ == 0 ? $"{m.Groups[1].Value}({strlen})" : m.Groups[0].Value);
|
||||
break;
|
||||
case DataType.TDengine:
|
||||
colattr.DbType = Regex.Replace(colattr.DbType, charPattern, m =>
|
||||
replaceCounter++ == 0 ? $"{m.Groups[1].Value}({strlen})" : m.Groups[0].Value);
|
||||
break;
|
||||
case DataType.MsAccess:
|
||||
charPattern = @"(CHAR|CHAR2|CHARACTER|TEXT)\s*(\([^\)]*\))?";
|
||||
if (strlen < 0) colattr.DbType = $"LONGTEXT{strNotNull}";
|
||||
@@ -470,7 +477,8 @@ namespace FreeSql.Internal
|
||||
case DataType.CustomPostgreSQL:
|
||||
case DataType.KingbaseES:
|
||||
case DataType.ShenTong: //驱动引发的异常:“System.Data.OscarClient.OscarException”(位于 System.Data.OscarClient.dll 中)
|
||||
colattr.DbType = $"BYTEA{strNotNull}"; //变长二进制串
|
||||
case DataType.Xugu:
|
||||
colattr.DbType = $"BYTEA{strNotNull}"; //变长二进制串
|
||||
break;
|
||||
case DataType.Oracle:
|
||||
case DataType.OdbcOracle:
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<Title>$(AssemblyName)</Title>
|
||||
<IsPackable>true</IsPackable>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Linq;
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using DuckDB.NET.Data;
|
||||
using static DuckDB.NET.Native.NativeMethods;
|
||||
using ColumnInfo = FreeSql.Internal.Model.ColumnInfo;
|
||||
|
||||
namespace FreeSql.Duckdb
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Numerics;
|
||||
using static DuckDB.NET.Native.NativeMethods;
|
||||
using System.Text;
|
||||
using System.Security.AccessControl;
|
||||
using ColumnInfo = FreeSql.Internal.Model.ColumnInfo;
|
||||
|
||||
namespace FreeSql.Duckdb
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql + DuckDB is a fast in-process analytical database,supports .NetCore、.NetFramework4.6.1+</Description>
|
||||
@@ -18,24 +18,24 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="../../readme.md" Pack="true" PackagePath="\"/>
|
||||
<None Include="../../readme.md" Pack="true" PackagePath="\" />
|
||||
<None Include="../../logo.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DuckDB.NET.Data.Full" Version="1.0.2" />
|
||||
<PackageReference Include="DuckDB.NET.Data.Full" Version="1.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<DefineConstants>net60</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -268,9 +268,9 @@ where trim(d.rdb$relation_name) = {0}", tboldname ?? tbname);
|
||||
sb.Remove(sb.Length - 2, 2).Append(");\r\n");
|
||||
}
|
||||
}
|
||||
var dbcomment = string.Concat(_orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select trim(rdb$external_description) from rdb$relations where rdb$system_flag=0 and trim(rdb$relation_name) = {0}", tbname)));
|
||||
var dbcomment = string.Concat(_orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select trim(rdb$description) from rdb$relations where rdb$system_flag=0 and trim(rdb$relation_name) = {0}", tbname)));
|
||||
if (dbcomment != (tb.Comment ?? ""))
|
||||
sb.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName(tbname)).Append(" COMMENT ").Append(" ").Append(_commonUtils.FormatSql("{0}", tb.Comment ?? "")).Append(";\r\n");
|
||||
sb.Append("COMMENT ON TABLE ").Append(_commonUtils.QuoteSqlName(tbname)).Append(" IS ").Append(_commonUtils.FormatSql("{0}", tb.Comment ?? "")).Append(";\r\n");
|
||||
}
|
||||
return sb.Length == 0 ? null : sb.ToString();
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ select
|
||||
trim(rdb$relation_name) as id,
|
||||
trim(rdb$owner_name) as owner,
|
||||
trim(rdb$relation_name) as name,
|
||||
trim(rdb$external_description) as comment,
|
||||
trim(rdb$description) as comment,
|
||||
rdb$relation_type as type
|
||||
from rdb$relations
|
||||
where rdb$system_flag=0" + (tbname == null ? "" : $" and {(ignoreCase ? "upper(trim(rdb$relation_name))" : "trim(rdb$relation_name)")} = {_commonUtils.FormatSql("{0}", tbname.Last())}");
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace FreeSql.Firebird
|
||||
if (value == null) return "NULL";
|
||||
if (type.IsNumberType()) return string.Format(CultureInfo.InvariantCulture, "{0}", value);
|
||||
if (type == typeof(byte[])) return $"x'{CommonUtils.BytesSqlRaw(value as byte[])}'";
|
||||
if (type == typeof(string) && col != null && (specialParamFlag == "c" || specialParamFlag == "cu")) return $"cast('{value.ToString().Replace("'", "''")}' as {col.Attribute.DbType})"; //#1923
|
||||
return FormatSql("{0}", value, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.1;netstandard2.0;net452</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql 数据库实现,基于 Firebird</Description>
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
<None Include="../../logo.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="8.5.4" />
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="10.3.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
|
||||
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="7.10.1" />
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.0;net461</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql 数据库实现,基于 人大金仓数据库 V008R003/V008R006 Ado.Net (Kdbndp)</Description>
|
||||
@@ -15,7 +15,7 @@
|
||||
<Title>$(AssemblyName)</Title>
|
||||
<IsPackable>true</IsPackable>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<DefineConstants>ns20;netstandard20</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<DefineConstants>net60</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0;net452;net451;net45;net40</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net452;net451;net45;net40</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql 数据库实现,基于 MySql 5.6,Ado.Net 驱动是 MySql.Data(Oracle官方)</Description>
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -27,7 +27,10 @@
|
||||
<None Include="../../logo.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net452' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="MySql.Data" Version="9.1.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
|
||||
<PackageReference Include="MySql.Data" Version="8.0.30" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net40'">
|
||||
@@ -41,7 +44,7 @@
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
|
||||
<DefineConstants>net40</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<DefineConstants>net60</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;netcoreapp3.1;netstandard2.1;netstandard2.0;net45</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net45</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql 数据库实现,基于 MySql 5.6,Ado.Net 驱动是 MySqlConnector</Description>
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -27,8 +27,12 @@
|
||||
<None Include="../../logo.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MySqlConnector" Version="2.0.0" />
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="MySqlConnector" Version="2.4.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
|
||||
<PackageReference Include="MySqlConnector" Version="2.1.13" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -45,7 +49,7 @@
|
||||
<PropertyGroup>
|
||||
<DefineConstants>MySqlConnector</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<DefineConstants>net60;MySqlConnector</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net5.0;netstandard2.1;netstandard2.0;net45;net40</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;net5.0;netcoreapp31;netstandard2.1;net45;net40</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql 数据库实现,基于 Oracle 11</Description>
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -27,13 +27,9 @@
|
||||
<None Include="../../logo.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.210" />
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'netcoreapp31'">
|
||||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.6.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net5.0'">
|
||||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.120" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'net40'">
|
||||
<PackageReference Include="Oracle.ManagedDataAccess" Version="19.18.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0;net461;net452;net451;net45</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.0;net461;net452;net451;net45</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql 数据库实现,基于 PostgreSQL 9.5</Description>
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="Npgsql.LegacyPostgis" Version="5.0.11" />
|
||||
<PackageReference Include="Npgsql.NetTopologySuite" Version="5.0.11" />
|
||||
</ItemGroup>
|
||||
@@ -49,8 +49,8 @@
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461'">
|
||||
<DefineConstants>nts</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<DefineConstants>net60</DefineConstants>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<DefineConstants>net60;nts</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Newtonsoft.Json
|
||||
{
|
||||
@@ -57,6 +60,98 @@ namespace Newtonsoft.Json
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static readonly Regex NpgsqlPointParseRegex = new Regex("\\((-?\\d+.?\\d*),(-?\\d+.?\\d*)\\)");
|
||||
static NpgsqlPoint NpgsqlPointParse(string s)
|
||||
{
|
||||
Match match = NpgsqlPointParseRegex.Match(s);
|
||||
if (!match.Success)
|
||||
throw new FormatException("Not a valid point: " + s);
|
||||
|
||||
return new NpgsqlPoint(double.Parse(match.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat), double.Parse(match.Groups[2].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat));
|
||||
}
|
||||
static readonly Regex NpgsqlLineRegex = new Regex(@"\{(-?\d+.?\d*),(-?\d+.?\d*),(-?\d+.?\d*)\}");
|
||||
static NpgsqlLine NpgsqlLineParse(string s)
|
||||
{
|
||||
var m = NpgsqlLineRegex.Match(s);
|
||||
if (!m.Success)
|
||||
throw new FormatException("Not a valid line: " + s);
|
||||
return new NpgsqlLine(
|
||||
double.Parse(m.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[2].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[3].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat)
|
||||
);
|
||||
}
|
||||
static readonly Regex NpgsqlLSegRegex = new Regex(@"\[\((-?\d+.?\d*),(-?\d+.?\d*)\),\((-?\d+.?\d*),(-?\d+.?\d*)\)\]");
|
||||
static NpgsqlLSeg NpgsqlLSegParse(string s)
|
||||
{
|
||||
var m = NpgsqlLSegRegex.Match(s);
|
||||
if (!m.Success)
|
||||
{
|
||||
throw new FormatException("Not a valid line: " + s);
|
||||
}
|
||||
return new NpgsqlLSeg(
|
||||
double.Parse(m.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[2].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[3].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[4].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat)
|
||||
);
|
||||
}
|
||||
static readonly Regex NpgsqlBoxRegex = new Regex(@"\((-?\d+.?\d*),(-?\d+.?\d*)\),\((-?\d+.?\d*),(-?\d+.?\d*)\)");
|
||||
static NpgsqlBox NpgsqlBoxParse(string s)
|
||||
{
|
||||
var m = NpgsqlBoxRegex.Match(s);
|
||||
return new NpgsqlBox(
|
||||
new NpgsqlPoint(double.Parse(m.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[2].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat)),
|
||||
new NpgsqlPoint(double.Parse(m.Groups[3].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[4].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat))
|
||||
);
|
||||
}
|
||||
static NpgsqlPath NpgsqlPathParse(string s)
|
||||
{
|
||||
var open = s[0] == '[' ? true : (s[0] == '(' ? false : throw new Exception("Invalid path string: " + s));
|
||||
Debug.Assert(s[s.Length - 1] == (open ? ']' : ')'));
|
||||
var result = new NpgsqlPath(open);
|
||||
var i = 1;
|
||||
while (true)
|
||||
{
|
||||
var i2 = s.IndexOf(')', i);
|
||||
result.Add(NpgsqlPointParse(s.Substring(i, i2 - i + 1)));
|
||||
if (s[i2 + 1] != ',')
|
||||
break;
|
||||
i = i2 + 2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
static NpgsqlPolygon NpgsqlPolygonParse(string s)
|
||||
{
|
||||
var points = new List<NpgsqlPoint>();
|
||||
var i = 1;
|
||||
while (true)
|
||||
{
|
||||
var i2 = s.IndexOf(')', i);
|
||||
points.Add(NpgsqlPointParse(s.Substring(i, i2 - i + 1)));
|
||||
if (s[i2 + 1] != ',')
|
||||
break;
|
||||
i = i2 + 2;
|
||||
}
|
||||
return new NpgsqlPolygon(points);
|
||||
}
|
||||
static readonly Regex NpgsqlCircleRegex = new Regex(@"<\((-?\d+.?\d*),(-?\d+.?\d*)\),(\d+.?\d*)>");
|
||||
static NpgsqlCircle NpgsqlCircleParse(string s)
|
||||
{
|
||||
var m = NpgsqlCircleRegex.Match(s);
|
||||
if (!m.Success)
|
||||
throw new FormatException("Not a valid circle: " + s);
|
||||
|
||||
return new NpgsqlCircle(
|
||||
double.Parse(m.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[2].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat),
|
||||
double.Parse(m.Groups[3].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat)
|
||||
);
|
||||
}
|
||||
|
||||
private object YieldJToken(Type ctype, JToken jt, int rank)
|
||||
{
|
||||
if (jt.Type == JTokenType.Null) return null;
|
||||
@@ -65,13 +160,13 @@ namespace Newtonsoft.Json
|
||||
var ctypeGenericType1 = ctype.GenericTypeArguments.FirstOrDefault();//ctype.Namespace == "System" && ctype.Name.StartsWith("Nullable`") ? ctype.GenericTypeArguments.FirstOrDefault() : null;
|
||||
if (ctype == typeof_BitArray) return jt.ToString().ToBitArray();
|
||||
|
||||
if (ctype == typeof_NpgsqlPoint || ctypeGenericType1 == typeof_NpgsqlPoint) return NpgsqlPoint.Parse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlLine || ctypeGenericType1 == typeof_NpgsqlLine) return NpgsqlLine.Parse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlLSeg || ctypeGenericType1 == typeof_NpgsqlLSeg) return NpgsqlLSeg.Parse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlBox || ctypeGenericType1 == typeof_NpgsqlBox) return NpgsqlBox.Parse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlPath || ctypeGenericType1 == typeof_NpgsqlPath) return NpgsqlPath.Parse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlPolygon || ctypeGenericType1 == typeof_NpgsqlPolygon) return NpgsqlPolygon.Parse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlCircle || ctypeGenericType1 == typeof_NpgsqlCircle) return NpgsqlCircle.Parse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlPoint || ctypeGenericType1 == typeof_NpgsqlPoint) return NpgsqlPointParse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlLine || ctypeGenericType1 == typeof_NpgsqlLine) return NpgsqlLineParse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlLSeg || ctypeGenericType1 == typeof_NpgsqlLSeg) return NpgsqlLSegParse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlBox || ctypeGenericType1 == typeof_NpgsqlBox) return NpgsqlBoxParse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlPath || ctypeGenericType1 == typeof_NpgsqlPath) return NpgsqlPathParse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlPolygon || ctypeGenericType1 == typeof_NpgsqlPolygon) return NpgsqlPolygonParse(jt.ToString());
|
||||
if (ctype == typeof_NpgsqlCircle || ctypeGenericType1 == typeof_NpgsqlCircle) return NpgsqlCircleParse(jt.ToString());
|
||||
|
||||
if (ctype == typeof_Cidr || ctypeGenericType1 == typeof_Cidr)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ public static partial class PostgreSQLTypesExtensions
|
||||
double radLng2 = (double)(point.X) * Math.PI / 180d;
|
||||
return 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin((radLat1 - radLat2) / 2), 2) + Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin((radLng1 - radLng2) / 2), 2))) * 6378137;
|
||||
}
|
||||
|
||||
|
||||
public static NpgsqlRange<T> ToNpgsqlRange<T>(this string that)
|
||||
{
|
||||
var s = that;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<Title>$(AssemblyName)</Title>
|
||||
<IsPackable>true</IsPackable>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0;net451;net45;net40</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net451;net45;net40</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql 数据库实现,基于 SqlServer 2005+,并根据版本适配分页方法:row_number 或 offset fetch next</Description>
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<DelaySign>false</DelaySign>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -30,21 +30,21 @@
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.7" />
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'netstandard2.0'">
|
||||
<DefineConstants>microsoft</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
|
||||
<DefineConstants>net40</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<DefineConstants>net60;microsoft</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -81,23 +81,42 @@ public static partial class FreeSqlSqlServerGlobalExtensions
|
||||
/// <param name="that"></param>
|
||||
/// <param name="rule"></param>
|
||||
/// <returns></returns>
|
||||
public static ISelect<T> WithIndex<T>(this ISelect<T> that, string indexName, Dictionary<Type, string> rule = null) => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2> WithIndex<T1, T2>(this ISelect<T1, T2> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3> WithIndex<T1, T2, T3>(this ISelect<T1, T2, T3> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4> WithIndex<T1, T2, T3, T4>(this ISelect<T1, T2, T3, T4> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5> WithIndex<T1, T2, T3, T4, T5>(this ISelect<T1, T2, T3, T4, T5> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6> WithIndex<T1, T2, T3, T4, T5, T6>(this ISelect<T1, T2, T3, T4, T5, T6> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7> WithIndex<T1, T2, T3, T4, T5, T6, T7>(this ISelect<T1, T2, T3, T4, T5, T6, T7> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T> WithIndex<T>(this ISelect<T> that, string indexName) => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2> WithIndex<T1, T2>(this ISelect<T1, T2> that, string indexName) where T1 : class where T2 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3> WithIndex<T1, T2, T3>(this ISelect<T1, T2, T3> that, string indexName) where T1 : class where T2 : class where T3 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4> WithIndex<T1, T2, T3, T4>(this ISelect<T1, T2, T3, T4> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5> WithIndex<T1, T2, T3, T4, T5>(this ISelect<T1, T2, T3, T4, T5> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6> WithIndex<T1, T2, T3, T4, T5, T6>(this ISelect<T1, T2, T3, T4, T5, T6> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7> WithIndex<T1, T2, T3, T4, T5, T6, T7>(this ISelect<T1, T2, T3, T4, T5, T6, T7> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class => LocalWithIndex(that, indexName, null);
|
||||
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> that, string indexName, Dictionary<Type, string> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class => LocalWithIndex(that, indexName, null);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> that, string indexName) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class => LocalWithIndex(that, indexName, null);
|
||||
|
||||
public static ISelect<T> WithIndex<T>(this ISelect<T> that, string indexName, Dictionary<Type, string> rule) => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2> WithIndex<T1, T2>(this ISelect<T1, T2> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3> WithIndex<T1, T2, T3>(this ISelect<T1, T2, T3> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4> WithIndex<T1, T2, T3, T4>(this ISelect<T1, T2, T3, T4> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5> WithIndex<T1, T2, T3, T4, T5>(this ISelect<T1, T2, T3, T4, T5> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6> WithIndex<T1, T2, T3, T4, T5, T6>(this ISelect<T1, T2, T3, T4, T5, T6> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7> WithIndex<T1, T2, T3, T4, T5, T6, T7>(this ISelect<T1, T2, T3, T4, T5, T6, T7> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class => LocalWithIndex(that, indexName, rule);
|
||||
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class => LocalWithIndex(that, indexName, rule);
|
||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> WithIndex<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> that, string indexName, Dictionary<Type, string> rule) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class => LocalWithIndex(that, indexName, rule);
|
||||
|
||||
static TReturn LocalWithIndex<TReturn>(TReturn query, string indexName, Dictionary<Type, string> rule)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(indexName)) return query;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0;net451;net45;net40</TargetFrameworks>
|
||||
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net451;net45;net40</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin</Authors>
|
||||
<Description>FreeSql 数据库实现,基于 System.Data.SqlClient + SqlServer 2005+,并根据版本适配分页方法:row_number 或 offset fetch next</Description>
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
|
||||
<DefineConstants>net40</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0' or '$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net6.0'">
|
||||
<DefineConstants>net60</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql.DataAnnotations
|
||||
{
|
||||
/// <summary>
|
||||
/// TDengine 超级表-子表
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class TDengineSubTableAttribute : TableAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 超表名称
|
||||
/// </summary>
|
||||
public string SuperTableName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql.DataAnnotations
|
||||
{
|
||||
/// <summary>
|
||||
/// TDengine 超级表
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class TDengineSuperTableAttribute : TableAttribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.DataAnnotations;
|
||||
|
||||
namespace FreeSql.Provider.TDengine.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class TDengineTagAttribute : ColumnAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
26
Providers/FreeSql.Provider.TDengine/Curd/TDengineDelete.cs
Normal file
26
Providers/FreeSql.Provider.TDengine/Curd/TDengineDelete.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using FreeSql.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql.TDengine.Curd
|
||||
{
|
||||
|
||||
class TDengineDelete<T1> : Internal.CommonProvider.DeleteProvider<T1>
|
||||
{
|
||||
public TDengineDelete(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override List<T1> ExecuteDeleted() => throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
|
||||
#if net40
|
||||
#else
|
||||
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
228
Providers/FreeSql.Provider.TDengine/Curd/TDengineInsert.cs
Normal file
228
Providers/FreeSql.Provider.TDengine/Curd/TDengineInsert.cs
Normal file
@@ -0,0 +1,228 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
using FreeSql.Provider.TDengine.Attributes;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql.TDengine.Curd
|
||||
{
|
||||
class TDengineInsert<T1> : Internal.CommonProvider.InsertProvider<T1> where T1 : class
|
||||
{
|
||||
public TDengineInsert(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression)
|
||||
: base(orm, commonUtils, commonExpression)
|
||||
{
|
||||
}
|
||||
|
||||
internal bool InternalIsIgnoreInto = false;
|
||||
internal IFreeSql InternalOrm => _orm;
|
||||
internal TableInfo InternalTable => _table;
|
||||
internal DbParameter[] InternalParams => _params;
|
||||
internal DbConnection InternalConnection => _connection;
|
||||
internal DbTransaction InternalTransaction => _transaction;
|
||||
internal CommonUtils InternalCommonUtils => _commonUtils;
|
||||
internal CommonExpression InternalCommonExpression => _commonExpression;
|
||||
internal List<T1> InternalSource => _source;
|
||||
internal Dictionary<string, bool> InternalIgnore => _ignore;
|
||||
internal void InternalClearData() => ClearData();
|
||||
|
||||
public override int ExecuteAffrows() => base.SplitExecuteAffrows(
|
||||
_batchValuesLimit > 0 ? _batchValuesLimit : 5000, _batchParameterLimit > 0 ? _batchParameterLimit : 3000);
|
||||
|
||||
public override long ExecuteIdentity() => base.SplitExecuteIdentity(
|
||||
_batchValuesLimit > 0 ? _batchValuesLimit : 5000, _batchParameterLimit > 0 ? _batchParameterLimit : 3000);
|
||||
|
||||
public override List<T1> ExecuteInserted() => base.SplitExecuteInserted(
|
||||
_batchValuesLimit > 0 ? _batchValuesLimit : 5000, _batchParameterLimit > 0 ? _batchParameterLimit : 3000);
|
||||
|
||||
|
||||
public override string ToSql()
|
||||
{
|
||||
//处理Insert忽略Tag
|
||||
var ignoreColumnList = _ignoreInsertColumns.GetOrAdd(typeof(T1), s =>
|
||||
{
|
||||
//如果是超表不处理
|
||||
if (!s.IsDefined(typeof(TDengineSubTableAttribute))) return new List<string>(0);
|
||||
var tableByEntity = _commonUtils.GetTableByEntity(s);
|
||||
var keyValuePairs = tableByEntity.Properties.Where(pair =>
|
||||
pair.Value.GetCustomAttribute<TDengineTagAttribute>() != null);
|
||||
return keyValuePairs.Select(keyValuePair => keyValuePair.Value.Name).ToList();
|
||||
});
|
||||
if (InternalIsIgnoreInto == false) return base.ToSqlValuesOrSelectUnionAll(ignoreColumn: ignoreColumnList);
|
||||
var sql = base.ToSqlValuesOrSelectUnionAll(ignoreColumn: ignoreColumnList);
|
||||
return $"INSERT IGNORE INTO {sql.Substring(12)}";
|
||||
}
|
||||
|
||||
private static ConcurrentDictionary<Type, List<string>> _ignoreInsertColumns =
|
||||
new ConcurrentDictionary<Type, List<string>>();
|
||||
|
||||
protected override long RawExecuteIdentity()
|
||||
{
|
||||
var sql = this.ToSql();
|
||||
if (string.IsNullOrEmpty(sql)) return 0;
|
||||
|
||||
sql = string.Concat(sql, "; SELECT LAST_INSERT_ID();");
|
||||
var before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, sql, _params);
|
||||
_orm.Aop.CurdBeforeHandler?.Invoke(this, before);
|
||||
long ret = 0;
|
||||
Exception exception = null;
|
||||
try
|
||||
{
|
||||
ret = long.TryParse(
|
||||
string.Concat(_orm.Ado.ExecuteScalar(_connection, _transaction, CommandType.Text, sql,
|
||||
_commandTimeout, _params)), out var trylng)
|
||||
? trylng
|
||||
: 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
var after = new Aop.CurdAfterEventArgs(before, exception, ret);
|
||||
_orm.Aop.CurdAfterHandler?.Invoke(this, after);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected override List<T1> RawExecuteInserted()
|
||||
{
|
||||
var sql = this.ToSql();
|
||||
if (string.IsNullOrEmpty(sql)) return new List<T1>();
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(sql).Append(" RETURNING ");
|
||||
|
||||
var colidx = 0;
|
||||
foreach (var col in _table.Columns.Values)
|
||||
{
|
||||
if (colidx > 0) sb.Append(", ");
|
||||
sb.Append(_commonUtils.RereadColumn(col, _commonUtils.QuoteSqlName(col.Attribute.Name))).Append(" as ")
|
||||
.Append(_commonUtils.QuoteSqlName(col.CsName));
|
||||
++colidx;
|
||||
}
|
||||
|
||||
sql = sb.ToString();
|
||||
var before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, sql, _params);
|
||||
_orm.Aop.CurdBeforeHandler?.Invoke(this, before);
|
||||
var ret = new List<T1>();
|
||||
Exception exception = null;
|
||||
try
|
||||
{
|
||||
ret = _orm.Ado.Query<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text,
|
||||
sql, _commandTimeout, _params);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
var after = new Aop.CurdAfterEventArgs(before, exception, ret);
|
||||
_orm.Aop.CurdAfterHandler?.Invoke(this, after);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if net40
|
||||
#else
|
||||
public override Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default) =>
|
||||
base.SplitExecuteAffrowsAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
||||
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
||||
|
||||
public override Task<long> ExecuteIdentityAsync(CancellationToken cancellationToken = default) =>
|
||||
base.SplitExecuteIdentityAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
||||
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
||||
|
||||
public override Task<List<T1>> ExecuteInsertedAsync(CancellationToken cancellationToken = default) =>
|
||||
base.SplitExecuteInsertedAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
||||
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
||||
|
||||
protected override async Task<long> RawExecuteIdentityAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var sql = this.ToSql();
|
||||
if (string.IsNullOrEmpty(sql)) return 0;
|
||||
|
||||
sql = string.Concat(sql, "; SELECT LAST_INSERT_ID();");
|
||||
var before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, sql, _params);
|
||||
_orm.Aop.CurdBeforeHandler?.Invoke(this, before);
|
||||
long ret = 0;
|
||||
Exception exception = null;
|
||||
try
|
||||
{
|
||||
ret = long.TryParse(
|
||||
string.Concat(await _orm.Ado.ExecuteScalarAsync(_connection, _transaction, CommandType.Text, sql,
|
||||
_commandTimeout, _params, cancellationToken)), out var trylng)
|
||||
? trylng
|
||||
: 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
var after = new Aop.CurdAfterEventArgs(before, exception, ret);
|
||||
_orm.Aop.CurdAfterHandler?.Invoke(this, after);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected override async Task<List<T1>> RawExecuteInsertedAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var sql = this.ToSql();
|
||||
if (string.IsNullOrEmpty(sql)) return new List<T1>();
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(sql).Append(" RETURNING ");
|
||||
|
||||
var colidx = 0;
|
||||
foreach (var col in _table.Columns.Values)
|
||||
{
|
||||
if (colidx > 0) sb.Append(", ");
|
||||
sb.Append(_commonUtils.RereadColumn(col, _commonUtils.QuoteSqlName(col.Attribute.Name))).Append(" as ")
|
||||
.Append(_commonUtils.QuoteSqlName(col.CsName));
|
||||
++colidx;
|
||||
}
|
||||
|
||||
sql = sb.ToString();
|
||||
var before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Insert, sql, _params);
|
||||
_orm.Aop.CurdBeforeHandler?.Invoke(this, before);
|
||||
var ret = new List<T1>();
|
||||
Exception exception = null;
|
||||
try
|
||||
{
|
||||
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction,
|
||||
CommandType.Text, sql, _commandTimeout, _params, cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
var after = new Aop.CurdAfterEventArgs(before, exception, ret);
|
||||
_orm.Aop.CurdAfterHandler?.Invoke(this, after);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
628
Providers/FreeSql.Provider.TDengine/Curd/TDengineSelect.cs
Normal file
628
Providers/FreeSql.Provider.TDengine/Curd/TDengineSelect.cs
Normal file
@@ -0,0 +1,628 @@
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
using FreeSql.Provider.TDengine.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace FreeSql.TDengine.Curd
|
||||
{
|
||||
internal class TDengineSelect<T1> : FreeSql.Internal.CommonProvider.Select1Provider<T1>
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal static string ToSqlStatic(CommonUtils _commonUtils, CommonExpression _commonExpression, string _select,
|
||||
bool _distinct, string field, StringBuilder _join, StringBuilder _where, string _groupby, string _having,
|
||||
string _orderby, int _skip, int _limit, List<SelectTableInfo> _tables,
|
||||
List<Dictionary<Type, string>> tbUnions, Func<Type, string, string> _aliasRule, string _tosqlAppendContent,
|
||||
List<GlobalFilter.Item> _whereGlobalFilter, IFreeSql _orm)
|
||||
{
|
||||
if (_orm.CodeFirst.IsAutoSyncStructure)
|
||||
_orm.CodeFirst.SyncStructure(_tables.Select(a => a.Table.Type).ToArray());
|
||||
|
||||
if (_whereGlobalFilter.Any())
|
||||
foreach (var tb in _tables.Where(a => a.Type != SelectTableInfoType.Parent))
|
||||
{
|
||||
tb.Cascade =
|
||||
_commonExpression.GetWhereCascadeSql(tb, _whereGlobalFilter.Where(a => a.Before == false),
|
||||
true);
|
||||
tb.CascadeBefore =
|
||||
_commonExpression.GetWhereCascadeSql(tb, _whereGlobalFilter.Where(a => a.Before == true), true);
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var tbUnionsGt0 = tbUnions.Count > 1;
|
||||
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
|
||||
{
|
||||
if (tbUnionsIdx > 0) sb.Append("\r\n \r\nUNION ALL\r\n \r\n");
|
||||
if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
|
||||
var tbUnion = tbUnions[tbUnionsIdx];
|
||||
var sbnav = new StringBuilder();
|
||||
sb.Append(_select);
|
||||
if (_distinct) sb.Append("DISTINCT ");
|
||||
sb.Append(field).Append(" \r\nFROM ");
|
||||
var tbsjoin = _tables.Where(a => a.Type != SelectTableInfoType.From).ToArray();
|
||||
var tbsfrom = _tables.Where(a => a.Type == SelectTableInfoType.From).ToArray();
|
||||
for (var a = 0; a < tbsfrom.Length; a++)
|
||||
{
|
||||
var aTableInfo = tbsfrom[a].Table;
|
||||
var aTbFrom = tbUnion[aTableInfo.Type];
|
||||
//适配 TDengine 超表
|
||||
//aTbFrom = TDengineTableNameAdapter(ref aTableInfo, ref aTbFrom, ref _commonUtils);
|
||||
sb.Append(_commonUtils.QuoteSqlName(aTbFrom)).Append(" ")
|
||||
.Append(_aliasRule?.Invoke(aTableInfo.Type, tbsfrom[a].Alias) ?? tbsfrom[a].Alias);
|
||||
if (tbsjoin.Length > 0)
|
||||
{
|
||||
//如果存在 join 查询,则处理 from t1, t2 改为 from t1 inner join t2 on 1 = 1
|
||||
for (var b = 1; b < tbsfrom.Length; b++)
|
||||
{
|
||||
var bTbFrom = tbUnion[tbsfrom[b].Table.Type];
|
||||
sb.Append(" \r\nLEFT JOIN ").Append(_commonUtils.QuoteSqlName(bTbFrom)).Append(" ")
|
||||
.Append(_aliasRule?.Invoke(tbsfrom[b].Table.Type, tbsfrom[b].Alias) ??
|
||||
tbsfrom[b].Alias);
|
||||
|
||||
if (string.IsNullOrEmpty(tbsfrom[b].NavigateCondition) &&
|
||||
string.IsNullOrEmpty(tbsfrom[b].On) &&
|
||||
string.IsNullOrEmpty(tbsfrom[b].Cascade) &&
|
||||
string.IsNullOrEmpty(tbsfrom[b].CascadeBefore)) sb.Append(" ON 1 = 1");
|
||||
else
|
||||
sb.Append(" ON ").Append(string.Join(" AND ", new[]
|
||||
{
|
||||
tbsfrom[b].CascadeBefore,
|
||||
tbsfrom[b].NavigateCondition ?? tbsfrom[b].On,
|
||||
tbsfrom[b].Cascade
|
||||
}.Where(sql => string.IsNullOrEmpty(sql) == false)));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a > 0 && !string.IsNullOrEmpty(tbsfrom[a].CascadeBefore))
|
||||
sbnav.Append(" AND ").Append(tbsfrom[a].CascadeBefore);
|
||||
if (!string.IsNullOrEmpty(tbsfrom[a].NavigateCondition))
|
||||
sbnav.Append(" AND (").Append(tbsfrom[a].NavigateCondition).Append(")");
|
||||
if (!string.IsNullOrEmpty(tbsfrom[a].On))
|
||||
sbnav.Append(" AND (").Append(tbsfrom[a].On).Append(")");
|
||||
if (a > 0 && !string.IsNullOrEmpty(tbsfrom[a].Cascade))
|
||||
sbnav.Append(" AND ").Append(tbsfrom[a].Cascade);
|
||||
}
|
||||
|
||||
if (a < tbsfrom.Length - 1) sb.Append(", ");
|
||||
}
|
||||
|
||||
foreach (var tb in tbsjoin)
|
||||
{
|
||||
switch (tb.Type)
|
||||
{
|
||||
case SelectTableInfoType.Parent:
|
||||
case SelectTableInfoType.RawJoin:
|
||||
continue;
|
||||
case SelectTableInfoType.LeftJoin:
|
||||
sb.Append(" \r\nLEFT JOIN ");
|
||||
break;
|
||||
case SelectTableInfoType.InnerJoin:
|
||||
sb.Append(" \r\nINNER JOIN ");
|
||||
break;
|
||||
case SelectTableInfoType.RightJoin:
|
||||
sb.Append(" \r\nRIGHT JOIN ");
|
||||
break;
|
||||
}
|
||||
|
||||
sb.Append(_commonUtils.QuoteSqlName(tbUnion[tb.Table.Type])).Append(" ")
|
||||
.Append(_aliasRule?.Invoke(tb.Table.Type, tb.Alias) ?? tb.Alias)
|
||||
.Append(" ON ").Append(string.Join(" AND ", new[]
|
||||
{
|
||||
tb.CascadeBefore,
|
||||
tb.On ?? tb.NavigateCondition,
|
||||
tb.Cascade
|
||||
}.Where(sql => string.IsNullOrEmpty(sql) == false)));
|
||||
if (!string.IsNullOrEmpty(tb.On) && !string.IsNullOrEmpty(tb.NavigateCondition))
|
||||
sbnav.Append(" AND (").Append(tb.NavigateCondition).Append(")");
|
||||
}
|
||||
|
||||
if (_join.Length > 0) sb.Append(_join);
|
||||
|
||||
if (!string.IsNullOrEmpty(_tables[0].CascadeBefore))
|
||||
sbnav.Append(" AND ").Append(_tables[0].CascadeBefore);
|
||||
sbnav.Append(_where);
|
||||
if (!string.IsNullOrEmpty(_tables[0].Cascade)) sbnav.Append(" AND ").Append(_tables[0].Cascade);
|
||||
|
||||
if (sbnav.Length > 0)
|
||||
{
|
||||
sb.Append(" \r\nWHERE ").Append(sbnav.Remove(0, 5));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_groupby) == false)
|
||||
{
|
||||
sb.Append(_groupby);
|
||||
if (string.IsNullOrEmpty(_having) == false)
|
||||
sb.Append(" \r\nHAVING ").Append(_having.Substring(5));
|
||||
}
|
||||
|
||||
sb.Append(_orderby);
|
||||
if (_skip > 0 || _limit > 0)
|
||||
sb.Append(" \r\nlimit ").Append(Math.Max(0, _skip)).Append(",").Append(_limit > 0 ? _limit : -1);
|
||||
|
||||
sbnav.Clear();
|
||||
if (tbUnionsGt0) sb.Append(") ftb");
|
||||
}
|
||||
|
||||
return sb.Append(_tosqlAppendContent).ToString();
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2> From<T2>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3> From<T2, T3>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3>(_orm, _commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4> From<T2, T3, T4>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4>(_orm, _commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5> From<T2, T3, T4, T5>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5>(_orm, _commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6> From<T2, T3, T4, T5, T6>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6>(_orm, _commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7> From<T2, T3, T4, T5, T6, T7>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7>(_orm, _commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression,
|
||||
null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>>
|
||||
exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression,
|
||||
null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
|
||||
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
|
||||
ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(_orm, _commonUtils,
|
||||
_commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
|
||||
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
|
||||
ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(_orm, _commonUtils,
|
||||
_commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>
|
||||
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
|
||||
ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(_orm, _commonUtils,
|
||||
_commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>
|
||||
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
|
||||
ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(_orm,
|
||||
_commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> From<T2, T3, T4, T5,
|
||||
T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
|
||||
ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(_orm,
|
||||
_commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> From<T2, T3, T4,
|
||||
T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
|
||||
Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16
|
||||
, ISelectFromExpression<T1>>> exp)
|
||||
{
|
||||
this.InternalFrom(exp);
|
||||
var ret = new TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(_orm,
|
||||
_commonUtils, _commonExpression, null);
|
||||
TDengineSelect<T1>.CopyData(this, ret, exp?.Parameters);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _commonExpression, _select,
|
||||
_distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having,
|
||||
_orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent,
|
||||
_whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T2 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3>
|
||||
where T2 : class where T3 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4>
|
||||
where T2 : class where T3 : class where T4 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5>
|
||||
where T2 : class where T3 : class where T4 : class where T5 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5,
|
||||
T6> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4,
|
||||
T5, T6, T7> where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3,
|
||||
T4, T5, T6, T7, T8> where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2,
|
||||
T3, T4, T5, T6, T7, T8, T9> where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
where T9 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1,
|
||||
T2, T3, T4, T5, T6, T7, T8, T9, T10> where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
where T9 : class
|
||||
where T10 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : FreeSql.Internal.CommonProvider.
|
||||
Select11Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
where T9 : class
|
||||
where T10 : class
|
||||
where T11 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : FreeSql.Internal.CommonProvider.
|
||||
Select12Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
where T9 : class
|
||||
where T10 : class
|
||||
where T11 : class
|
||||
where T12 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : FreeSql.Internal.CommonProvider.
|
||||
Select13Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
where T9 : class
|
||||
where T10 : class
|
||||
where T11 : class
|
||||
where T12 : class
|
||||
where T13 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : FreeSql.Internal.CommonProvider.
|
||||
Select14Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
where T9 : class
|
||||
where T10 : class
|
||||
where T11 : class
|
||||
where T12 : class
|
||||
where T13 : class
|
||||
where T14 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : FreeSql.Internal.
|
||||
CommonProvider.Select15Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>
|
||||
where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
where T9 : class
|
||||
where T10 : class
|
||||
where T11 : class
|
||||
where T12 : class
|
||||
where T13 : class
|
||||
where T14 : class
|
||||
where T15 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class TDengineSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> : FreeSql.Internal.
|
||||
CommonProvider.Select16Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>
|
||||
where T2 : class
|
||||
where T3 : class
|
||||
where T4 : class
|
||||
where T5 : class
|
||||
where T6 : class
|
||||
where T7 : class
|
||||
where T8 : class
|
||||
where T9 : class
|
||||
where T10 : class
|
||||
where T11 : class
|
||||
where T12 : class
|
||||
where T13 : class
|
||||
where T14 : class
|
||||
where T15 : class
|
||||
where T16 : class
|
||||
{
|
||||
public TDengineSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere)
|
||||
: base(orm, commonUtils, commonExpression, dywhere)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToSql(string field = null) => TDengineSelect<T1>.ToSqlStatic(_commonUtils,
|
||||
_commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where,
|
||||
_groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule,
|
||||
_tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql.TDengine.Describes
|
||||
{
|
||||
internal class SuperTableDescribe
|
||||
{
|
||||
/// <summary>
|
||||
/// 超级表Type
|
||||
/// </summary>
|
||||
public Type SuperTableType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 超级表名称
|
||||
/// </summary>
|
||||
public string SuperTableName { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0;net451;net45;</TargetFrameworks>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>FreeSql;ncc;YeXiangQin;Daily</Authors>
|
||||
<Description>FreeSql 数据库实现,基于TDengine.Connector</Description>
|
||||
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageTags>FreeSql;ORM;TDengine;TaoS</PackageTags>
|
||||
<PackageId>$(AssemblyName)</PackageId>
|
||||
<PackageIcon>logo.png</PackageIcon>
|
||||
<Title>$(AssemblyName)</Title>
|
||||
<IsPackable>true</IsPackable>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<DelaySign>false</DelaySign>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="../../readme.md" Pack="true" PackagePath="\" />
|
||||
<None Include="../../logo.png" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="TDengine.Connector" Version="3.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
111
Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineAdo.cs
Normal file
111
Providers/FreeSql.Provider.TDengine/TDengineAdo/TDengineAdo.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using FreeSql.Internal.Model;
|
||||
using FreeSql.Internal.ObjectPool;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using TDengine.Data.Client;
|
||||
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineAdo : AdoProvider
|
||||
{
|
||||
public TDengineAdo() : base(DataType.TDengine, null, null) { }
|
||||
|
||||
public TDengineAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings,
|
||||
Func<DbConnection> connectionFactory) : base(DataType.TDengine, masterConnectionString,
|
||||
slaveConnectionStrings)
|
||||
{
|
||||
base._util = util;
|
||||
if (connectionFactory != null)
|
||||
{
|
||||
var pool = new DbConnectionPool(DataType.TDengine, connectionFactory);
|
||||
ConnectionString = pool.TestConnection?.ConnectionString;
|
||||
MasterPool = pool;
|
||||
return;
|
||||
}
|
||||
|
||||
var isAdoPool = masterConnectionString?.StartsWith("AdoConnectionPool,") ?? false;
|
||||
if (isAdoPool) masterConnectionString = masterConnectionString.Substring("AdoConnectionPool,".Length);
|
||||
if (!string.IsNullOrEmpty(masterConnectionString))
|
||||
MasterPool = isAdoPool
|
||||
? new DbConnectionStringPool(base.DataType, CoreErrorStrings.S_MasterDatabase,
|
||||
() => new TDengineConnection(masterConnectionString)) as IObjectPool<DbConnection>
|
||||
: new TDengineConnectionPool(CoreErrorStrings.S_MasterDatabase, masterConnectionString, null, null);
|
||||
|
||||
slaveConnectionStrings?.ToList().ForEach(slaveConnectionString =>
|
||||
{
|
||||
var slavePool = isAdoPool
|
||||
? new DbConnectionStringPool(base.DataType, $"{CoreErrorStrings.S_SlaveDatabase}{SlavePools.Count + 1}",
|
||||
() => new TDengineConnection(slaveConnectionString)) as IObjectPool<DbConnection>
|
||||
: new TDengineConnectionPool($"{CoreErrorStrings.S_SlaveDatabase}{SlavePools.Count + 1}",
|
||||
slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables),
|
||||
() => Interlocked.Increment(ref slaveUnavailables));
|
||||
SlavePools.Add(slavePool);
|
||||
});
|
||||
}
|
||||
|
||||
public override object AddslashesProcessParam(object param, Type mapType, ColumnInfo mapColumn)
|
||||
{
|
||||
if (param == null) return "NULL";
|
||||
|
||||
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
|
||||
param = Utils.GetDataReaderValue(mapType, param);
|
||||
|
||||
if (param is bool paramBool)
|
||||
return paramBool ? "true" : "false";
|
||||
else if (param is string paramStr)
|
||||
return string.Concat("'", paramStr?.Replace("'", "\\'"), "'");
|
||||
else if (param is char)
|
||||
return string.Concat("'", param.ToString()?.Replace("'", "''").Replace('\0', ' '), "'");
|
||||
else if (param is Enum @enum)
|
||||
return AddslashesTypeHandler(@enum.GetType(), @enum) ?? @enum.ToInt64();
|
||||
else if (decimal.TryParse(string.Concat(param), out _))
|
||||
return param;
|
||||
|
||||
else if (param is DateTime time)
|
||||
return AddslashesTypeHandler(typeof(DateTime), time) ??
|
||||
string.Concat("'", time.ToString("yyyy-MM-dd HH:mm:ss.fffffff"), "'");
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
|
||||
else if (param is DateOnly dateOnly)
|
||||
return AddslashesTypeHandler(typeof(DateOnly), dateOnly) ??
|
||||
string.Concat("'", dateOnly.ToString("yyyy-MM-dd"), "'");
|
||||
else if (param is TimeOnly timeOnly)
|
||||
{
|
||||
return $"'{timeOnly.Hour}:{timeOnly.Minute}:{timeOnly.Second}'";
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (param is TimeSpan timeSpan)
|
||||
{
|
||||
return $"'{Math.Floor(timeSpan.TotalHours)}:{timeSpan.Minutes}:{timeSpan.Seconds}'";
|
||||
}
|
||||
else if (param is byte[] bytes)
|
||||
return $"0x{CommonUtils.BytesSqlRaw(bytes)}";
|
||||
|
||||
else if (param is IEnumerable)
|
||||
return AddslashesIEnumerable(param, mapType, mapColumn);
|
||||
|
||||
return string.Concat("'", param.ToString()?.Replace("\\", "\\\\").Replace("'", "\\'"), "'");
|
||||
}
|
||||
|
||||
public override DbCommand CreateCommand()
|
||||
{
|
||||
return new TDengineCommand();
|
||||
}
|
||||
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj) =>
|
||||
_util.GetDbParamtersByObject(sql, obj);
|
||||
|
||||
public override void ReturnConnection(IObjectPool<DbConnection> pool, Object<DbConnection> conn, Exception ex)
|
||||
{
|
||||
if (pool is TDengineConnectionPool rawPool) rawPool.Return(conn, ex);
|
||||
else pool.Return(conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
using FreeSql.Internal.ObjectPool;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TDengine.Data.Client;
|
||||
using TDengine.Driver;
|
||||
using TDengine.Driver.Client;
|
||||
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineConnectionPool : ObjectPool<DbConnection>
|
||||
{
|
||||
internal Action AvailableHandler;
|
||||
|
||||
internal Action UnavailableHandler;
|
||||
|
||||
public TDengineConnectionPool(string name, string connectionString, Action availableHandler,
|
||||
Action unavailableHandler) : base(null)
|
||||
{
|
||||
this.AvailableHandler = availableHandler;
|
||||
this.UnavailableHandler = unavailableHandler;
|
||||
var policy = new TDengineConnectionPoolPolicy
|
||||
{
|
||||
InternalPool = this,
|
||||
Name = name
|
||||
};
|
||||
this.Policy = policy;
|
||||
policy.ConnectionString = connectionString;
|
||||
}
|
||||
|
||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||
{
|
||||
base.Return(obj, isRecreate);
|
||||
}
|
||||
}
|
||||
|
||||
internal class TDengineConnectionPoolPolicy : IPolicy<DbConnection>
|
||||
{
|
||||
internal TDengineConnectionPool InternalPool;
|
||||
public string Name { get; set; } = $"TDengine Connection {CoreErrorStrings.S_ObjectPool}";
|
||||
public int PoolSize { get; set; } = 50;
|
||||
public TimeSpan SyncGetTimeout { get; set; } = TimeSpan.FromSeconds(10);
|
||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||
public int AsyncGetCapacity { get; set; } = 10000;
|
||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||
public int CheckAvailableInterval { get; set; } = 2;
|
||||
public int Weight { get; set; } = 1;
|
||||
|
||||
static readonly ConcurrentDictionary<string, int> DicConnStrIncr =
|
||||
new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||
|
||||
private string _connectionString;
|
||||
|
||||
public string ConnectionString
|
||||
{
|
||||
get => _connectionString;
|
||||
set
|
||||
{
|
||||
_connectionString = value ?? "";
|
||||
|
||||
var minPoolSize = 0;
|
||||
var pattern = @"Min(imum)?\s*pool\s*size\s*=\s*(\d+)";
|
||||
var m = Regex.Match(_connectionString, pattern, RegexOptions.IgnoreCase);
|
||||
if (m.Success)
|
||||
{
|
||||
minPoolSize = int.Parse(m.Groups[2].Value);
|
||||
_connectionString = Regex.Replace(_connectionString, pattern, "", RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
pattern = @"Max(imum)?\s*pool\s*size\s*=\s*(\d+)";
|
||||
m = Regex.Match(_connectionString, pattern, RegexOptions.IgnoreCase);
|
||||
if (m.Success == false || int.TryParse(m.Groups[2].Value, out var poolsize) == false || poolsize <= 0)
|
||||
poolsize = Math.Max(50, minPoolSize);
|
||||
var connStrIncr =
|
||||
DicConnStrIncr.AddOrUpdate(_connectionString, 1, (oldkey, oldval) => Math.Min(5, oldval + 1));
|
||||
PoolSize = poolsize + connStrIncr;
|
||||
_connectionString = m.Success
|
||||
? Regex.Replace(_connectionString, pattern, $"Maximum pool size={PoolSize}",
|
||||
RegexOptions.IgnoreCase)
|
||||
: $"{_connectionString};Maximum pool size={PoolSize}";
|
||||
|
||||
pattern = @"Connection\s*LifeTime\s*=\s*(\d+)";
|
||||
m = Regex.Match(_connectionString, pattern, RegexOptions.IgnoreCase);
|
||||
if (m.Success)
|
||||
{
|
||||
IdleTimeout = TimeSpan.FromSeconds(int.Parse(m.Groups[1].Value));
|
||||
_connectionString = Regex.Replace(_connectionString, pattern, "", RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
FreeSql.Internal.CommonUtils.PrevReheatConnectionPool(InternalPool, minPoolSize);
|
||||
}
|
||||
}
|
||||
|
||||
public DbConnection OnCreate()
|
||||
{
|
||||
var conn = new TDengineConnection(_connectionString);
|
||||
return conn;
|
||||
}
|
||||
|
||||
public void OnDestroy(DbConnection obj)
|
||||
{
|
||||
if (obj.State != ConnectionState.Closed) obj.Close();
|
||||
obj.Dispose();
|
||||
}
|
||||
|
||||
public void OnGetTimeout()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnGet(Object<DbConnection> obj)
|
||||
{
|
||||
if (InternalPool.IsAvailable)
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
InternalPool.SetUnavailable(new Exception(CoreErrorStrings.S_ConnectionStringError),
|
||||
obj.LastGetTimeCopy);
|
||||
throw new Exception(CoreErrorStrings.S_ConnectionStringError_Check(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open ||
|
||||
DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
obj.Value.Open();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (InternalPool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
|
||||
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if net40
|
||||
#else
|
||||
public async Task OnGetAsync(Object<DbConnection> obj)
|
||||
{
|
||||
if (InternalPool.IsAvailable)
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
InternalPool.SetUnavailable(new Exception(CoreErrorStrings.S_ConnectionStringError),
|
||||
obj.LastGetTimeCopy);
|
||||
throw new Exception(CoreErrorStrings.S_ConnectionStringError_Check(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open ||
|
||||
DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 &&
|
||||
(await obj.Value.PingAsync()) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
await obj.Value.OpenAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (InternalPool.SetUnavailable(ex, obj.LastGetTimeCopy) == true)
|
||||
throw new Exception($"【{this.Name}】Block access and wait for recovery: {ex.Message}");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public void OnReturn(Object<DbConnection> obj)
|
||||
{
|
||||
}
|
||||
|
||||
public bool OnCheckAvailable(Object<DbConnection> obj)
|
||||
{
|
||||
if (obj.Value == null) return false;
|
||||
if (obj.Value.State == ConnectionState.Closed) obj.Value.Open();
|
||||
return obj.Value.Ping(true);
|
||||
}
|
||||
|
||||
public void OnAvailable()
|
||||
{
|
||||
InternalPool.AvailableHandler?.Invoke();
|
||||
}
|
||||
|
||||
public void OnUnavailable()
|
||||
{
|
||||
InternalPool.UnavailableHandler?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
static class DbConnectionExtensions
|
||||
{
|
||||
static DbCommand PingCommand(DbConnection conn)
|
||||
{
|
||||
var cmd = conn.CreateCommand();
|
||||
cmd.CommandTimeout = 5;
|
||||
cmd.CommandText = "select 1";
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public static bool Ping(this DbConnection that, bool isThrow = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
PingCommand(that).ExecuteNonQuery();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (that.State != ConnectionState.Closed)
|
||||
try
|
||||
{
|
||||
that.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (isThrow) throw;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#if net40
|
||||
#else
|
||||
public static async Task<bool> PingAsync(this DbConnection that, bool isThrow = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
await PingCommand(that).ExecuteNonQueryAsync();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (that.State != ConnectionState.Closed)
|
||||
try
|
||||
{
|
||||
that.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (isThrow) throw;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
308
Providers/FreeSql.Provider.TDengine/TDengineCodeFirst.cs
Normal file
308
Providers/FreeSql.Provider.TDengine/TDengineCodeFirst.cs
Normal file
@@ -0,0 +1,308 @@
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using FreeSql.DataAnnotations;
|
||||
using System.Reflection;
|
||||
using FreeSql.Internal.ObjectPool;
|
||||
using FreeSql.Provider.TDengine.Attributes;
|
||||
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineCodeFirst : Internal.CommonProvider.CodeFirstProvider
|
||||
{
|
||||
public TDengineCodeFirst(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) : base(orm,
|
||||
commonUtils, commonExpression)
|
||||
{
|
||||
}
|
||||
|
||||
static readonly Dictionary<string, CsToDb<DbType>> DicCsToDb = new Dictionary<string, CsToDb<DbType>>()
|
||||
{
|
||||
{ typeof(bool).FullName, CsToDb.New(DbType.Boolean, "BOOL", "BOOL", null, false, null) },
|
||||
{ typeof(bool?).FullName, CsToDb.New(DbType.Boolean, "BOOL", "BOOL", null, true, null) },
|
||||
{ typeof(DateTime).FullName, CsToDb.New(DbType.DateTime, "TIMESTAMP", "TIMESTAMP", null, false, null) },
|
||||
{ typeof(DateTime?).FullName, CsToDb.New(DbType.DateTime, "TIMESTAMP", "TIMESTAMP", null, true, null) },
|
||||
{ typeof(TimeSpan).FullName, CsToDb.New(DbType.DateTime, "TIMESTAMP", "TIMESTAMP", null, false, null) },
|
||||
{ typeof(TimeSpan?).FullName, CsToDb.New(DbType.DateTime, "TIMESTAMP", "TIMESTAMP", null, true, null) },
|
||||
{ typeof(short).FullName, CsToDb.New(DbType.Int16, "SMALLINT", "SMALLINT", null, false, 0) },
|
||||
{ typeof(short?).FullName, CsToDb.New(DbType.Int16, "SMALLINT", "SMALLINT", null, true, null) },
|
||||
{ typeof(int).FullName, CsToDb.New(DbType.Int32, "INT", "INT", null, false, 0) },
|
||||
{ typeof(int?).FullName, CsToDb.New(DbType.Int32, "INT", "INT", null, true, null) },
|
||||
{ typeof(sbyte).FullName, CsToDb.New(DbType.SByte, "TINYINT", "TINYINT", null, false, 0) },
|
||||
{ typeof(sbyte?).FullName, CsToDb.New(DbType.SByte, "TINYINT", "TINYINT", null, true, null) },
|
||||
{ typeof(long).FullName, CsToDb.New(DbType.Int64, "BIGINT", "BIGINT", null, false, 0) },
|
||||
{ typeof(long?).FullName, CsToDb.New(DbType.Int64, "BIGINT", "BIGINT", null, true, null) },
|
||||
{ typeof(byte).FullName, CsToDb.New(DbType.Byte, "TINYINT UNSIGNED", "TINYINT UNSIGNED", null, false, 0) },
|
||||
{
|
||||
typeof(byte?).FullName,
|
||||
CsToDb.New(DbType.Byte, "TINYINT UNSIGNED", "TINYINT UNSIGNED", null, true, null)
|
||||
},
|
||||
{
|
||||
typeof(ushort).FullName,
|
||||
CsToDb.New(DbType.UInt16, "SMALLINT UNSIGNED", "SMALLINT UNSIGNED", null, false, 0)
|
||||
},
|
||||
{
|
||||
typeof(ushort?).FullName,
|
||||
CsToDb.New(DbType.UInt16, "SMALLINT UNSIGNED", "SMALLINT UNSIGNED", null, true, null)
|
||||
},
|
||||
{ typeof(uint).FullName, CsToDb.New(DbType.UInt32, "INT UNSIGNED", "INT UNSIGNED", null, false, 0) },
|
||||
{ typeof(uint?).FullName, CsToDb.New(DbType.UInt32, "INT UNSIGNED", "INT UNSIGNED", null, true, null) },
|
||||
{ typeof(ulong).FullName, CsToDb.New(DbType.UInt64, "BIGINT UNSIGNED", "BIGINT UNSIGNED", null, false, 0) },
|
||||
{
|
||||
typeof(ulong?).FullName,
|
||||
CsToDb.New(DbType.UInt64, "BIGINT UNSIGNED", "BIGINT UNSIGNED", null, true, null)
|
||||
},
|
||||
{ typeof(float).FullName, CsToDb.New(DbType.Single, "FLOAT", "FLOAT", null, false, 0) },
|
||||
{ typeof(float?).FullName, CsToDb.New(DbType.Single, "FLOAT", "FLOAT", null, true, null) },
|
||||
{ typeof(double).FullName, CsToDb.New(DbType.Double, "DOUBLE", "DOUBLE", null, false, 0) },
|
||||
{ typeof(double?).FullName, CsToDb.New(DbType.Double, "DOUBLE", "DOUBLE", null, true, null) },
|
||||
{ typeof(string).FullName, CsToDb.New(DbType.String, "NCHAR", "NCHAR(255)", null, false, 0) },
|
||||
};
|
||||
|
||||
public override DbInfoResult GetDbInfo(Type type)
|
||||
{
|
||||
if (DicCsToDb.TryGetValue(type.FullName, out var trydc))
|
||||
return new DbInfoResult((int)trydc.type, trydc.dbtype, trydc.dbtypeFull, trydc.isnullable,
|
||||
trydc.defaultValue);
|
||||
if (type.IsArray) return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override string GetComparisonDDLStatements(params TypeSchemaAndName[] objects)
|
||||
{
|
||||
Object<DbConnection> conn = null;
|
||||
string database = null;
|
||||
var sb = new StringBuilder();
|
||||
try
|
||||
{
|
||||
conn = _orm.Ado.MasterPool.Get(TimeSpan.FromSeconds(5));
|
||||
database = conn.Value.Database;
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
if (sb.Length > 0) sb.Append(Environment.NewLine);
|
||||
var tb = obj.tableSchema;
|
||||
if (tb == null)
|
||||
throw new Exception(CoreErrorStrings.S_Type_IsNot_Migrable(obj.tableSchema.Type.FullName));
|
||||
if (tb.Columns.Any() == false)
|
||||
throw new Exception(
|
||||
CoreErrorStrings.S_Type_IsNot_Migrable_0Attributes(obj.tableSchema.Type.FullName));
|
||||
|
||||
var tbName = _commonUtils.SplitTableName(tb.DbName).First();
|
||||
|
||||
tbName = _commonUtils.QuoteSqlName(database, tbName);
|
||||
|
||||
if (!TryTableExists(tbName))
|
||||
{
|
||||
TableHandle(ref tb, ref database, tb.Type, ref sb, tbName);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(database) == false)
|
||||
conn.Value.ChangeDatabase(database);
|
||||
_orm.Ado.MasterPool.Return(conn);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_orm.Ado.MasterPool.Return(conn, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var ddl = sb.Length == 0 ? null : sb.ToString();
|
||||
return ddl;
|
||||
}
|
||||
|
||||
private void CreateColumns(ref TableInfo tb, ref StringBuilder sb)
|
||||
{
|
||||
//创建表
|
||||
foreach (var columnInfo in tb.ColumnsByPosition.Where(c =>
|
||||
!c.Table.Properties[c.CsName].IsDefined(typeof(TDengineTagAttribute))))
|
||||
{
|
||||
sb.Append($" {Environment.NewLine} ").Append(_commonUtils.QuoteSqlName(columnInfo.Attribute.Name))
|
||||
.Append(" ")
|
||||
.Append(columnInfo.Attribute.DbType);
|
||||
sb.Append(",");
|
||||
}
|
||||
|
||||
sb.Remove(sb.Length - 1, 1).Append($"{Environment.NewLine})");
|
||||
}
|
||||
|
||||
private void TableHandle(ref TableInfo tb, ref string database, Type type, ref StringBuilder sb, string tbName)
|
||||
{
|
||||
//判断是否超级表
|
||||
var subTableAttribute = type.GetCustomAttribute<TDengineSubTableAttribute>();
|
||||
|
||||
//要创建表的为子表
|
||||
if (subTableAttribute != null)
|
||||
{
|
||||
if (_commonUtils is TDengineUtils utils)
|
||||
{
|
||||
var superTableDescribe = utils.GetSuperTableDescribe(type);
|
||||
|
||||
if (superTableDescribe == null) return;
|
||||
|
||||
var superTableName = _commonUtils.QuoteSqlName(database, superTableDescribe.SuperTableName);
|
||||
var superTableInfo = GetTableByEntity(superTableDescribe.SuperTableType);
|
||||
|
||||
//判断超表是否存在
|
||||
if (!TryTableExists(superTableName))
|
||||
{
|
||||
//先创建超级表
|
||||
CreateSuperTable(ref superTableInfo, ref sb, superTableName);
|
||||
_orm.Ado.ExecuteNonQuery(sb.ToString());
|
||||
sb = sb.Clear();
|
||||
}
|
||||
|
||||
var subTableName = _commonUtils.QuoteSqlName(database, subTableAttribute.Name);
|
||||
|
||||
//创建子表
|
||||
CreateSubTable(ref tb, ref sb, superTableName, subTableName, ref superTableInfo);
|
||||
}
|
||||
}
|
||||
//要创建的为超级表
|
||||
else if (type.IsDefined(typeof(TDengineSuperTableAttribute)))
|
||||
{
|
||||
var superTableAttribute = type.GetCustomAttribute<TDengineSuperTableAttribute>();
|
||||
if (superTableAttribute == null) return;
|
||||
tbName = _commonUtils.QuoteSqlName(database, superTableAttribute.Name);
|
||||
CreateSuperTable(ref tb, ref sb, tbName);
|
||||
}
|
||||
//创建普通表
|
||||
else
|
||||
{
|
||||
CreateNormalTable(ref tb, ref sb, tbName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建子表
|
||||
/// </summary>
|
||||
/// <param name="childTableInfo"></param>
|
||||
/// <param name="sb"></param>
|
||||
/// <param name="superTableName"></param>
|
||||
private void CreateSubTable(ref TableInfo childTableInfo, ref StringBuilder sb, string superTableName,
|
||||
string subTableName, ref TableInfo
|
||||
superTableInfo)
|
||||
{
|
||||
sb.Append($"CREATE TABLE {subTableName}{Environment.NewLine}");
|
||||
sb.Append($"USING {superTableName} (");
|
||||
|
||||
var tagCols = superTableInfo.ColumnsByPosition.Where(c =>
|
||||
c.Table.Properties[c.CsName].IsDefined(typeof(TDengineTagAttribute))).ToArray();
|
||||
|
||||
var tagValues = new List<object>(tagCols.Count());
|
||||
|
||||
var tableInstance = Activator.CreateInstance(childTableInfo.Type);
|
||||
|
||||
foreach (var columnInfo in tagCols)
|
||||
{
|
||||
var tagValue = childTableInfo.Properties[columnInfo.CsName].GetValue(tableInstance);
|
||||
tagValues.Add(tagValue);
|
||||
sb.Append($" {Environment.NewLine} ").Append(_commonUtils.QuoteSqlName(columnInfo.Attribute.Name))
|
||||
.Append(",");
|
||||
}
|
||||
|
||||
sb.Remove(sb.Length - 1, 1).Append($"{Environment.NewLine}) TAGS (");
|
||||
|
||||
foreach (var tagValue in tagValues)
|
||||
{
|
||||
sb.Append($" {Environment.NewLine} ").Append(HandleTagValue(tagValue)).Append(",");
|
||||
}
|
||||
|
||||
sb.Remove(sb.Length - 1, 1).Append($"{Environment.NewLine});");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建超级表
|
||||
/// </summary>
|
||||
/// <param name="tb"></param>
|
||||
/// <param name="sb"></param>
|
||||
/// <param name="superTableName"></param>
|
||||
private void CreateSuperTable(ref TableInfo tb, ref StringBuilder sb, string superTableName)
|
||||
{
|
||||
sb.Append($"CREATE STABLE {superTableName} (");
|
||||
CreateColumns(ref tb, ref sb);
|
||||
sb.Append($" TAGS (");
|
||||
|
||||
var columInfos = tb.ColumnsByPosition.Where(c =>
|
||||
c.Table.Properties[c.CsName].IsDefined(typeof(TDengineTagAttribute)));
|
||||
|
||||
foreach (var columnInfo in columInfos)
|
||||
{
|
||||
sb.Append($" {Environment.NewLine} ").Append(_commonUtils.QuoteSqlName(columnInfo.Attribute.Name))
|
||||
.Append(" ")
|
||||
.Append(columnInfo.Attribute.DbType);
|
||||
sb.Append(",");
|
||||
}
|
||||
|
||||
sb.Remove(sb.Length - 1, 1).Append($"{Environment.NewLine});");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建普通表
|
||||
/// </summary>
|
||||
/// <param name="tb"></param>
|
||||
/// <param name="sb"></param>
|
||||
/// <param name="normalTableName"></param>
|
||||
private void CreateNormalTable(ref TableInfo tb, ref StringBuilder sb, string normalTableName)
|
||||
{
|
||||
sb.Append($"CREATE TABLE {normalTableName} (");
|
||||
CreateColumns(ref tb, ref sb);
|
||||
foreach (var columnInfo in tb.ColumnsByPosition.Where(c =>
|
||||
c.Table.Properties[c.CsName].IsDefined(typeof(TDengineTagAttribute))))
|
||||
{
|
||||
sb.Append($" {Environment.NewLine} ").Append(_commonUtils.QuoteSqlName(columnInfo.Attribute.Name))
|
||||
.Append(" ")
|
||||
.Append(columnInfo.Attribute.DbType);
|
||||
sb.Append(",");
|
||||
}
|
||||
|
||||
sb.Remove(sb.Length - 1, 1).Append(");");
|
||||
}
|
||||
|
||||
private bool TryTableExists(string tbName)
|
||||
{
|
||||
var flag = true;
|
||||
try
|
||||
{
|
||||
var executeScalar = _orm.Ado.ExecuteScalar(CommandType.Text,
|
||||
$"DESCRIBE {tbName}");
|
||||
|
||||
if (executeScalar == null)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.Message.Contains("Table does not exist"))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
private object HandleTagValue(object tagValue)
|
||||
{
|
||||
if (tagValue is DateTime || tagValue is string)
|
||||
{
|
||||
return $"\"{tagValue}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
return tagValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
134
Providers/FreeSql.Provider.TDengine/TDengineDbFirst.cs
Normal file
134
Providers/FreeSql.Provider.TDengine/TDengineDbFirst.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using FreeSql.DatabaseModel;
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
public class TDengineDbFirst : IDbFirst
|
||||
{
|
||||
IFreeSql _orm;
|
||||
protected CommonUtils _commonUtils;
|
||||
protected CommonExpression _commonExpression;
|
||||
|
||||
public TDengineDbFirst(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression)
|
||||
{
|
||||
_orm = orm;
|
||||
_commonUtils = commonUtils;
|
||||
_commonExpression = commonExpression;
|
||||
}
|
||||
|
||||
public List<string> GetDatabases()
|
||||
{
|
||||
var sql = @"SHOW DATABASES;";
|
||||
var ds = _orm.Ado.Query<string>(sql);
|
||||
return ds;
|
||||
}
|
||||
|
||||
public List<DbTableInfo> GetTablesByDatabase(params string[] database)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
}
|
||||
|
||||
public DbTableInfo GetTableByName(string name, bool ignoreCase = true)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
}
|
||||
|
||||
public bool ExistsTable(string name, bool ignoreCase = true)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("select count(1) from information_schema.ins_tables where ");
|
||||
var where = ignoreCase ? $"LOWER(table_name) = LOWER('{name}')" : $"table_name = '{name}'";
|
||||
sb.Append(where);
|
||||
var sql = sb.ToString();
|
||||
var executeScalar = _orm.Ado.ExecuteScalar(sql);
|
||||
var result = Convert.ToInt32(executeScalar);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
public int GetDbType(DbColumnInfo column) => (int)GetTDengineDbType(column);
|
||||
|
||||
DbType GetTDengineDbType(DbColumnInfo column)
|
||||
{
|
||||
switch (column.DbTypeText)
|
||||
{
|
||||
case "DOUBLE": return DbType.Double;
|
||||
case "FLOAT": return DbType.Single;
|
||||
case "TIMESTAMP": return DbType.DateTime;
|
||||
case "BOOL": return DbType.Boolean;
|
||||
case "NCHAR": return DbType.String;
|
||||
case "TINYINT UNSIGNED": return DbType.Byte;
|
||||
case "SMALLINT UNSIGNED": return DbType.UInt16;
|
||||
case "INT UNSIGNED": return DbType.UInt32;
|
||||
case "BIGINT UNSIGNED": return DbType.UInt64;
|
||||
case "SMALLINT": return DbType.Int16;
|
||||
case "INT": return DbType.Int32;
|
||||
case "BIGINT": return DbType.Int64;
|
||||
default: return DbType.String;
|
||||
}
|
||||
}
|
||||
|
||||
static readonly Dictionary<int, DbToCs> _dicDbToCs = new Dictionary<int, DbToCs>()
|
||||
{
|
||||
};
|
||||
|
||||
public string GetCsConvert(DbColumnInfo column)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
//return _dicDbToCs.TryGetValue(column.DbType, out var trydc)
|
||||
// ? (column.IsNullable ? trydc.csConvert : trydc.csConvert.Replace("?", ""))
|
||||
// : null;
|
||||
}
|
||||
|
||||
public string GetCsParse(DbColumnInfo column)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
//return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csParse : null;
|
||||
}
|
||||
|
||||
public string GetCsStringify(DbColumnInfo column)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
//return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csStringify : null;
|
||||
}
|
||||
|
||||
|
||||
public string GetCsType(DbColumnInfo column)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
//return _dicDbToCs.TryGetValue(column.DbType, out var trydc)
|
||||
// ? (column.IsNullable ? trydc.csType : trydc.csType.Replace("?", ""))
|
||||
// : null;
|
||||
}
|
||||
|
||||
public Type GetCsTypeInfo(DbColumnInfo column)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
//return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csTypeInfo : null;
|
||||
}
|
||||
|
||||
public string GetCsTypeValue(DbColumnInfo column)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
//return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.csTypeValue : null;
|
||||
}
|
||||
|
||||
public string GetDataReaderMethod(DbColumnInfo column)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
//return _dicDbToCs.TryGetValue(column.DbType, out var trydc) ? trydc.dataReaderMethod : null;
|
||||
}
|
||||
|
||||
public List<DbEnumInfo> GetEnumsByDatabase(params string[] database)
|
||||
{
|
||||
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
}
|
||||
}
|
||||
}
|
||||
584
Providers/FreeSql.Provider.TDengine/TDengineExpression.cs
Normal file
584
Providers/FreeSql.Provider.TDengine/TDengineExpression.cs
Normal file
@@ -0,0 +1,584 @@
|
||||
using FreeSql.Internal;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text;
|
||||
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineExpression : CommonExpression
|
||||
{
|
||||
public TDengineExpression(CommonUtils common) : base(common)
|
||||
{
|
||||
}
|
||||
public override string ExpressionLambdaToSqlOther(Expression exp, ExpTSC tsc)
|
||||
{
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
|
||||
switch (exp.NodeType)
|
||||
{
|
||||
case ExpressionType.ArrayLength:
|
||||
var arrOper = (exp as UnaryExpression)?.Operand;
|
||||
var arrOperExp = getExp(arrOper);
|
||||
if (arrOperExp.StartsWith("(") || arrOperExp.EndsWith(")")) return $"len([{arrOperExp.TrimStart('(').TrimEnd(')')}])";
|
||||
if (arrOper.Type == typeof(byte[])) return $"octet_length({getExp(arrOper)})";
|
||||
return $"case when {arrOperExp} is null then 0 else len({arrOperExp}) end";
|
||||
case ExpressionType.Convert:
|
||||
var operandExp = (exp as UnaryExpression)?.Operand;
|
||||
var gentype = exp.Type.NullableTypeOrThis();
|
||||
if (gentype != operandExp.Type.NullableTypeOrThis())
|
||||
{
|
||||
switch (exp.Type.NullableTypeOrThis().ToString())
|
||||
{
|
||||
case "System.Boolean": return $"({getExp(operandExp)} not in ('0','false'))";
|
||||
case "System.Byte": return $"cast({getExp(operandExp)} as utinyint)";
|
||||
case "System.Char": return $"substr(cast({getExp(operandExp)} as char), 1, 1)";
|
||||
case "System.DateTime": return ExpressionConstDateTime(operandExp) ?? $"cast({getExp(operandExp)} as timestamp)";
|
||||
case "System.Decimal": return $"cast({getExp(operandExp)} as decimal(36,18))";
|
||||
case "System.Double": return $"cast({getExp(operandExp)} as double)";
|
||||
case "System.Int16": return $"cast({getExp(operandExp)} as smallint)";
|
||||
case "System.Int32": return $"cast({getExp(operandExp)} as integer)";
|
||||
case "System.Int64": return $"cast({getExp(operandExp)} as bigint)";
|
||||
case "System.SByte": return $"cast({getExp(operandExp)} as tinyint)";
|
||||
case "System.Single": return $"cast({getExp(operandExp)} as float)";
|
||||
case "System.String": return $"cast({getExp(operandExp)} as text)";
|
||||
case "System.UInt16": return $"cast({getExp(operandExp)} as usmallint)";
|
||||
case "System.UInt32": return $"cast({getExp(operandExp)} as uinteger)";
|
||||
case "System.UInt64": return $"cast({getExp(operandExp)} as ubigint)";
|
||||
case "System.Guid": return $"cast({getExp(operandExp)} as uuid)";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ExpressionType.Call:
|
||||
var callExp = exp as MethodCallExpression;
|
||||
|
||||
switch (callExp.Method.Name)
|
||||
{
|
||||
case "Parse":
|
||||
case "TryParse":
|
||||
switch (callExp.Method.DeclaringType.NullableTypeOrThis().ToString())
|
||||
{
|
||||
case "System.Boolean": return $"({getExp(callExp.Arguments[0])} not in ('0','false'))";
|
||||
case "System.Byte": return $"cast({getExp(callExp.Arguments[0])} as utinyint)";
|
||||
case "System.Char": return $"substr(cast({getExp(callExp.Arguments[0])} as char), 1, 1)";
|
||||
case "System.DateTime": return ExpressionConstDateTime(callExp.Arguments[0]) ?? $"cast({getExp(callExp.Arguments[0])} as timestamp)";
|
||||
case "System.Decimal": return $"cast({getExp(callExp.Arguments[0])} as decimal(36,18))";
|
||||
case "System.Double": return $"cast({getExp(callExp.Arguments[0])} as double)";
|
||||
case "System.Int16": return $"cast({getExp(callExp.Arguments[0])} as smallint)";
|
||||
case "System.Int32": return $"cast({getExp(callExp.Arguments[0])} as integer)";
|
||||
case "System.Int64": return $"cast({getExp(callExp.Arguments[0])} as bigint)";
|
||||
case "System.SByte": return $"cast({getExp(callExp.Arguments[0])} as tinyint)";
|
||||
case "System.Single": return $"cast({getExp(callExp.Arguments[0])} as float)";
|
||||
case "System.UInt16": return $"cast({getExp(callExp.Arguments[0])} as usmallint)";
|
||||
case "System.UInt32": return $"cast({getExp(callExp.Arguments[0])} as uinteger)";
|
||||
case "System.UInt64": return $"cast({getExp(callExp.Arguments[0])} as ubigint)";
|
||||
case "System.Guid": return $"cast({getExp(callExp.Arguments[0])} as uuid)";
|
||||
}
|
||||
return null;
|
||||
case "NewGuid":
|
||||
return null;
|
||||
case "Next":
|
||||
if (callExp.Object?.Type == typeof(Random)) return "cast(random()*1000000000 as int)";
|
||||
return null;
|
||||
case "NextDouble":
|
||||
if (callExp.Object?.Type == typeof(Random)) return "random()";
|
||||
return null;
|
||||
case "Random":
|
||||
if (callExp.Method.DeclaringType.IsNumberType()) return "random()";
|
||||
return null;
|
||||
case "ToString":
|
||||
if (callExp.Object != null)
|
||||
{
|
||||
if (callExp.Object.Type.NullableTypeOrThis().IsEnum)
|
||||
{
|
||||
tsc.SetMapColumnTmp(null);
|
||||
var oldMapType = tsc.SetMapTypeReturnOld(typeof(string));
|
||||
var enumStr = ExpressionLambdaToSql(callExp.Object, tsc);
|
||||
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||
return enumStr;
|
||||
}
|
||||
var value = ExpressionGetValue(callExp.Object, out var success);
|
||||
if (success) return formatSql(value, typeof(string), null, null);
|
||||
return callExp.Arguments.Count == 0 ? $"({getExp(callExp.Object)})::text" : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var objExp = callExp.Object;
|
||||
var objType = objExp?.Type;
|
||||
if (objType?.FullName == "System.Byte[]") return null;
|
||||
|
||||
var argIndex = 0;
|
||||
if (objType == null && callExp.Method.DeclaringType == typeof(Enumerable))
|
||||
{
|
||||
objExp = callExp.Arguments.FirstOrDefault();
|
||||
objType = objExp?.Type;
|
||||
argIndex++;
|
||||
|
||||
if (objType == typeof(string))
|
||||
{
|
||||
switch (callExp.Method.Name)
|
||||
{
|
||||
case "First":
|
||||
case "FirstOrDefault":
|
||||
return $"substring({getExp(callExp.Arguments[0])}, 1, 1)";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (objType == null) objType = callExp.Method.DeclaringType;
|
||||
if (objType != null || objType.IsArrayOrList())
|
||||
{
|
||||
string left = null;
|
||||
switch (callExp.Method.Name)
|
||||
{
|
||||
case "Any":
|
||||
left = objExp == null ? null : getExp(objExp);
|
||||
if (left.StartsWith("(") || left.EndsWith(")")) left = $"[{left.TrimStart('(').TrimEnd(')')}]";
|
||||
return $"(case when {left} is null then 0 else len({left}) end > 0)";
|
||||
case "Contains":
|
||||
tsc.SetMapColumnTmp(null);
|
||||
var args1 = getExp(callExp.Arguments[argIndex]);
|
||||
var oldMapType = tsc.SetMapTypeReturnOld(tsc.mapTypeTmp);
|
||||
var oldDbParams = objExp?.NodeType == ExpressionType.MemberAccess ? tsc.SetDbParamsReturnOld(null) : null; //#900 UseGenerateCommandParameterWithLambda(true) 子查询 bug、以及 #1173 参数化 bug
|
||||
tsc.isNotSetMapColumnTmp = true;
|
||||
left = objExp == null ? null : getExp(objExp);
|
||||
tsc.isNotSetMapColumnTmp = false;
|
||||
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||
if (oldDbParams != null) tsc.SetDbParamsReturnOld(oldDbParams);
|
||||
//判断 in 或 array @> array
|
||||
if (left.StartsWith("[") && left.EndsWith("]"))
|
||||
return $"({args1}) in ({left.TrimStart('[').TrimEnd(']')})";
|
||||
if (left.StartsWith("(") && left.EndsWith(")")) //在各大 Provider AdoProvider 中已约定,500元素分割, 3空格\r\n4空格
|
||||
return $"(({args1}) in {left.Replace(", \r\n \r\n", $") \r\n OR ({args1}) in (")})";
|
||||
return $"list_contains({left}, {args1})";
|
||||
case "Concat":
|
||||
left = objExp == null ? null : getExp(objExp);
|
||||
if (left.StartsWith("(") || left.EndsWith(")")) left = $"[{left.TrimStart('(').TrimEnd(')')}]";
|
||||
var right2 = getExp(callExp.Arguments[argIndex]);
|
||||
if (right2.StartsWith("(") || right2.EndsWith(")")) right2 = $"[{right2.TrimStart('(').TrimEnd(')')}]";
|
||||
return $"list_concat({left}, {right2})";
|
||||
case "GetLength":
|
||||
case "GetLongLength":
|
||||
case "Length":
|
||||
case "Count":
|
||||
left = objExp == null ? null : getExp(objExp);
|
||||
if (left.StartsWith("(") || left.EndsWith(")")) left = $"[{left.TrimStart('(').TrimEnd(')')}]";
|
||||
return $"case when {left} is null then 0 else len({left}) end";
|
||||
}
|
||||
if (objType.IsGenericType && objType.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
||||
{
|
||||
left = objExp == null ? null : getExp(objExp);
|
||||
switch (callExp.Method.Name)
|
||||
{
|
||||
case "get_Item": return $"element_at({left},{getExp(callExp.Arguments[argIndex])})[1]";
|
||||
case "ContainsKey": return $"len(element_at({left},{getExp(callExp.Arguments[argIndex])})) > 0";
|
||||
case "GetLength":
|
||||
case "GetLongLength":
|
||||
case "Count": return $"cardinality({left})";
|
||||
case "Keys": return $"map_keys({left})";
|
||||
case "Values": return $"map_values({left})";
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ExpressionType.MemberAccess:
|
||||
var memExp = exp as MemberExpression;
|
||||
var memParentExp = memExp.Expression?.Type;
|
||||
if (memParentExp?.FullName == "System.Byte[]") return null;
|
||||
if (memParentExp != null)
|
||||
{
|
||||
if (memParentExp.IsArrayOrList())
|
||||
{
|
||||
var left = getExp(memExp.Expression);
|
||||
if (left.StartsWith("(") || left.EndsWith(")")) left = $"[{left.TrimStart('(').TrimEnd(')')}]";
|
||||
switch (memExp.Member.Name)
|
||||
{
|
||||
case "Length":
|
||||
case "Count": return $"case when {left} is null then 0 else len({left}) end";
|
||||
}
|
||||
}
|
||||
if (memParentExp.IsGenericType && memParentExp.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
||||
{
|
||||
var left = getExp(memExp.Expression);
|
||||
switch (memExp.Member.Name)
|
||||
{
|
||||
case "Count": return $"cardinality({left})";
|
||||
case "Keys": return $"map_keys({left})";
|
||||
case "Values": return $"map_values({left})";
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ExpressionType.NewArrayInit:
|
||||
var arrExp = exp as NewArrayExpression;
|
||||
var arrSb = new StringBuilder();
|
||||
arrSb.Append("[");
|
||||
for (var a = 0; a < arrExp.Expressions.Count; a++)
|
||||
{
|
||||
if (a > 0) arrSb.Append(",");
|
||||
arrSb.Append(getExp(arrExp.Expressions[a]));
|
||||
}
|
||||
if (arrSb.Length == 1) arrSb.Append("NULL");
|
||||
return arrSb.Append("]").ToString();
|
||||
case ExpressionType.ListInit:
|
||||
var listExp = exp as ListInitExpression;
|
||||
var listSb = new StringBuilder();
|
||||
listSb.Append("(");
|
||||
for (var a = 0; a < listExp.Initializers.Count; a++)
|
||||
{
|
||||
if (listExp.Initializers[a].Arguments.Any() == false) continue;
|
||||
if (a > 0) listSb.Append(",");
|
||||
listSb.Append(getExp(listExp.Initializers[a].Arguments.FirstOrDefault()));
|
||||
}
|
||||
if (listSb.Length == 1) listSb.Append("NULL");
|
||||
return listSb.Append(")").ToString();
|
||||
case ExpressionType.New:
|
||||
var newExp = exp as NewExpression;
|
||||
if (typeof(IList).IsAssignableFrom(newExp.Type))
|
||||
{
|
||||
if (newExp.Arguments.Count == 0) return "(NULL)";
|
||||
if (typeof(IEnumerable).IsAssignableFrom(newExp.Arguments[0].Type) == false) return "(NULL)";
|
||||
return getExp(newExp.Arguments[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ExpressionLambdaToSqlMemberAccessString(MemberExpression exp, ExpTSC tsc)
|
||||
{
|
||||
if (exp.Expression == null)
|
||||
{
|
||||
switch (exp.Member.Name)
|
||||
{
|
||||
case "Empty": return "''";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var left = ExpressionLambdaToSql(exp.Expression, tsc);
|
||||
switch (exp.Member.Name)
|
||||
{
|
||||
case "Length": return $"length({left})";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public override string ExpressionLambdaToSqlMemberAccessDateTime(MemberExpression exp, ExpTSC tsc)
|
||||
{
|
||||
if (exp.Expression == null)
|
||||
{
|
||||
switch (exp.Member.Name)
|
||||
{
|
||||
case "Now": return _common.Now;
|
||||
case "UtcNow": return _common.NowUtc;
|
||||
case "Today": return "current_date";
|
||||
case "MinValue": return "timestamp '0001-01-01 00:00:00.000'";
|
||||
case "MaxValue": return "timestamp '9999-12-31 23:59:59.999'";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var left = ExpressionLambdaToSql(exp.Expression, tsc);
|
||||
switch (exp.Member.Name)
|
||||
{
|
||||
case "Date": return $"({left})::date";
|
||||
case "TimeOfDay": return $"strftime({left},'%H:%M:%S')::time";
|
||||
case "DayOfWeek": return $"dayofweek({left})";
|
||||
case "Day": return $"day({left})";
|
||||
case "DayOfYear": return $"dayofyear({left})";
|
||||
case "Month": return $"month({left})";
|
||||
case "Year": return $"year({left})";
|
||||
case "Hour": return $"hour({left})";
|
||||
case "Minute": return $"minute({left})";
|
||||
case "Second": return $"second({left})";
|
||||
case "Millisecond": return $"millisecond({left})";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ExpressionLambdaToSqlCallString(MethodCallExpression exp, ExpTSC tsc)
|
||||
{
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
|
||||
if (exp.Object == null)
|
||||
{
|
||||
switch (exp.Method.Name)
|
||||
{
|
||||
case "IsNullOrEmpty":
|
||||
var arg1 = getExp(exp.Arguments[0]);
|
||||
return $"({arg1} is null or {arg1} = '')";
|
||||
case "IsNullOrWhiteSpace":
|
||||
var arg2 = getExp(exp.Arguments[0]);
|
||||
return $"({arg2} is null or {arg2} = '' or ltrim({arg2}) = '')";
|
||||
case "Concat":
|
||||
if (exp.Arguments.Count == 1 && exp.Arguments[0].NodeType == ExpressionType.NewArrayInit && exp.Arguments[0] is NewArrayExpression concatNewArrExp)
|
||||
return _common.StringConcat(concatNewArrExp.Expressions.Select(a => getExp(a)).ToArray(), null);
|
||||
return _common.StringConcat(exp.Arguments.Select(a => getExp(a)).ToArray(), null);
|
||||
case "Format":
|
||||
if (exp.Arguments[0].NodeType != ExpressionType.Constant) throw new Exception(CoreErrorStrings.Not_Implemented_Expression_ParameterUseConstant(exp, exp.Arguments[0]));
|
||||
var expArgsHack = exp.Arguments.Count == 2 && exp.Arguments[1].NodeType == ExpressionType.NewArrayInit ?
|
||||
(exp.Arguments[1] as NewArrayExpression).Expressions : exp.Arguments.Where((a, z) => z > 0);
|
||||
//3个 {} 时,Arguments 解析出来是分开的
|
||||
//4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
|
||||
var expArgs = expArgsHack.Select(a =>
|
||||
{
|
||||
var atype = (a as UnaryExpression)?.Operand.Type.NullableTypeOrThis() ?? a.Type.NullableTypeOrThis();
|
||||
if (atype == typeof(string)) return $"'||{_common.IsNull(ExpressionLambdaToSql(a, tsc), "''")}||'";
|
||||
return $"'||{_common.IsNull($"({ExpressionLambdaToSql(a, tsc)})::text", "''")}||'";
|
||||
}).ToArray();
|
||||
return string.Format(ExpressionLambdaToSql(exp.Arguments[0], tsc), expArgs);
|
||||
case "Join":
|
||||
if (exp.IsStringJoin(out var tolistObjectExp, out var toListMethod, out var toListArgs1))
|
||||
{
|
||||
var newToListArgs0 = Expression.Call(tolistObjectExp, toListMethod,
|
||||
Expression.Lambda(
|
||||
Expression.Call(
|
||||
typeof(SqlExtExtensions).GetMethod("StringJoinPgsqlGroupConcat"),
|
||||
Expression.Convert(toListArgs1.Body, typeof(object)),
|
||||
Expression.Convert(exp.Arguments[0], typeof(object))),
|
||||
toListArgs1.Parameters));
|
||||
var newToListSql = getExp(newToListArgs0);
|
||||
return newToListSql;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var left = getExp(exp.Object);
|
||||
switch (exp.Method.Name)
|
||||
{
|
||||
case "StartsWith":
|
||||
case "EndsWith":
|
||||
case "Contains":
|
||||
var leftLike = exp.Object.NodeType == ExpressionType.MemberAccess ? left : $"({left})";
|
||||
var args0Value = getExp(exp.Arguments[0]);
|
||||
if (args0Value == "NULL") return $"{leftLike} IS NULL";
|
||||
if (exp.Method.Name == "StartsWith") return $"{left} ^@ ({args0Value})";
|
||||
if (args0Value.Contains("%"))
|
||||
{
|
||||
if (exp.Method.Name == "EndsWith") return $"strpos({left}, {args0Value}) = length({left})-length({args0Value})+1";
|
||||
return $"strpos({left}, {args0Value}) > 0";
|
||||
}
|
||||
if (exp.Method.Name == "EndsWith") return $"{leftLike} LIKE {(args0Value.StartsWith("'") ? args0Value.Insert(1, "%") : $"('%' || ({args0Value})::text)")}";
|
||||
if (args0Value.StartsWith("'") && args0Value.EndsWith("'")) return $"{leftLike} LIKE {args0Value.Insert(1, "%").Insert(args0Value.Length, "%")}";
|
||||
return $"{leftLike} LIKE ('%' || ({args0Value})::text || '%')";
|
||||
case "ToLower": return $"lower({left})";
|
||||
case "ToUpper": return $"upper({left})";
|
||||
case "Substring":
|
||||
var substrArgs1 = getExp(exp.Arguments[0]);
|
||||
if (long.TryParse(substrArgs1, out var testtrylng1)) substrArgs1 = (testtrylng1 + 1).ToString();
|
||||
else substrArgs1 += "+1";
|
||||
if (exp.Arguments.Count == 1) return $"substring({left}, {substrArgs1})";
|
||||
return $"substring({left}, {substrArgs1}, {getExp(exp.Arguments[1])})";
|
||||
case "IndexOf":
|
||||
var indexOfFindStr = getExp(exp.Arguments[0]);
|
||||
//if (exp.Arguments.Count > 1 && exp.Arguments[1].Type.FullName == "System.Int32") {
|
||||
// var locateArgs1 = getExp(exp.Arguments[1]);
|
||||
// if (long.TryParse(locateArgs1, out var testtrylng2)) locateArgs1 = (testtrylng2 + 1).ToString();
|
||||
// else locateArgs1 += "+1";
|
||||
// return $"(instr({left}, {indexOfFindStr}, {locateArgs1})-1)";
|
||||
//}
|
||||
return $"(strpos({left}, {indexOfFindStr})-1)";
|
||||
case "PadLeft":
|
||||
if (exp.Arguments.Count == 1) return $"lpad({left}, {getExp(exp.Arguments[0])}, ' ')";
|
||||
return $"lpad({left}, {getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "PadRight":
|
||||
if (exp.Arguments.Count == 1) return $"rpad({left}, {getExp(exp.Arguments[0])}, ' ')";
|
||||
return $"rpad({left}, {getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "Trim":
|
||||
case "TrimStart":
|
||||
case "TrimEnd":
|
||||
if (exp.Arguments.Count == 0)
|
||||
{
|
||||
if (exp.Method.Name == "Trim") return $"trim({left})";
|
||||
if (exp.Method.Name == "TrimStart") return $"ltrim({left})";
|
||||
if (exp.Method.Name == "TrimEnd") return $"rtrim({left})";
|
||||
}
|
||||
var trimArg1 = "";
|
||||
var trimArg2 = "";
|
||||
foreach (var argsTrim02 in exp.Arguments)
|
||||
{
|
||||
var argsTrim01s = new[] { argsTrim02 };
|
||||
if (argsTrim02.NodeType == ExpressionType.NewArrayInit)
|
||||
{
|
||||
var arritem = argsTrim02 as NewArrayExpression;
|
||||
argsTrim01s = arritem.Expressions.ToArray();
|
||||
}
|
||||
foreach (var argsTrim01 in argsTrim01s)
|
||||
{
|
||||
var trimChr = getExp(argsTrim01).Trim('\'');
|
||||
if (trimChr.Length == 1) trimArg1 += trimChr;
|
||||
else trimArg2 += $" || ({trimChr})";
|
||||
}
|
||||
}
|
||||
if (exp.Method.Name == "Trim") left = $"trim({left}, {_common.FormatSql("{0}", trimArg1)}{trimArg2})";
|
||||
if (exp.Method.Name == "TrimStart") left = $"ltrim({left}, {_common.FormatSql("{0}", trimArg1)}{trimArg2})";
|
||||
if (exp.Method.Name == "TrimEnd") left = $"rtrim({left}, {_common.FormatSql("{0}", trimArg1)}{trimArg2})";
|
||||
return left;
|
||||
case "Replace": return $"replace({left}, {getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "CompareTo": return $"case when {left} = {getExp(exp.Arguments[0])} then 0 when {left} > {getExp(exp.Arguments[0])} then 1 else -1 end";
|
||||
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public override string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc)
|
||||
{
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
|
||||
switch (exp.Method.Name)
|
||||
{
|
||||
case "Abs": return $"abs({getExp(exp.Arguments[0])})";
|
||||
case "Sign": return $"sign({getExp(exp.Arguments[0])})";
|
||||
case "Floor": return $"floor({getExp(exp.Arguments[0])})";
|
||||
case "Ceiling": return $"ceiling({getExp(exp.Arguments[0])})";
|
||||
case "Round":
|
||||
if (exp.Arguments.Count > 1 && exp.Arguments[1].Type.FullName == "System.Int32") return $"round({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
return $"round({getExp(exp.Arguments[0])}, 2)";
|
||||
case "Exp": return $"exp({getExp(exp.Arguments[0])})";
|
||||
case "Log": return $"log({getExp(exp.Arguments[0])})";
|
||||
case "Log10": return $"log10({getExp(exp.Arguments[0])})";
|
||||
case "Pow": return $"power({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "Sqrt": return $"sqrt({getExp(exp.Arguments[0])})";
|
||||
case "Cos": return $"cos({getExp(exp.Arguments[0])})";
|
||||
case "Sin": return $"sin({getExp(exp.Arguments[0])})";
|
||||
case "Tan": return $"tan({getExp(exp.Arguments[0])})";
|
||||
case "Acos": return $"acos({getExp(exp.Arguments[0])})";
|
||||
case "Asin": return $"asin({getExp(exp.Arguments[0])})";
|
||||
case "Atan": return $"atan({getExp(exp.Arguments[0])})";
|
||||
case "Atan2": return $"atan2({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
case "Truncate": return $"trunc({getExp(exp.Arguments[0])})";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
|
||||
{
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
|
||||
if (exp.Object == null)
|
||||
{
|
||||
switch (exp.Method.Name)
|
||||
{
|
||||
case "Compare": return $"(epoch({getExp(exp.Arguments[0])})-epoch({getExp(exp.Arguments[1])}))";
|
||||
case "DaysInMonth": return $"day(last_day(cast({getExp(exp.Arguments[0])}||'-'||{getExp(exp.Arguments[1])}||'-01' as date)))";
|
||||
case "Equals": return $"({getExp(exp.Arguments[0])} = {getExp(exp.Arguments[1])})";
|
||||
|
||||
case "IsLeapYear":
|
||||
var isLeapYearArgs1 = getExp(exp.Arguments[0]);
|
||||
return $"(({isLeapYearArgs1})%4=0 AND ({isLeapYearArgs1})%100<>0 OR ({isLeapYearArgs1})%400=0)";
|
||||
|
||||
case "Parse": return ExpressionConstDateTime(exp.Arguments[0]) ?? $"cast({getExp(exp.Arguments[0])} as timestamp)";
|
||||
case "ParseExact":
|
||||
case "TryParse":
|
||||
case "TryParseExact": return ExpressionConstDateTime(exp.Arguments[0]) ?? $"cast({getExp(exp.Arguments[0])} as timestamp)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var left = getExp(exp.Object);
|
||||
var args1 = exp.Arguments.Count == 0 ? null : getExp(exp.Arguments[0]);
|
||||
switch (exp.Method.Name)
|
||||
{
|
||||
case "AddDays": return $"date_add({left},cast(({args1})||' days' as interval))";
|
||||
case "AddHours": return $"date_add({left},cast(({args1})||' hours' as interval))";
|
||||
case "AddMilliseconds": return $"date_add({left},cast(({args1})||' milliseconds' as interval))";
|
||||
case "AddMinutes": return $"date_add({left},cast(({args1})||' minutes' as interval))";
|
||||
case "AddMonths": return $"date_add({left},cast(({args1})||' months' as interval))";
|
||||
case "AddSeconds": return $"date_add({left},cast(({args1})||' seconds' as interval))";
|
||||
case "AddTicks": return $"date_add({left},cast((({args1})/10)||' microseconds' as interval))";
|
||||
case "AddYears": return $"date_add({left},cast(({args1})||' years' as interval))";
|
||||
case "Subtract":
|
||||
switch ((exp.Arguments[0].Type.IsNullableType() ? exp.Arguments[0].Type.GetGenericArguments().FirstOrDefault() : exp.Arguments[0].Type).FullName)
|
||||
{
|
||||
case "System.DateTime": return $"cast((epoch({left})-epoch({args1}))||' seconds' as interval)";
|
||||
case "System.TimeSpan": return $"date_add({left},{args1})";
|
||||
}
|
||||
break;
|
||||
case "Equals": return $"({left} = {args1})";
|
||||
case "CompareTo": return $"(epoch({left})-epoch({args1}))";
|
||||
case "ToString":
|
||||
if (exp.Arguments.Count == 0) return $"strftime({left},'%Y-%m-%d %H:%M:%S')";
|
||||
switch (args1)
|
||||
{
|
||||
case "'yyyy-MM-dd HH:mm:ss'": return $"strftime({left},'%Y-%m-%d %H:%M:%S')";
|
||||
case "'yyyy-MM-dd HH:mm'": return $"strftime({left},'%Y-%m-%d %H:%M')";
|
||||
case "'yyyy-MM-dd HH'": return $"strftime({left},'%Y-%m-%d %H')";
|
||||
case "'yyyy-MM-dd'": return $"strftime({left},'%Y-%m-%d')";
|
||||
case "'yyyy-MM'": return $"strftime({left},'%Y-%m')";
|
||||
case "'yyyyMMddHHmmss'": return $"strftime({left},'%Y%m%d%H%M%S')";
|
||||
case "'yyyyMMddHHmm'": return $"strftime({left},'%Y%m%d%H%M')";
|
||||
case "'yyyyMMddHH'": return $"strftime({left},'%Y%m%d%H')";
|
||||
case "'yyyyMMdd'": return $"strftime({left},'%Y%m%d')";
|
||||
case "'yyyyMM'": return $"strftime({left},'%Y%m')";
|
||||
case "'yyyy'": return $"strftime({left},'%Y')";
|
||||
case "'HH:mm:ss'": return $"strftime({left},'%H:%M:%S')";
|
||||
}
|
||||
args1 = Regex.Replace(args1, "(yyyy|MM|dd|HH|mm|ss)", m =>
|
||||
{
|
||||
switch (m.Groups[1].Value)
|
||||
{
|
||||
case "yyyy": return $"%Y";
|
||||
case "MM": return $"%_a1";
|
||||
case "dd": return $"%_a2";
|
||||
case "HH": return $"%_a3";
|
||||
case "mm": return $"%_a4";
|
||||
case "ss": return $"%S";
|
||||
}
|
||||
return m.Groups[0].Value;
|
||||
});
|
||||
var argsFinds = new[] { "%Y", "%_a1", "%_a2", "%_a3", "%_a4", "%S" };
|
||||
var argsSpts = Regex.Split(args1, "(yy|M|d|H|hh|h|m|s|tt|t)");
|
||||
for (var a = 0; a < argsSpts.Length; a++)
|
||||
{
|
||||
switch (argsSpts[a])
|
||||
{
|
||||
case "yy": argsSpts[a] = $"substr(strftime({left},'%Y'),3,2)"; break;
|
||||
case "M": argsSpts[a] = $"strftime({left},'%-m')"; break;
|
||||
case "d": argsSpts[a] = $"strftime({left},'%-d')"; break;
|
||||
case "H": argsSpts[a] = $"strftime({left},'%-H')"; break;
|
||||
case "hh": argsSpts[a] = $"strftime({left},'%I')"; break;
|
||||
case "h": argsSpts[a] = $"strftime({left},'%-I')"; break;
|
||||
case "m": argsSpts[a] = $"strftime({left},'%-M')"; break;
|
||||
case "s": argsSpts[a] = $"strftime({left},'%-S')"; break;
|
||||
case "tt": argsSpts[a] = $"strftime({left},'%p')"; break;
|
||||
case "t": argsSpts[a] = $"substr(strftime({left},'%p'),1,1)"; break;
|
||||
default:
|
||||
var argsSptsA = argsSpts[a];
|
||||
if (argsSptsA.StartsWith("'")) argsSptsA = argsSptsA.Substring(1);
|
||||
if (argsSptsA.EndsWith("'")) argsSptsA = argsSptsA.Remove(argsSptsA.Length - 1);
|
||||
argsSpts[a] = argsFinds.Any(m => argsSptsA.Contains(m)) ? $"strftime({left},'{argsSptsA}')" : $"'{argsSptsA}'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (argsSpts.Length > 0) args1 = $"({string.Join(" || ", argsSpts.Where(a => a != "''"))})";
|
||||
return args1.Replace("%_a1", "%m").Replace("%_a2", "%d").Replace("%_a3", "%H").Replace("%_a4", "%M");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public override string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc)
|
||||
{
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
|
||||
if (exp.Object == null)
|
||||
{
|
||||
switch (exp.Method.Name)
|
||||
{
|
||||
case "ToBoolean": return $"({getExp(exp.Arguments[0])} not in ('0','false'))";
|
||||
case "ToByte": return $"cast({getExp(exp.Arguments[0])} as utinyint)";
|
||||
case "ToChar": return $"substr(cast({getExp(exp.Arguments[0])} as char), 1, 1)";
|
||||
case "ToDateTime": return ExpressionConstDateTime(exp.Arguments[0]) ?? $"cast({getExp(exp.Arguments[0])} as timestamp)";
|
||||
case "ToDecimal": return $"cast({getExp(exp.Arguments[0])} as decimal(36,18))";
|
||||
case "ToDouble": return $"cast({getExp(exp.Arguments[0])} as double)";
|
||||
case "ToInt16": return $"cast({getExp(exp.Arguments[0])} as smallint)";
|
||||
case "ToInt32": return $"cast({getExp(exp.Arguments[0])} as integer)";
|
||||
case "ToInt64": return $"cast({getExp(exp.Arguments[0])} as bigint)";
|
||||
case "ToSByte": return $"cast({getExp(exp.Arguments[0])} as tinyint)";
|
||||
case "ToSingle": return $"cast({getExp(exp.Arguments[0])} as float)";
|
||||
case "ToString": return $"cast({getExp(exp.Arguments[0])} as text)";
|
||||
case "ToUInt16": return $"cast({getExp(exp.Arguments[0])} as usmallint)";
|
||||
case "ToUInt32": return $"cast({getExp(exp.Arguments[0])} as uinteger)";
|
||||
case "ToUInt64": return $"cast({getExp(exp.Arguments[0])} as ubigint)";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Providers/FreeSql.Provider.TDengine/TDengineExtensions.cs
Normal file
15
Providers/FreeSql.Provider.TDengine/TDengineExtensions.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text;
|
||||
using FreeSql.TDengine;
|
||||
|
||||
public static class FreeSqlTDengineGlobalExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 特殊处理类似 string.Format 的使用方法,防止注入,以及 IS NULL 转换
|
||||
/// </summary>
|
||||
/// <param name="that"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public static string FormatTDengine(this string that, params object[] args) => TDengineAdo.Addslashes(that, args);
|
||||
|
||||
static readonly TDengineAdo TDengineAdo = new TDengineAdo();
|
||||
}
|
||||
100
Providers/FreeSql.Provider.TDengine/TDengineProvider.cs
Normal file
100
Providers/FreeSql.Provider.TDengine/TDengineProvider.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using FreeSql.Aop;
|
||||
using FreeSql.Provider.TDengine.Attributes;
|
||||
using FreeSql.TDengine.Curd;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TDengine.Data.Client;
|
||||
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||
{
|
||||
public TDengineProvider(string masterConnectionString, string[] slaveConnectionString,
|
||||
Func<DbConnection> connectionFactory = null)
|
||||
{
|
||||
this.InternalCommonUtils = new TDengineUtils(this);
|
||||
this.InternalCommonExpression = new TDengineExpression(this.InternalCommonUtils);
|
||||
this.Ado = new TDengineAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString,
|
||||
connectionFactory);
|
||||
this.Aop = new AopProvider();
|
||||
this.DbFirst = new TDengineDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||
this.CodeFirst = new TDengineCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||
|
||||
//处理超级表查询问题
|
||||
//this.Aop.ConfigEntityProperty += (s, e) =>
|
||||
//{
|
||||
// if (e.Property.ReflectedType == null)
|
||||
// return;
|
||||
|
||||
// if (e.Property.ReflectedType.BaseType == null)
|
||||
// return;
|
||||
|
||||
// var propertyInfo = e.Property.ReflectedType.BaseType.GetProperty(e.Property.Name);
|
||||
|
||||
// if (propertyInfo == null)
|
||||
// return;
|
||||
|
||||
// if (propertyInfo.GetCustomAttribute(typeof(TDengineTagAttribute)) != null)
|
||||
// e.ModifyResult.IsIgnore = true;
|
||||
//};
|
||||
|
||||
//处理参数化
|
||||
this.Aop.CommandBefore += (_, e) =>
|
||||
{
|
||||
if (e.Command.Parameters.Count <= 0) return;
|
||||
var dengineParameters = new TDengineParameter[e.Command.Parameters.Count];
|
||||
e.Command.Parameters.CopyTo(dengineParameters, 0);
|
||||
var cmdText = e.Command.CommandText;
|
||||
var isChanged = false;
|
||||
foreach (var parameter in dengineParameters.OrderByDescending(a => a.ParameterName.Length))
|
||||
{
|
||||
var idx = cmdText.IndexOf(parameter.ParameterName, StringComparison.Ordinal);
|
||||
if (idx != -1)
|
||||
{
|
||||
isChanged = true;
|
||||
cmdText =
|
||||
$"{cmdText.Substring(0, idx)}?{cmdText.Substring(idx + parameter.ParameterName.Length)}";
|
||||
}
|
||||
}
|
||||
|
||||
if (isChanged) e.Command.CommandText = cmdText;
|
||||
};
|
||||
}
|
||||
|
||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) =>
|
||||
new TDengineSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||
|
||||
public override IInsert<T1> CreateInsertProvider<T1>() =>
|
||||
new TDengineInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||
|
||||
|
||||
public override IUpdate<T1> CreateUpdateProvider<T1>(object dywhere)
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
}
|
||||
|
||||
public override IDelete<T1> CreateDeleteProvider<T1>(object dywhere)
|
||||
{
|
||||
return new TDengineDelete<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||
}
|
||||
|
||||
public override IInsertOrUpdate<T1> CreateInsertOrUpdateProvider<T1>()
|
||||
{
|
||||
throw new NotImplementedException($"FreeSql.Provider.TDengine {CoreErrorStrings.S_Not_Implemented_Feature}");
|
||||
}
|
||||
|
||||
~TDengineProvider() => this.Dispose();
|
||||
int _disposeCounter;
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
if (Interlocked.Increment(ref _disposeCounter) != 1) return;
|
||||
(this.Ado as AdoProvider)?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
237
Providers/FreeSql.Provider.TDengine/TDengineUtils.cs
Normal file
237
Providers/FreeSql.Provider.TDengine/TDengineUtils.cs
Normal file
@@ -0,0 +1,237 @@
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql.TDengine.Describes;
|
||||
using TDengine.Data.Client;
|
||||
using TDengine.Driver;
|
||||
|
||||
namespace FreeSql.TDengine
|
||||
{
|
||||
internal class TDengineUtils : CommonUtils
|
||||
{
|
||||
public TDengineUtils(IFreeSql orm) : base(orm)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Now => "now()";
|
||||
|
||||
public override string NowUtc => throw new NotImplementedException();
|
||||
|
||||
public override DbParameter AppendParamter(List<DbParameter> _params, string parameterName, ColumnInfo col,
|
||||
Type type, object value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(parameterName)) parameterName = $"p_{_params?.Count}";
|
||||
if (value != null) value = getParamterValue(type, value);
|
||||
var ret = new TDengineParameter() { ParameterName = QuoteParamterName(parameterName), Value = value };
|
||||
var dbType = _orm.DbFirst.GetDbType(new DatabaseModel.DbColumnInfo
|
||||
{ DbTypeText = col.DbTypeText, DbTypeTextFull = col.Attribute.DbType, MaxLength = col.DbSize });
|
||||
ret.DbType = (DbType)dbType;
|
||||
_params?.Add(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override string Div(string left, string right, Type leftType, Type rightType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string FormatSql(string sql, params object[] args) => sql.FormatTDengine(args);
|
||||
|
||||
static Dictionary<string, Func<object, object>> dicGetParamterValue =
|
||||
new Dictionary<string, Func<object, object>>
|
||||
{
|
||||
{ typeof(uint).FullName, a => long.Parse(string.Concat(a)) },
|
||||
{ typeof(uint[]).FullName, a => getParamterArrayValue(typeof(long), a, 0) },
|
||||
{ typeof(uint?[]).FullName, a => getParamterArrayValue(typeof(long?), a, null) },
|
||||
{ typeof(ulong).FullName, a => decimal.Parse(string.Concat(a)) },
|
||||
{ typeof(ulong[]).FullName, a => getParamterArrayValue(typeof(decimal), a, 0) },
|
||||
{ typeof(ulong?[]).FullName, a => getParamterArrayValue(typeof(decimal?), a, null) },
|
||||
{ typeof(ushort).FullName, a => int.Parse(string.Concat(a)) },
|
||||
{ typeof(ushort[]).FullName, a => getParamterArrayValue(typeof(int), a, 0) },
|
||||
{ typeof(ushort?[]).FullName, a => getParamterArrayValue(typeof(int?), 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(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) },
|
||||
};
|
||||
|
||||
static Array getParamterArrayValue(Type arrayType, object value, object defaultValue)
|
||||
{
|
||||
var valueArr = value as Array;
|
||||
var len = valueArr.GetLength(0);
|
||||
var ret = Array.CreateInstance(arrayType, len);
|
||||
for (var a = 0; a < len; a++)
|
||||
{
|
||||
var item = valueArr.GetValue(a);
|
||||
ret.SetValue(item == null ? defaultValue : getParamterValue(item.GetType(), item, 1), a);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static object getParamterValue(Type type, object value, int level = 0)
|
||||
{
|
||||
if (type.FullName == "System.Byte[]") return value;
|
||||
if (type.FullName == "System.Char[]") return value;
|
||||
if (type.IsArray && level == 0)
|
||||
{
|
||||
var elementType = type.GetElementType();
|
||||
Type enumType = null;
|
||||
if (elementType.IsEnum) enumType = elementType;
|
||||
else if (elementType.IsNullableType() && elementType.GenericTypeArguments.First().IsEnum)
|
||||
enumType = elementType.GenericTypeArguments.First();
|
||||
if (enumType != null)
|
||||
return enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Any()
|
||||
? getParamterArrayValue(typeof(long), value,
|
||||
elementType.IsEnum ? null : enumType.CreateInstanceGetDefaultValue())
|
||||
: getParamterArrayValue(typeof(int), value,
|
||||
elementType.IsEnum ? null : enumType.CreateInstanceGetDefaultValue());
|
||||
return dicGetParamterValue.TryGetValue(type.FullName, out var trydicarr) ? trydicarr(value) : value;
|
||||
}
|
||||
|
||||
if (type.IsNullableType()) type = type.GenericTypeArguments.First();
|
||||
if (type.IsEnum) return (int)value;
|
||||
if (dicGetParamterValue.TryGetValue(type.FullName, out var trydic)) return trydic(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public override DbParameter[] GetDbParamtersByObject(string sql, object obj)
|
||||
=>
|
||||
Utils.GetDbParamtersByObject<DbParameter>(sql, obj, "@", (name, type, value) =>
|
||||
{
|
||||
if (value != null) value = getParamterValue(type, value);
|
||||
var ret = new TDengineParameter { ParameterName = $"@{name}", Value = value };
|
||||
//if (value.GetType().IsEnum || value.GetType().GenericTypeArguments.FirstOrDefault()?.IsEnum == true) {
|
||||
// ret.DataTypeName = "";
|
||||
//} else {
|
||||
var tp = _orm.CodeFirst.GetDbInfo(type)?.type;
|
||||
if (tp != null) ret.DbType = (DbType)tp.Value;
|
||||
//}
|
||||
return ret;
|
||||
});
|
||||
|
||||
public override string GetNoneParamaterSqlValue(List<DbParameter> specialParams, string specialParamFlag,
|
||||
ColumnInfo col, Type type, object value)
|
||||
{
|
||||
if (value == null) return "NULL";
|
||||
if (type.IsNumberType()) return string.Format(CultureInfo.InvariantCulture, "{0}", value);
|
||||
if (type == typeof(byte[])) return $"0x{CommonUtils.BytesSqlRaw(value as byte[])}";
|
||||
if (type == typeof(TimeSpan) || type == typeof(TimeSpan?))
|
||||
{
|
||||
var ts = (TimeSpan)value;
|
||||
value = $"{Math.Floor(ts.TotalHours)}:{ts.Minutes}:{ts.Seconds}";
|
||||
}
|
||||
|
||||
return FormatSql("{0}", value, 1);
|
||||
}
|
||||
|
||||
public override string RewriteColumn(ColumnInfo col, string sql)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(col?.Attribute.RewriteSql) == false)
|
||||
return string.Format(col.Attribute.RewriteSql, sql);
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
public override string IsNull(string sql, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string Mod(string left, string right, Type leftType, Type rightType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string QuoteParamterName(string name) => $"@{name}";
|
||||
|
||||
public override string QuoteSqlNameAdapter(params string[] name)
|
||||
{
|
||||
if (name.Length == 1)
|
||||
{
|
||||
var nameAdapter = name[0].Trim();
|
||||
if (nameAdapter.StartsWith("(") && nameAdapter.EndsWith(")"))
|
||||
return nameAdapter; //原生SQL
|
||||
if (nameAdapter.StartsWith("`") && nameAdapter.EndsWith("`"))
|
||||
return nameAdapter;
|
||||
return $"`{nameAdapter.Replace(".", "`.`")}`";
|
||||
}
|
||||
|
||||
return $"`{string.Join("`.`", name)}`";
|
||||
}
|
||||
|
||||
public override string QuoteWriteParamterAdapter(Type type, string paramterName) => paramterName;
|
||||
|
||||
public override string[] SplitTableName(string name)
|
||||
{
|
||||
return new[] { name };
|
||||
}
|
||||
|
||||
public override string StringConcat(string[] objs, Type[] types)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string TrimQuoteSqlName(string name)
|
||||
{
|
||||
var nametrim = name.Trim();
|
||||
if (nametrim.StartsWith("(") && nametrim.EndsWith(")"))
|
||||
return nametrim; //原生SQL
|
||||
return $"{nametrim.Trim('`').Replace("`.`", ".").Replace(".`", ".")}";
|
||||
}
|
||||
|
||||
protected override string QuoteReadColumnAdapter(Type type, Type mapType, string columnName)
|
||||
{
|
||||
return columnName;
|
||||
}
|
||||
|
||||
//超表描述
|
||||
private static readonly ConcurrentDictionary<Type, Lazy<SuperTableDescribe>> STableDescribes =
|
||||
new ConcurrentDictionary<Type, Lazy<SuperTableDescribe>>();
|
||||
|
||||
/// <summary>
|
||||
/// 通过子表获取超级表描述
|
||||
/// </summary>
|
||||
/// <param name="subTableType"></param>
|
||||
/// <returns></returns>
|
||||
internal SuperTableDescribe GetSuperTableDescribe(Type subTableType)
|
||||
{
|
||||
var stableDescribe = STableDescribes.GetOrAdd(subTableType, key => new Lazy<SuperTableDescribe>(() =>
|
||||
{
|
||||
var sTableAttribute = subTableType.GetCustomAttribute<TDengineSubTableAttribute>();
|
||||
if (sTableAttribute == null) return null;
|
||||
var describe = new SuperTableDescribe
|
||||
{
|
||||
SuperTableName = sTableAttribute.SuperTableName,
|
||||
SuperTableType = subTableType.BaseType
|
||||
};
|
||||
return describe;
|
||||
}));
|
||||
|
||||
var stableDescribeValue = stableDescribe.Value;
|
||||
|
||||
return stableDescribeValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
BIN
Providers/FreeSql.Provider.TDengine/key.snk
Normal file
BIN
Providers/FreeSql.Provider.TDengine/key.snk
Normal file
Binary file not shown.
@@ -127,98 +127,98 @@ namespace FreeSql.Xugu.Curd
|
||||
}
|
||||
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override ISelect<T1, T2> From<T2>(Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3> From<T2, T3>(Expression<Func<ISelectFromExpression<T1>, T2, T3, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4> From<T2, T3, T4>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5> From<T2, T3, T4, T5>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6> From<T2, T3, T4, T5, T6>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7> From<T2, T3, T4, T5, T6, T7>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2> From<T2>(Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3> From<T2, T3>(Expression<Func<ISelectFromExpression<T1>, T2, T3, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4> From<T2, T3, T4>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5> From<T2, T3, T4, T5>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6> From<T2, T3, T4, T5, T6>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7> From<T2, T3, T4, T5, T6, T7>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(_orm, _commonUtils, _commonExpression, null); XuguSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||
public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T2 : class
|
||||
class XuguSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T2 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T2 : class where T3 : class
|
||||
class XuguSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T2 : class where T3 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T2 : class where T3 : class where T4 : class
|
||||
class XuguSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T2 : class where T3 : class where T4 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T2 : class where T3 : class where T4 : class where T5 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T2 : class where T3 : class where T4 : class where T5 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : FreeSql.Internal.CommonProvider.Select11Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : FreeSql.Internal.CommonProvider.Select11Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : FreeSql.Internal.CommonProvider.Select12Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : FreeSql.Internal.CommonProvider.Select12Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : FreeSql.Internal.CommonProvider.Select13Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : FreeSql.Internal.CommonProvider.Select13Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : FreeSql.Internal.CommonProvider.Select14Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : FreeSql.Internal.CommonProvider.Select14Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : FreeSql.Internal.CommonProvider.Select15Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : FreeSql.Internal.CommonProvider.Select15Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
class PostgreSQLSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> : FreeSql.Internal.CommonProvider.Select16Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class
|
||||
class XuguSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> : FreeSql.Internal.CommonProvider.Select16Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class
|
||||
{
|
||||
public PostgreSQLSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public XuguSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||
public override string ToSql(string field = null) => XuguSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<Title>$(AssemblyName)</Title>
|
||||
<IsPackable>true</IsPackable>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>3.5.100-preview20241112</Version>
|
||||
<Version>3.5.103-preview20241205</Version>
|
||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace FreeSql.Xugu
|
||||
{
|
||||
class XuguAdo : FreeSql.Internal.CommonProvider.AdoProvider
|
||||
{
|
||||
public XuguAdo() : base(DataType.PostgreSQL, null, null) { }
|
||||
public XuguAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func<DbConnection> connectionFactory) : base(DataType.PostgreSQL, masterConnectionString, slaveConnectionStrings)
|
||||
public XuguAdo() : base(DataType.Xugu, null, null) { }
|
||||
public XuguAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func<DbConnection> connectionFactory) : base(DataType.Xugu, masterConnectionString, slaveConnectionStrings)
|
||||
{
|
||||
base._util = util;
|
||||
if (connectionFactory != null)
|
||||
{
|
||||
MasterPool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.PostgreSQL, connectionFactory);
|
||||
MasterPool = new FreeSql.Internal.CommonProvider.DbConnectionPool(DataType.Xugu, connectionFactory);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user