mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-11 02:40:55 +08:00
Merge branch 'dotnetcore:master' into master
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<!--
|
<!--
|
||||||
经常出于版本交叉问题,暂时关闭,在每个项目上设置版本号
|
经常出于版本交叉问题,暂时关闭,在每个项目上设置版本号
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|||||||
@@ -621,6 +621,8 @@ namespace base_entity
|
|||||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
var skdkdk1 = fsql.Select<User1>().LimitBy(a => a.Sort, 1).ToSql();
|
||||||
|
|
||||||
|
|
||||||
fsql.Insert(new User1 { Nickname = "nickname11", Username = "username11", Description = "desc11" }).ExecuteAffrows();
|
fsql.Insert(new User1 { Nickname = "nickname11", Username = "username11", Description = "desc11" }).ExecuteAffrows();
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
|
||||||
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
|
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -240,13 +240,13 @@ public class RazorModel
|
|||||||
if (cstype == typeof(string) && string.Compare(defval, "newid()", true) == 0) return $"Guid.NewGuid().ToString().ToUpper()";
|
if (cstype == typeof(string) && string.Compare(defval, "newid()", true) == 0) return $"Guid.NewGuid().ToString().ToUpper()";
|
||||||
if (defval == "NULL") return null;
|
if (defval == "NULL") return null;
|
||||||
}
|
}
|
||||||
if (!isInsertValueSql && (fsql.Ado.DataType == DataType.PostgreSQL || fsql.Ado.DataType == DataType.OdbcPostgreSQL || fsql.Ado.DataType == DataType.CustomPostgreSQL ||
|
if ((fsql.Ado.DataType == DataType.PostgreSQL || fsql.Ado.DataType == DataType.OdbcPostgreSQL || fsql.Ado.DataType == DataType.CustomPostgreSQL ||
|
||||||
fsql.Ado.DataType == DataType.KingbaseES ||
|
fsql.Ado.DataType == DataType.KingbaseES ||
|
||||||
fsql.Ado.DataType == DataType.ShenTong))
|
fsql.Ado.DataType == DataType.ShenTong))
|
||||||
{
|
{
|
||||||
switch (defval)
|
switch (defval)
|
||||||
{
|
{
|
||||||
case "uuid_generate_v4()": return null;
|
case "uuid_generate_v4()": return isInsertValueSql ? defval : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((cstype == typeof(string) && defval.StartsWith("'") && defval.EndsWith("'::character varying") ||
|
if ((cstype == typeof(string) && defval.StartsWith("'") && defval.EndsWith("'::character varying") ||
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -718,15 +718,6 @@
|
|||||||
<param name="modelBuilder"></param>
|
<param name="modelBuilder"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</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)">
|
<member name="M:FreeSqlDbContextExtensions.CreateDbContext(IFreeSql)">
|
||||||
<summary>
|
<summary>
|
||||||
创建普通数据上下文档对象
|
创建普通数据上下文档对象
|
||||||
|
|||||||
@@ -11,7 +11,31 @@ namespace FreeSql
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工作单元管理器
|
/// 工作单元管理器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UnitOfWorkManager : IDisposable
|
public interface IUnitOfWorkManager : IDisposable
|
||||||
|
{
|
||||||
|
IFreeSql Orm { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前的工作单元
|
||||||
|
/// </summary>
|
||||||
|
IUnitOfWork Current { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// 将仓储的事务交给我管理
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="repository"></param>
|
||||||
|
void Binding(IBaseRepository repository);
|
||||||
|
/// <summary>
|
||||||
|
/// 创建工作单元
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="propagation">事务传播方式</param>
|
||||||
|
/// <param name="isolationLevel">事务隔离级别</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
IUnitOfWork Begin(Propagation propagation = Propagation.Required, IsolationLevel? isolationLevel = null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工作单元管理器
|
||||||
|
/// </summary>
|
||||||
|
public class UnitOfWorkManager : IUnitOfWorkManager
|
||||||
{
|
{
|
||||||
internal DbContextScopedFreeSql _ormScoped;
|
internal DbContextScopedFreeSql _ormScoped;
|
||||||
internal IFreeSql OrmOriginal => _ormScoped?._originalFsql;
|
internal IFreeSql OrmOriginal => _ormScoped?._originalFsql;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
[Fact,Order(1)]
|
[Fact,Order(1)]
|
||||||
public async Task TestInsertAsync()
|
public async Task TestInsertAsync()
|
||||||
{
|
{
|
||||||
var result = await fsql.Insert(new QuestDb_Model_Test01()
|
var result = await Db.Insert(new QuestDb_Model_Test01()
|
||||||
{
|
{
|
||||||
Primarys = Guid.NewGuid().ToString(),
|
Primarys = Guid.NewGuid().ToString(),
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
@@ -66,7 +66,7 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
NameUpdate = "NameUpdate"
|
NameUpdate = "NameUpdate"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
var result = await fsql.Insert(list).ExecuteAffrowsAsync();
|
var result = await Db.Insert(list).ExecuteAffrowsAsync();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,14 +106,14 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
NameUpdate = "NameUpdate"
|
NameUpdate = "NameUpdate"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
var result = await fsql.Insert(list).IgnoreColumns(q => q.NameInsert).ExecuteAffrowsAsync();
|
var result = await Db.Insert(list).IgnoreColumns(q => q.NameInsert).ExecuteAffrowsAsync();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task TestRestInsertAsync()
|
public async Task TestRestInsertAsync()
|
||||||
{
|
{
|
||||||
var result = await restFsql.Insert(new QuestDb_Model_Test01()
|
var result = await RestApiDb.Insert(new QuestDb_Model_Test01()
|
||||||
{
|
{
|
||||||
Primarys = Guid.NewGuid().ToString(),
|
Primarys = Guid.NewGuid().ToString(),
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
@@ -162,7 +162,7 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
NameUpdate = "NameUpdate"
|
NameUpdate = "NameUpdate"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
var result = await restFsql.Insert(list).ExecuteAffrowsAsync();
|
var result = await RestApiDb.Insert(list).ExecuteAffrowsAsync();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
NameUpdate = "NameUpdate"
|
NameUpdate = "NameUpdate"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
var result = await restFsql.Insert(list).IgnoreColumns(q => q.NameInsert).ExecuteAffrowsAsync();
|
var result = await RestApiDb.Insert(list).IgnoreColumns(q => q.NameInsert).ExecuteAffrowsAsync();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await restFsql.Insert(list).ExecuteQuestDbBulkCopyAsync();
|
var result = await RestApiDb.Insert(list).ExecuteQuestDbBulkCopyAsync();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
public void TestNormalUpdate()
|
public void TestNormalUpdate()
|
||||||
{
|
{
|
||||||
var updateTime = DateTime.Now;
|
var updateTime = DateTime.Now;
|
||||||
var updateObj = fsql.Update<QuestDb_Model_Test01>()
|
var updateObj = Db.Update<QuestDb_Model_Test01>()
|
||||||
.Set(q => q.NameUpdate, "UpdateNow")
|
.Set(q => q.NameUpdate, "UpdateNow")
|
||||||
// .Set(q => q.CreateTime, DateTime.Now) 分表的时间不可以随便改
|
// .Set(q => q.CreateTime, DateTime.Now) 分表的时间不可以随便改
|
||||||
.Where(q => q.Id == "1");
|
.Where(q => q.Id == "1");
|
||||||
@@ -253,7 +253,7 @@ WHERE (""Id"" = '1')";
|
|||||||
{
|
{
|
||||||
var primary = Guid.NewGuid().ToString();
|
var primary = Guid.NewGuid().ToString();
|
||||||
//先插入
|
//先插入
|
||||||
fsql.Insert(new QuestDb_Model_Test01()
|
Db.Insert(new QuestDb_Model_Test01()
|
||||||
{
|
{
|
||||||
Primarys = primary,
|
Primarys = primary,
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
@@ -269,11 +269,11 @@ WHERE (""Id"" = '1')";
|
|||||||
Id = primary,
|
Id = primary,
|
||||||
Activos = 12.65,
|
Activos = 12.65,
|
||||||
};
|
};
|
||||||
var updateObj = fsql.Update<QuestDb_Model_Test01>().SetSourceIgnore(updateModel, o => o == null);
|
var updateObj = Db.Update<QuestDb_Model_Test01>().SetSourceIgnore(updateModel, o => o == null);
|
||||||
var sql = updateObj.ToSql();
|
var sql = updateObj.ToSql();
|
||||||
Debug.WriteLine(sql);
|
Debug.WriteLine(sql);
|
||||||
var result = updateObj.ExecuteAffrows();
|
var result = updateObj.ExecuteAffrows();
|
||||||
var resultAsync = fsql.Update<QuestDb_Model_Test01>().SetSourceIgnore(updateModel, o => o == null)
|
var resultAsync = Db.Update<QuestDb_Model_Test01>().SetSourceIgnore(updateModel, o => o == null)
|
||||||
.ExecuteAffrows();
|
.ExecuteAffrows();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
Assert.True(resultAsync > 0);
|
Assert.True(resultAsync > 0);
|
||||||
@@ -288,7 +288,7 @@ WHERE (""Id"" = '{primary}')", sql);
|
|||||||
var primary = Guid.NewGuid().ToString();
|
var primary = Guid.NewGuid().ToString();
|
||||||
var updateTime = DateTime.Now;
|
var updateTime = DateTime.Now;
|
||||||
//先插入
|
//先插入
|
||||||
fsql.Insert(new QuestDb_Model_Test01()
|
Db.Insert(new QuestDb_Model_Test01()
|
||||||
{
|
{
|
||||||
Primarys = primary,
|
Primarys = primary,
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
@@ -298,6 +298,7 @@ WHERE (""Id"" = '{primary}')", sql);
|
|||||||
NameInsert = "NameInsert",
|
NameInsert = "NameInsert",
|
||||||
NameUpdate = "NameUpdate"
|
NameUpdate = "NameUpdate"
|
||||||
}).ExecuteAffrows();
|
}).ExecuteAffrows();
|
||||||
|
|
||||||
var updateModel = new QuestDb_Model_Test01
|
var updateModel = new QuestDb_Model_Test01
|
||||||
{
|
{
|
||||||
Id = primary,
|
Id = primary,
|
||||||
@@ -305,12 +306,12 @@ WHERE (""Id"" = '{primary}')", sql);
|
|||||||
IsCompra = true,
|
IsCompra = true,
|
||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now
|
||||||
};
|
};
|
||||||
var updateObj = fsql.Update<QuestDb_Model_Test01>().SetSource(updateModel)
|
var updateObj = Db.Update<QuestDb_Model_Test01>().SetSource(updateModel)
|
||||||
.IgnoreColumns(q => new { q.Id, q.CreateTime });
|
.IgnoreColumns(q => new { q.Id, q.CreateTime });
|
||||||
var sql = updateObj.ToSql();
|
var sql = updateObj.ToSql();
|
||||||
Debug.WriteLine(sql);
|
Debug.WriteLine(sql);
|
||||||
var result = updateObj.ExecuteAffrows();
|
var result = updateObj.ExecuteAffrows();
|
||||||
var resultAsync = await fsql.Update<QuestDb_Model_Test01>().SetSource(updateModel)
|
var resultAsync = await Db.Update<QuestDb_Model_Test01>().SetSource(updateModel)
|
||||||
.IgnoreColumns(q => new { q.Id, q.CreateTime }).ExecuteAffrowsAsync();
|
.IgnoreColumns(q => new { q.Id, q.CreateTime }).ExecuteAffrowsAsync();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
Assert.True(resultAsync > 0);
|
Assert.True(resultAsync > 0);
|
||||||
@@ -323,7 +324,7 @@ WHERE (""Id"" = '{primary}')", sql);
|
|||||||
public async Task TestUpdateToUpdateAsync()
|
public async Task TestUpdateToUpdateAsync()
|
||||||
{
|
{
|
||||||
//官网demo有问题,暂时放弃此功能
|
//官网demo有问题,暂时放弃此功能
|
||||||
var result = await fsql.Select<QuestDb_Model_Test01>().Where(q => q.Id == "IdAsync" && q.NameInsert == null)
|
var result = await Db.Select<QuestDb_Model_Test01>().Where(q => q.Id == "IdAsync" && q.NameInsert == null)
|
||||||
.ToUpdate()
|
.ToUpdate()
|
||||||
.Set(q => q.UpdateTime, DateTime.Now)
|
.Set(q => q.UpdateTime, DateTime.Now)
|
||||||
.ExecuteAffrowsAsync();
|
.ExecuteAffrowsAsync();
|
||||||
@@ -6,7 +6,6 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using FreeSql.Tests.QuestDb.QuestDbTestModel;
|
using FreeSql.Tests.QuestDb.QuestDbTestModel;
|
||||||
using NetTopologySuite.Operation.Valid;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using static FreeSql.Tests.QuestDb.QuestDbTest;
|
using static FreeSql.Tests.QuestDb.QuestDbTest;
|
||||||
|
|
||||||
@@ -17,13 +16,13 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void TestNormal()
|
public void TestNormal()
|
||||||
{
|
{
|
||||||
var sql = fsql.Select<QuestDb_Model_Test01>().ToSql();
|
var sql = Db.Select<QuestDb_Model_Test01>().ToSql();
|
||||||
Debug.WriteLine(sql);
|
Debug.WriteLine(sql);
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
@"SELECT a.""Primarys"", a.""Id"", a.""NameUpdate"", a.""NameInsert"", a.""Activos"", a.""CreateTime"", a.""UpdateTime"", a.""IsCompra""
|
@"SELECT a.""Primarys"", a.""Id"", a.""NameUpdate"", a.""NameInsert"", a.""Activos"", a.""CreateTime"", a.""UpdateTime"", a.""IsCompra""
|
||||||
FROM ""QuestDb_Model_Test01"" a", sql);
|
FROM ""QuestDb_Model_Test01"" a", sql);
|
||||||
|
|
||||||
var sqlWhere = fsql.Select<QuestDb_Model_Test01>().Where(q =>
|
var sqlWhere = Db.Select<QuestDb_Model_Test01>().Where(q =>
|
||||||
q.UpdateTime.Value.BetweenEnd(DateTime.Parse("2023-02-17 09:35:00"),
|
q.UpdateTime.Value.BetweenEnd(DateTime.Parse("2023-02-17 09:35:00"),
|
||||||
DateTime.Parse("2023-02-17 10:20:00"))).ToSql();
|
DateTime.Parse("2023-02-17 10:20:00"))).ToSql();
|
||||||
Debug.WriteLine(sqlWhere);
|
Debug.WriteLine(sqlWhere);
|
||||||
@@ -41,7 +40,7 @@ WHERE (a.""UpdateTime"" >= '2023-02-17 09:35:00.000000' and a.""UpdateTime"" < '
|
|||||||
public void TestPageAndCount(int page)
|
public void TestPageAndCount(int page)
|
||||||
{
|
{
|
||||||
var pageSize = 5;
|
var pageSize = 5;
|
||||||
var select = fsql.Select<QuestDb_Model_Test01>().Count(out var total).Page(page, pageSize);
|
var select = Db.Select<QuestDb_Model_Test01>().Count(out var total).Page(page, pageSize);
|
||||||
var sql = select.ToSql();
|
var sql = select.ToSql();
|
||||||
Debug.WriteLine(sql);
|
Debug.WriteLine(sql);
|
||||||
switch (page)
|
switch (page)
|
||||||
@@ -70,7 +69,7 @@ limit 10,15", sql);
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void TestNavigation()
|
public void TestNavigation()
|
||||||
{
|
{
|
||||||
var select = fsql.Select<Topic>()
|
var select = Db.Select<Topic>()
|
||||||
.LeftJoin(a => a.Category.Id == a.CategoryId)
|
.LeftJoin(a => a.Category.Id == a.CategoryId)
|
||||||
.LeftJoin(a => a.Category.Parent.Id == a.Category.ParentId)
|
.LeftJoin(a => a.Category.Parent.Id == a.Category.ParentId)
|
||||||
.Where(a => a.Category.Parent.Id > 0);
|
.Where(a => a.Category.Parent.Id > 0);
|
||||||
@@ -88,7 +87,7 @@ WHERE (a__Category__Parent.""Id"" > 0)", sql);
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void TestComplexJoin()
|
public void TestComplexJoin()
|
||||||
{
|
{
|
||||||
var select = fsql.Select<Topic, Category, CategoryType>()
|
var select = Db.Select<Topic, Category, CategoryType>()
|
||||||
.LeftJoin(w => w.t1.CategoryId == w.t2.Id)
|
.LeftJoin(w => w.t1.CategoryId == w.t2.Id)
|
||||||
.LeftJoin(w => w.t2.ParentId == w.t3.Id)
|
.LeftJoin(w => w.t2.ParentId == w.t3.Id)
|
||||||
.Where(w => w.t3.Id > 0);
|
.Where(w => w.t3.Id > 0);
|
||||||
@@ -106,10 +105,10 @@ WHERE (c.""Id"" > 0)", sql);
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void TestUnionAll()
|
public void TestUnionAll()
|
||||||
{
|
{
|
||||||
var select = fsql.Select<QuestDb_Model_Test01>().Where(a => a.IsCompra == true)
|
var select = Db.Select<QuestDb_Model_Test01>().Where(a => a.IsCompra == true)
|
||||||
.UnionAll(
|
.UnionAll(
|
||||||
fsql.Select<QuestDb_Model_Test01>().Where(a => a.IsCompra == true),
|
Db.Select<QuestDb_Model_Test01>().Where(a => a.IsCompra == true),
|
||||||
fsql.Select<QuestDb_Model_Test01>().Where(a => a.IsCompra == true)
|
Db.Select<QuestDb_Model_Test01>().Where(a => a.IsCompra == true)
|
||||||
)
|
)
|
||||||
.Where(a => a.IsCompra == true);
|
.Where(a => a.IsCompra == true);
|
||||||
var sql = select.ToSql();
|
var sql = select.ToSql();
|
||||||
@@ -134,7 +133,7 @@ WHERE (a.""IsCompra"" = True)", sql);
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void TestSampleBy()
|
public void TestSampleBy()
|
||||||
{
|
{
|
||||||
var selectSql = fsql.Select<QuestDb_Model_Test01>()
|
var selectSql = Db.Select<QuestDb_Model_Test01>()
|
||||||
.SampleBy(1, SampleUnit.day)
|
.SampleBy(1, SampleUnit.day)
|
||||||
.WithTempQuery(q => new { q.Id, q.Activos, count = SqlExt.Count(q.Id).ToValue() })
|
.WithTempQuery(q => new { q.Id, q.Activos, count = SqlExt.Count(q.Id).ToValue() })
|
||||||
.Where(q => q.Id != "1")
|
.Where(q => q.Id != "1")
|
||||||
@@ -153,7 +152,7 @@ WHERE (a.""Id"" <> '1')";
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void TestLatestOn()
|
public void TestLatestOn()
|
||||||
{
|
{
|
||||||
var selectSql = fsql.Select<QuestDb_Model_Test01>()
|
var selectSql = Db.Select<QuestDb_Model_Test01>()
|
||||||
.LatestOn(q => q.CreateTime, q => new { q.Id, q.NameUpdate })
|
.LatestOn(q => q.CreateTime, q => new { q.Id, q.NameUpdate })
|
||||||
.ToSql();
|
.ToSql();
|
||||||
Debug.WriteLine(selectSql);
|
Debug.WriteLine(selectSql);
|
||||||
@@ -168,7 +167,7 @@ LATEST ON CreateTime PARTITION BY Id,NameUpdate ";
|
|||||||
public void TestGroup()
|
public void TestGroup()
|
||||||
{
|
{
|
||||||
//QUEDTDB的GroupBy PostgrSql有所不同
|
//QUEDTDB的GroupBy PostgrSql有所不同
|
||||||
var selectSql = fsql.Select<QuestDb_Model_Test01>()
|
var selectSql = Db.Select<QuestDb_Model_Test01>()
|
||||||
.WithTempQuery(q => new { q.Id, q.Activos, count = SqlExt.Count(q.Id).ToValue() })
|
.WithTempQuery(q => new { q.Id, q.Activos, count = SqlExt.Count(q.Id).ToValue() })
|
||||||
.Where(q => q.Id != "1" && q.count > 1)
|
.Where(q => q.Id != "1" && q.count > 1)
|
||||||
.ToSql();
|
.ToSql();
|
||||||
@@ -18,7 +18,7 @@ namespace FreeSql.Tests.QuestDb.Crud
|
|||||||
public void TestNormalRestUpdate()
|
public void TestNormalRestUpdate()
|
||||||
{
|
{
|
||||||
var updateTime = DateTime.Now;
|
var updateTime = DateTime.Now;
|
||||||
var updateObj = restFsql.Update<QuestDb_Model_Test01>()
|
var updateObj = RestApiDb.Update<QuestDb_Model_Test01>()
|
||||||
.Set(q => q.NameUpdate, "UpdateNow")
|
.Set(q => q.NameUpdate, "UpdateNow")
|
||||||
// .Set(q => q.CreateTime, DateTime.Now) 分表的时间不可以随便改
|
// .Set(q => q.CreateTime, DateTime.Now) 分表的时间不可以随便改
|
||||||
.Where(q => q.Id == "1");
|
.Where(q => q.Id == "1");
|
||||||
@@ -38,7 +38,7 @@ WHERE (""Id"" = '1')";
|
|||||||
{
|
{
|
||||||
var primary = Guid.NewGuid().ToString();
|
var primary = Guid.NewGuid().ToString();
|
||||||
//先插入
|
//先插入
|
||||||
restFsql.Insert(new QuestDb_Model_Test01()
|
RestApiDb.Insert(new QuestDb_Model_Test01()
|
||||||
{
|
{
|
||||||
Primarys = primary,
|
Primarys = primary,
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
@@ -54,11 +54,11 @@ WHERE (""Id"" = '1')";
|
|||||||
Id = primary,
|
Id = primary,
|
||||||
Activos = 12.65,
|
Activos = 12.65,
|
||||||
};
|
};
|
||||||
var updateObj = restFsql.Update<QuestDb_Model_Test01>().SetSourceIgnore(updateModel, o => o == null);
|
var updateObj = RestApiDb.Update<QuestDb_Model_Test01>().SetSourceIgnore(updateModel, o => o == null);
|
||||||
var sql = updateObj.ToSql();
|
var sql = updateObj.ToSql();
|
||||||
Debug.WriteLine(sql);
|
Debug.WriteLine(sql);
|
||||||
var result = updateObj.ExecuteAffrows();
|
var result = updateObj.ExecuteAffrows();
|
||||||
var resultAsync = restFsql.Update<QuestDb_Model_Test01>().SetSourceIgnore(updateModel, o => o == null)
|
var resultAsync = RestApiDb.Update<QuestDb_Model_Test01>().SetSourceIgnore(updateModel, o => o == null)
|
||||||
.ExecuteAffrows();
|
.ExecuteAffrows();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
Assert.True(resultAsync > 0);
|
Assert.True(resultAsync > 0);
|
||||||
@@ -73,7 +73,7 @@ WHERE (""Id"" = '{primary}')", sql);
|
|||||||
var primary = Guid.NewGuid().ToString();
|
var primary = Guid.NewGuid().ToString();
|
||||||
var updateTime = DateTime.Now;
|
var updateTime = DateTime.Now;
|
||||||
//先插入
|
//先插入
|
||||||
restFsql.Insert(new QuestDb_Model_Test01()
|
RestApiDb.Insert(new QuestDb_Model_Test01()
|
||||||
{
|
{
|
||||||
Primarys = primary,
|
Primarys = primary,
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
@@ -90,12 +90,12 @@ WHERE (""Id"" = '{primary}')", sql);
|
|||||||
IsCompra = true,
|
IsCompra = true,
|
||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now
|
||||||
};
|
};
|
||||||
var updateObj = restFsql.Update<QuestDb_Model_Test01>().SetSource(updateModel)
|
var updateObj = RestApiDb.Update<QuestDb_Model_Test01>().SetSource(updateModel)
|
||||||
.IgnoreColumns(q => new { q.Id, q.CreateTime });
|
.IgnoreColumns(q => new { q.Id, q.CreateTime });
|
||||||
var sql = updateObj.ToSql();
|
var sql = updateObj.ToSql();
|
||||||
Debug.WriteLine(sql);
|
Debug.WriteLine(sql);
|
||||||
var result = updateObj.ExecuteAffrows();
|
var result = updateObj.ExecuteAffrows();
|
||||||
var resultAsync = await restFsql.Update<QuestDb_Model_Test01>().SetSource(updateModel)
|
var resultAsync = await RestApiDb.Update<QuestDb_Model_Test01>().SetSource(updateModel)
|
||||||
.IgnoreColumns(q => new { q.Id, q.CreateTime }).ExecuteAffrowsAsync();
|
.IgnoreColumns(q => new { q.Id, q.CreateTime }).ExecuteAffrowsAsync();
|
||||||
Assert.True(result > 0);
|
Assert.True(result > 0);
|
||||||
Assert.True(resultAsync > 0);
|
Assert.True(resultAsync > 0);
|
||||||
@@ -108,7 +108,7 @@ WHERE (""Id"" = '{primary}')", sql);
|
|||||||
public async Task TestUpdateToUpdateAsync()
|
public async Task TestUpdateToUpdateAsync()
|
||||||
{
|
{
|
||||||
//官网demo有问题,暂时放弃此功能
|
//官网demo有问题,暂时放弃此功能
|
||||||
var result = await restFsql.Select<QuestDb_Model_Test01>().Where(q => q.Id == "IdAsync" && q.NameInsert == null)
|
var result = await RestApiDb.Select<QuestDb_Model_Test01>().Where(q => q.Id == "IdAsync" && q.NameInsert == null)
|
||||||
.ToUpdate()
|
.ToUpdate()
|
||||||
.Set(q => q.UpdateTime, DateTime.Now)
|
.Set(q => q.UpdateTime, DateTime.Now)
|
||||||
.ExecuteAffrowsAsync();
|
.ExecuteAffrowsAsync();
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<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="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.QuestDb\FreeSql.Provider.QuestDb.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="Xunit" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -16,17 +16,17 @@ namespace FreeSql.Tests.QuestDb
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Test_SyncStructure()
|
public void Test_SyncStructure()
|
||||||
{
|
{
|
||||||
fsql.CodeFirst.SyncStructure<QuestDb_Model_Test01>();
|
Db.CodeFirst.SyncStructure<QuestDb_Model_Test01>();
|
||||||
fsql.CodeFirst.SyncStructure(typeof(Topic));
|
Db.CodeFirst.SyncStructure(typeof(Topic));
|
||||||
fsql.CodeFirst.SyncStructure(typeof(Category));
|
Db.CodeFirst.SyncStructure(typeof(Category));
|
||||||
fsql.CodeFirst.SyncStructure(typeof(CategoryType));
|
Db.CodeFirst.SyncStructure(typeof(CategoryType));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Test_SyncStructure_Type()
|
public void Test_SyncStructure_Type()
|
||||||
{
|
{
|
||||||
fsql.CodeFirst.SyncStructure<QuestDb_Model_Type01>();
|
Db.CodeFirst.SyncStructure<QuestDb_Model_Type01>();
|
||||||
var result = fsql.Insert(new QuestDb_Model_Type01()
|
var result = Db.Insert(new QuestDb_Model_Type01()
|
||||||
{
|
{
|
||||||
TestBool = false,
|
TestBool = false,
|
||||||
TestDecimal = (decimal?)153.02,
|
TestDecimal = (decimal?)153.02,
|
||||||
@@ -14,13 +14,13 @@ namespace FreeSql.Tests.QuestDb
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Test_ExistsTable()
|
public void Test_ExistsTable()
|
||||||
{
|
{
|
||||||
var existsTable = QuestDbTest.fsql.DbFirst.ExistsTable(nameof(QuestDb_Model_Test01));
|
var existsTable = QuestDbTest.Db.DbFirst.ExistsTable(nameof(QuestDb_Model_Test01));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Test_GetTablesByDatabase()
|
public void Test_GetTablesByDatabase()
|
||||||
{
|
{
|
||||||
var tablesByDatabase = QuestDbTest.fsql.DbFirst.GetTablesByDatabase("");
|
var tablesByDatabase = QuestDbTest.Db.DbFirst.GetTablesByDatabase("");
|
||||||
tablesByDatabase.ForEach(d =>
|
tablesByDatabase.ForEach(d =>
|
||||||
{
|
{
|
||||||
Debug.WriteLine(d.Name);
|
Debug.WriteLine(d.Name);
|
||||||
@@ -12,8 +12,8 @@ namespace FreeSql.Tests.QuestDb.QuestDbIssue
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Issue1757()
|
public void Issue1757()
|
||||||
{
|
{
|
||||||
restFsql.CodeFirst.SyncStructure<Test0111>();
|
RestApiDb.CodeFirst.SyncStructure<Test0111>();
|
||||||
var count = fsql.Insert(new List<Test0111>()
|
var count = Db.Insert(new List<Test0111>()
|
||||||
{
|
{
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
@@ -26,15 +26,15 @@ namespace FreeSql.Tests.QuestDb.QuestDbIssue
|
|||||||
|
|
||||||
Assert.True(count > 0);
|
Assert.True(count > 0);
|
||||||
|
|
||||||
var list = fsql.Select<Test0111>().ToList();
|
var list = Db.Select<Test0111>().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Issue1757Many()
|
public void Issue1757Many()
|
||||||
{
|
{
|
||||||
restFsql.CodeFirst.SyncStructure<Test0111>();
|
RestApiDb.CodeFirst.SyncStructure<Test0111>();
|
||||||
var count = fsql.Insert(new List<Test0111>()
|
var count = Db.Insert(new List<Test0111>()
|
||||||
{
|
{
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
@@ -61,7 +61,7 @@ namespace FreeSql.Tests.QuestDb.QuestDbIssue
|
|||||||
|
|
||||||
Assert.True(count > 0);
|
Assert.True(count > 0);
|
||||||
|
|
||||||
var list = fsql.Select<Test0111>().ToList();
|
var list = Db.Select<Test0111>().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,18 +10,18 @@ namespace FreeSql.Tests.QuestDb
|
|||||||
{
|
{
|
||||||
public class QuestDbTest
|
public class QuestDbTest
|
||||||
{
|
{
|
||||||
public static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
public static IFreeSql Db = new FreeSql.FreeSqlBuilder()
|
||||||
.UseConnectionString(FreeSql.DataType.QuestDb,
|
.UseConnectionString(FreeSql.DataType.QuestDb,
|
||||||
@"host=192.168.1.114;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
|
@"host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
|
||||||
.UseMonitorCommand(cmd => Debug.WriteLine($"Sql:{cmd.CommandText}")) //监听SQL语句
|
.UseMonitorCommand(cmd => Debug.WriteLine($"Sql:{cmd.CommandText}")) //监听SQL语句
|
||||||
.UseNoneCommandParameter(true)
|
.UseNoneCommandParameter(true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
public static IFreeSql restFsql = new FreeSql.FreeSqlBuilder()
|
public static IFreeSql RestApiDb = new FreeSql.FreeSqlBuilder()
|
||||||
.UseConnectionString(FreeSql.DataType.QuestDb,
|
.UseConnectionString(FreeSql.DataType.QuestDb,
|
||||||
@"host=192.168.1.114;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
|
@"host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
|
||||||
.UseMonitorCommand(cmd => Debug.WriteLine($"Sql:{cmd.CommandText}")) //监听SQL语句
|
.UseMonitorCommand(cmd => Debug.WriteLine($"Sql:{cmd.CommandText}")) //监听SQL语句
|
||||||
.UseQuestDbRestAPI("192.168.1.114:9000")
|
.UseQuestDbRestAPI("localhost:9000")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
}
|
}
|
||||||
18
FreeSql.sln
18
FreeSql.sln
@@ -137,6 +137,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.TDen
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.EFModel", "Extensions\FreeSql.Extensions.EFModel\FreeSql.Extensions.EFModel.csproj", "{4281AC48-6FE7-49C3-BE7B-D029058646BC}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.EFModel", "Extensions\FreeSql.Extensions.EFModel\FreeSql.Extensions.EFModel.csproj", "{4281AC48-6FE7-49C3-BE7B-D029058646BC}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSql.Tests.Provider.QuestDb", "FreeSql.Tests\FreeSql.Tests.Provider.QuestDb\FreeSql.Tests.Provider.QuestDb.csproj", "{5A59200F-9757-4E0B-B4CF-2E846F25A69A}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -831,6 +833,18 @@ Global
|
|||||||
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x64.Build.0 = Release|Any CPU
|
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x86.ActiveCfg = Release|Any CPU
|
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x86.Build.0 = Release|Any CPU
|
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -877,8 +891,8 @@ Global
|
|||||||
{4281AC48-6FE7-49C3-BE7B-D029058646BC} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
|
{4281AC48-6FE7-49C3-BE7B-D029058646BC} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
|
|
||||||
RESX_PrefixTranslations = True
|
|
||||||
RESX_NeutralResourcesLanguage = en-US
|
RESX_NeutralResourcesLanguage = en-US
|
||||||
|
RESX_PrefixTranslations = True
|
||||||
|
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -314,6 +314,142 @@ public static partial class FreeSqlGlobalExtensions
|
|||||||
freesql.Select<T1>().From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>((s, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) => s);
|
freesql.Select<T1>().From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>((s, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) => s);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region SqlServer with(nolock)、with(index) 强制索引
|
||||||
|
/// <summary>
|
||||||
|
/// SqlServer: with(nolock)<para></para>
|
||||||
|
/// 达梦: with ur<para></para>
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="that"></param>
|
||||||
|
/// <param name="lockType"></param>
|
||||||
|
/// <param name="rule">多表查询时的锁规则</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ISelect<T> WithLock<T>(this ISelect<T> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2> WithLock<T1, T2>(this ISelect<T1, T2> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3> WithLock<T1, T2, T3>(this ISelect<T1, T2, T3> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4> WithLock<T1, T2, T3, T4>(this ISelect<T1, T2, T3, T4> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5> WithLock<T1, T2, T3, T4, T5>(this ISelect<T1, T2, T3, T4, T5> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6> WithLock<T1, T2, T3, T4, T5, T6>(this ISelect<T1, T2, T3, T4, T5, T6> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7> WithLock<T1, T2, T3, T4, T5, T6, T7>(this ISelect<T1, T2, T3, T4, T5, T6, T7> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8> WithLock<T1, T2, T3, T4, T5, T6, T7, T8>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> WithLock<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithLock<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
||||||
|
static TReturn LocalWithLock<TReturn>(TReturn query, SqlServerLock lockType, Dictionary<Type, bool> rule)
|
||||||
|
{
|
||||||
|
var selectProvider = query as Select0Provider;
|
||||||
|
switch (selectProvider._orm.Ado.DataType)
|
||||||
|
{
|
||||||
|
case DataType.SqlServer:
|
||||||
|
case DataType.OdbcSqlServer:
|
||||||
|
case DataType.CustomSqlServer:
|
||||||
|
break;
|
||||||
|
case DataType.Dameng:
|
||||||
|
if ((lockType & SqlServerLock.NoLock) == SqlServerLock.NoLock &&
|
||||||
|
!selectProvider._tosqlAppendContent.Contains("with ur") &&
|
||||||
|
rule?.Any(r => r.Value && selectProvider._tables.Any(t => t.Table?.Type == r.Key)) == true)
|
||||||
|
selectProvider._tosqlAppendContent = $"{selectProvider._tosqlAppendContent} with ur";
|
||||||
|
return query;
|
||||||
|
default:
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
var oldalias = selectProvider._aliasRule;
|
||||||
|
selectProvider._aliasRule = (type, old) =>
|
||||||
|
{
|
||||||
|
if (oldalias != null) old = oldalias(type, old);
|
||||||
|
if (rule == null) return LocalAppendWithString(old, lockType.ToString());
|
||||||
|
return rule.TryGetValue(type, out var trybool) && trybool ? LocalAppendWithString(old, lockType.ToString()) : old;
|
||||||
|
};
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SqkServer with(index) 强制索引
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="that"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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) 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) && rule?.Any() != true) return query;
|
||||||
|
var selectProvider = query as Select0Provider;
|
||||||
|
switch (selectProvider._orm.Ado.DataType)
|
||||||
|
{
|
||||||
|
case DataType.SqlServer:
|
||||||
|
case DataType.OdbcSqlServer:
|
||||||
|
case DataType.CustomSqlServer:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
var oldalias = selectProvider._aliasRule;
|
||||||
|
selectProvider._aliasRule = (type, old) =>
|
||||||
|
{
|
||||||
|
if (oldalias != null) old = oldalias(type, old);
|
||||||
|
if (string.IsNullOrWhiteSpace(indexName) == false && type == selectProvider._tables[0].Table.Type) return LocalAppendWithString(old, $"index={indexName}");
|
||||||
|
if (rule == null) return old;
|
||||||
|
return rule.TryGetValue(type, out var tryidxName) && string.IsNullOrWhiteSpace(tryidxName) == false ? LocalAppendWithString(old, $"index={tryidxName}") : old;
|
||||||
|
};
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
static string LocalAppendWithString(string old, string str) => old?.Contains(" With(") == true ? old.Replace(" With(", $" With({str}, ") : $"{old} With({str})";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置全局 SqlServer: with(nolock)<para></para>
|
||||||
|
/// 设置全局 达梦: with ur<para></para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="that"></param>
|
||||||
|
public static IFreeSql SetGlobalSelectWithLock(this IFreeSql that, SqlServerLock lockType, Dictionary<Type, bool> rule)
|
||||||
|
{
|
||||||
|
var value = NativeTuple.Create(lockType, rule);
|
||||||
|
_dicSetGlobalSelectWithLock.AddOrUpdate(that.Ado.Identifier, value, (_, __) => value);
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
public static ConcurrentDictionary<Guid, NativeTuple<SqlServerLock, Dictionary<Type, bool>>> _dicSetGlobalSelectWithLock = new ConcurrentDictionary<Guid, NativeTuple<SqlServerLock, Dictionary<Type, bool>>>();
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 克隆ISelect
|
#region 克隆ISelect
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 克隆 ISelect
|
/// 克隆 ISelect
|
||||||
@@ -1543,3 +1679,22 @@ SELECT ");
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum SqlServerLock
|
||||||
|
{
|
||||||
|
NoLock = 1,
|
||||||
|
HoldLock = 2,
|
||||||
|
UpdLock = 4,
|
||||||
|
RowLock = 8,
|
||||||
|
ReadCommitted = 16,
|
||||||
|
ReadPast = 32,
|
||||||
|
ReadUnCommitted = 64,
|
||||||
|
RepeaTableRead = 256,
|
||||||
|
PagLock = 512,
|
||||||
|
Serializable = 1024,
|
||||||
|
TabLock = 2048,
|
||||||
|
TabLockX = 4096,
|
||||||
|
XLock = 8192,
|
||||||
|
NoWait = 16384
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
<!--<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
|
<!--<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
|
||||||
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) or
|
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) or
|
||||||
|
|||||||
@@ -1717,13 +1717,6 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.IDelete`1.ExecuteDeletedAsync(System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
执行SQL语句,返回被删除的记录<para></para>
|
|
||||||
注意:此方法只有 Postgresql/SqlServer/Maridb/Firebird/人大金仓 有效果
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IInsert`1.WithTransaction(System.Data.Common.DbTransaction)">
|
<member name="M:FreeSql.IInsert`1.WithTransaction(System.Data.Common.DbTransaction)">
|
||||||
<summary>
|
<summary>
|
||||||
指定事务对象
|
指定事务对象
|
||||||
@@ -1894,13 +1887,6 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.IInsert`1.ExecuteInsertedAsync(System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
执行SQL语句,返回插入后的记录<para></para>
|
|
||||||
注意:此方法只有 Postgresql/SqlServer/Maridb/Firebird/DuckDB/人大金仓 有效果
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IInsertOrUpdate`1.WithTransaction(System.Data.Common.DbTransaction)">
|
<member name="M:FreeSql.IInsertOrUpdate`1.WithTransaction(System.Data.Common.DbTransaction)">
|
||||||
<summary>
|
<summary>
|
||||||
指定事务对象
|
指定事务对象
|
||||||
@@ -3377,13 +3363,6 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.IUpdate`1.ExecuteUpdatedAsync(System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
执行SQL语句,返回更新后的记录<para></para>
|
|
||||||
注意:此方法只有 Postgresql/SqlServer/Maridb/Firebird/人大金仓 有效果
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IUpdateJoin`2.WithTransaction(System.Data.Common.DbTransaction)">
|
<member name="M:FreeSql.IUpdateJoin`2.WithTransaction(System.Data.Common.DbTransaction)">
|
||||||
<summary>
|
<summary>
|
||||||
指定事务对象
|
指定事务对象
|
||||||
@@ -3728,177 +3707,6 @@
|
|||||||
<param name="parms"></param>
|
<param name="parms"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.IAdo.ExecuteConnectTestAsync(System.Int32,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
测试数据库是否连接正确,本方法执行如下命令:<para></para>
|
|
||||||
MySql/SqlServer/PostgreSQL/达梦/人大金仓/神通: SELECT 1<para></para>
|
|
||||||
Oracle: SELECT 1 FROM dual<para></para>
|
|
||||||
</summary>
|
|
||||||
<param name="commandTimeout">命令超时设置(秒)</param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns>true: 成功, false: 失败</returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteReaderAsync(System.Func{FreeSql.Internal.Model.FetchCallbackArgs{System.Data.Common.DbDataReader},System.Threading.Tasks.Task},System.Data.CommandType,System.String,System.Data.Common.DbParameter[],System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
查询,若使用读写分离,查询【从库】条件cmdText.StartsWith("SELECT "),否则查询【主库】
|
|
||||||
</summary>
|
|
||||||
<param name="readerHander"></param>
|
|
||||||
<param name="cmdType"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="cmdParms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteReaderAsync(System.Func{FreeSql.Internal.Model.FetchCallbackArgs{System.Data.Common.DbDataReader},System.Threading.Tasks.Task},System.String,System.Object,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
查询,ExecuteReaderAsync(dr => {}, "select * from user where age > @age", new { age = 25 })<para></para>
|
|
||||||
提示:parms 参数还可以传 Dictionary<string, object>
|
|
||||||
</summary>
|
|
||||||
<param name="readerHander"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="parms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteArrayAsync(System.Data.CommandType,System.String,System.Data.Common.DbParameter[],System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
查询
|
|
||||||
</summary>
|
|
||||||
<param name="cmdType"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="cmdParms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteArrayAsync(System.String,System.Object,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
查询,ExecuteArrayAsync("select * from user where age > @age", new { age = 25 })<para></para>
|
|
||||||
提示:parms 参数还可以传 Dictionary<string, object>
|
|
||||||
</summary>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="parms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteDataSetAsync(System.Data.CommandType,System.String,System.Data.Common.DbParameter[],System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
查询
|
|
||||||
</summary>
|
|
||||||
<param name="cmdType"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="cmdParms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteDataSetAsync(System.String,System.Object,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
查询,ExecuteDataSetAsync("select * from user where age > @age; select 2", new { age = 25 })<para></para>
|
|
||||||
提示:parms 参数还可以传 Dictionary<string, object>
|
|
||||||
</summary>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="parms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteDataTableAsync(System.Data.CommandType,System.String,System.Data.Common.DbParameter[],System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
查询
|
|
||||||
</summary>
|
|
||||||
<param name="cmdType"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="cmdParms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteDataTableAsync(System.String,System.Object,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
查询,ExecuteDataTableAsync("select * from user where age > @age", new { age = 25 })<para></para>
|
|
||||||
提示:parms 参数还可以传 Dictionary<string, object>
|
|
||||||
</summary>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="parms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteNonQueryAsync(System.Data.CommandType,System.String,System.Data.Common.DbParameter[],System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
在【主库】执行
|
|
||||||
</summary>
|
|
||||||
<param name="cmdType"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="cmdParms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteNonQueryAsync(System.String,System.Object,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
在【主库】执行,ExecuteNonQueryAsync("delete from user where age > @age", new { age = 25 })<para></para>
|
|
||||||
提示:parms 参数还可以传 Dictionary<string, object>
|
|
||||||
</summary>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="parms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteScalarAsync(System.Data.CommandType,System.String,System.Data.Common.DbParameter[],System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
在【主库】执行
|
|
||||||
</summary>
|
|
||||||
<param name="cmdType"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="cmdParms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.ExecuteScalarAsync(System.String,System.Object,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
在【主库】执行,ExecuteScalarAsync("select 1 from user where age > @age", new { age = 25 })<para></para>
|
|
||||||
提示:parms 参数还可以传 Dictionary<string, object>
|
|
||||||
</summary>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="parms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.QueryAsync``1(System.Data.CommandType,System.String,System.Data.Common.DbParameter[],System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
执行SQL返回对象集合,QueryAsync<User>("select * from user where age > @age", new SqlParameter { ParameterName = "age", Value = 25 })
|
|
||||||
</summary>
|
|
||||||
<typeparam name="T"></typeparam>
|
|
||||||
<param name="cmdType"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="cmdParms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.QueryAsync``1(System.String,System.Object,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
执行SQL返回对象集合,QueryAsync<User>("select * from user where age > @age", new { age = 25 })<para></para>
|
|
||||||
提示:parms 参数还可以传 Dictionary<string, object>
|
|
||||||
</summary>
|
|
||||||
<typeparam name="T"></typeparam>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="parms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.QueryAsync``2(System.Data.CommandType,System.String,System.Data.Common.DbParameter[],System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
执行SQL返回对象集合,Query<User>("select * from user where age > @age; select * from address", new SqlParameter { ParameterName = "age", Value = 25 })
|
|
||||||
</summary>
|
|
||||||
<typeparam name="T1"></typeparam>
|
|
||||||
<typeparam name="T2"></typeparam>
|
|
||||||
<param name="cmdType"></param>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="cmdParms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.IAdo.QueryAsync``2(System.String,System.Object,System.Threading.CancellationToken)">
|
|
||||||
<summary>
|
|
||||||
执行SQL返回对象集合,Query<User, Address>("select * from user where age > @age; select * from address", new { age = 25 })<para></para>
|
|
||||||
提示:parms 参数还可以传 Dictionary<string, object>
|
|
||||||
</summary>
|
|
||||||
<typeparam name="T1"></typeparam>
|
|
||||||
<typeparam name="T2"></typeparam>
|
|
||||||
<param name="cmdText"></param>
|
|
||||||
<param name="parms"></param>
|
|
||||||
<param name="cancellationToken"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="E:FreeSql.IAop.ParseExpression">
|
<member name="E:FreeSql.IAop.ParseExpression">
|
||||||
<summary>
|
<summary>
|
||||||
可自定义解析表达式
|
可自定义解析表达式
|
||||||
@@ -4898,12 +4706,6 @@
|
|||||||
<param name="timeout">超时</param>
|
<param name="timeout">超时</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.Internal.ObjectPool.IObjectPool`1.GetAsync">
|
|
||||||
<summary>
|
|
||||||
获取资源
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.Internal.ObjectPool.IObjectPool`1.Return(FreeSql.Internal.ObjectPool.Object{`0},System.Boolean)">
|
<member name="M:FreeSql.Internal.ObjectPool.IObjectPool`1.Return(FreeSql.Internal.ObjectPool.Object{`0},System.Boolean)">
|
||||||
<summary>
|
<summary>
|
||||||
使用完毕后,归还资源
|
使用完毕后,归还资源
|
||||||
@@ -4979,12 +4781,6 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<param name="obj">资源对象</param>
|
<param name="obj">资源对象</param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.Internal.ObjectPool.IPolicy`1.OnGetAsync(FreeSql.Internal.ObjectPool.Object{`0})">
|
|
||||||
<summary>
|
|
||||||
从对象池获取对象成功的时候触发,通过该方法统计或初始化对象
|
|
||||||
</summary>
|
|
||||||
<param name="obj">资源对象</param>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.Internal.ObjectPool.IPolicy`1.OnReturn(FreeSql.Internal.ObjectPool.Object{`0})">
|
<member name="M:FreeSql.Internal.ObjectPool.IPolicy`1.OnReturn(FreeSql.Internal.ObjectPool.Object{`0})">
|
||||||
<summary>
|
<summary>
|
||||||
归还对象给对象池的时候触发
|
归还对象给对象池的时候触发
|
||||||
@@ -5984,6 +5780,32 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalExtensions.WithLock``1(FreeSql.ISelect{``0},SqlServerLock,System.Collections.Generic.Dictionary{System.Type,System.Boolean})">
|
||||||
|
<summary>
|
||||||
|
SqlServer: with(nolock)<para></para>
|
||||||
|
达梦: with ur<para></para>
|
||||||
|
</summary>
|
||||||
|
<typeparam name="T"></typeparam>
|
||||||
|
<param name="that"></param>
|
||||||
|
<param name="lockType"></param>
|
||||||
|
<param name="rule">多表查询时的锁规则</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalExtensions.WithIndex``1(FreeSql.ISelect{``0},System.String)">
|
||||||
|
<summary>
|
||||||
|
SqkServer with(index) 强制索引
|
||||||
|
</summary>
|
||||||
|
<typeparam name="T"></typeparam>
|
||||||
|
<param name="that"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalExtensions.SetGlobalSelectWithLock(IFreeSql,SqlServerLock,System.Collections.Generic.Dictionary{System.Type,System.Boolean})">
|
||||||
|
<summary>
|
||||||
|
设置全局 SqlServer: with(nolock)<para></para>
|
||||||
|
设置全局 达梦: with ur<para></para>
|
||||||
|
</summary>
|
||||||
|
<param name="that"></param>
|
||||||
|
</member>
|
||||||
<member name="M:FreeSqlGlobalExtensions.Clone``1(FreeSql.ISelect{``0})">
|
<member name="M:FreeSqlGlobalExtensions.Clone``1(FreeSql.ISelect{``0})">
|
||||||
<summary>
|
<summary>
|
||||||
克隆 ISelect
|
克隆 ISelect
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace FreeSql.Aop
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 索引配置
|
/// 索引配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<IndexAttribute> ModifyIndexResult { get; }
|
public List<IndexAttribute> ModifyIndexResult { get; internal set; }
|
||||||
}
|
}
|
||||||
public class ConfigEntityPropertyEventArgs : EventArgs
|
public class ConfigEntityPropertyEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1452,7 +1452,12 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tsc.dbParams != null) fsqlSelect0._params = tsc.dbParams;
|
if (tsc.dbParams != null)
|
||||||
|
{
|
||||||
|
if (fsqlSelect0._params?.Any() == true)
|
||||||
|
tsc.dbParams.AddRange(fsqlSelect0._params);
|
||||||
|
fsqlSelect0._params = tsc.dbParams;
|
||||||
|
}
|
||||||
fsqltables = fsqlSelect0._tables;
|
fsqltables = fsqlSelect0._tables;
|
||||||
//fsqltables[0].Alias = $"{tsc._tables[0].Alias}_{fsqltables[0].Alias}";
|
//fsqltables[0].Alias = $"{tsc._tables[0].Alias}_{fsqltables[0].Alias}";
|
||||||
if (fsqltables != tsc._tables)
|
if (fsqltables != tsc._tables)
|
||||||
@@ -1607,7 +1612,12 @@ namespace FreeSql.Internal
|
|||||||
fsql = method.Invoke(fsql, args);
|
fsql = method.Invoke(fsql, args);
|
||||||
fsqlType = fsql.GetType();
|
fsqlType = fsql.GetType();
|
||||||
fsqlSelect0 = fsql as Select0Provider;
|
fsqlSelect0 = fsql as Select0Provider;
|
||||||
if (tsc.dbParams != null) fsqlSelect0._params = tsc.dbParams;
|
if (tsc.dbParams != null)
|
||||||
|
{
|
||||||
|
if (fsqlSelect0._params?.Any() == true)
|
||||||
|
tsc.dbParams.AddRange(fsqlSelect0._params);
|
||||||
|
fsqlSelect0._params = tsc.dbParams;
|
||||||
|
}
|
||||||
fsqltables = fsqlSelect0._tables;
|
fsqltables = fsqlSelect0._tables;
|
||||||
fsqltable1SetAlias = false;
|
fsqltable1SetAlias = false;
|
||||||
if (method.Name == nameof(ISelect<object>.WithTempQuery)) fsqltable1SetAliasGai = 0;
|
if (method.Name == nameof(ISelect<object>.WithTempQuery)) fsqltable1SetAliasGai = 0;
|
||||||
|
|||||||
@@ -175,6 +175,13 @@ namespace FreeSql.Internal
|
|||||||
case MappingPriorityType.Aop:
|
case MappingPriorityType.Aop:
|
||||||
if (_orm.Aop.ConfigEntityHandler != null)
|
if (_orm.Aop.ConfigEntityHandler != null)
|
||||||
{
|
{
|
||||||
|
var aopBeforeTypes = new List<MappingPriorityType>();
|
||||||
|
foreach (var aipt in _mappingPriorityTypes)
|
||||||
|
{
|
||||||
|
if (aipt == MappingPriorityType.Aop) break;
|
||||||
|
else aopBeforeTypes.Add(aipt);
|
||||||
|
}
|
||||||
|
var aopeIndexs = GetEntityIndexAttribute(type, aopBeforeTypes);
|
||||||
var aope = new Aop.ConfigEntityEventArgs(type)
|
var aope = new Aop.ConfigEntityEventArgs(type)
|
||||||
{
|
{
|
||||||
ModifyResult = new TableAttribute
|
ModifyResult = new TableAttribute
|
||||||
@@ -183,7 +190,8 @@ namespace FreeSql.Internal
|
|||||||
OldName = attr.OldName,
|
OldName = attr.OldName,
|
||||||
_DisableSyncStructure = attr._DisableSyncStructure,
|
_DisableSyncStructure = attr._DisableSyncStructure,
|
||||||
AsTable = attr.AsTable
|
AsTable = attr.AsTable
|
||||||
}
|
},
|
||||||
|
ModifyIndexResult = aopeIndexs.ToList()
|
||||||
};
|
};
|
||||||
_orm.Aop.ConfigEntityHandler(_orm, aope);
|
_orm.Aop.ConfigEntityHandler(_orm, aope);
|
||||||
var tryattr = aope.ModifyResult;
|
var tryattr = aope.ModifyResult;
|
||||||
@@ -414,8 +422,27 @@ namespace FreeSql.Internal
|
|||||||
}
|
}
|
||||||
public IndexAttribute[] GetEntityIndexAttribute(Type type)
|
public IndexAttribute[] GetEntityIndexAttribute(Type type)
|
||||||
{
|
{
|
||||||
|
//计算 Aop 优先级后面的配置
|
||||||
|
var aopAfterTypes = new List<MappingPriorityType>();
|
||||||
|
var isAopFirst = false;
|
||||||
|
foreach (var aipt in _mappingPriorityTypes)
|
||||||
|
{
|
||||||
|
if (aipt == MappingPriorityType.Aop)
|
||||||
|
{
|
||||||
|
isAopFirst = true;
|
||||||
|
aopAfterTypes.Add(aipt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isAopFirst) aopAfterTypes.Add(aipt);
|
||||||
|
}
|
||||||
|
var indexs = GetEntityIndexAttribute(type, aopAfterTypes);
|
||||||
|
return indexs;
|
||||||
|
}
|
||||||
|
IndexAttribute[] GetEntityIndexAttribute(Type type, IEnumerable<MappingPriorityType> mappingPriorityTypes)
|
||||||
|
{
|
||||||
|
if (mappingPriorityTypes == null) mappingPriorityTypes = _mappingPriorityTypes;
|
||||||
var ret = new Dictionary<string, IndexAttribute>();
|
var ret = new Dictionary<string, IndexAttribute>();
|
||||||
foreach (var mp in _mappingPriorityTypes)
|
foreach (var mp in mappingPriorityTypes)
|
||||||
{
|
{
|
||||||
switch (mp)
|
switch (mp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,12 @@ public static partial class FreeSqlClickHouseGlobalExtensions
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
s0p.InternalOrderBy(selector);
|
s0p.InternalOrderBy(selector);
|
||||||
s0p._limitBy = $"LIMIT {(offset > 0 ? $"{offset}, " : "")}{limit} BY {s0p._orderby}";
|
s0p._limitBy = s0p._orderby;
|
||||||
|
if (s0p._limitBy.StartsWith(" \r\nORDER BY "))
|
||||||
|
s0p._limitBy = string.Concat(
|
||||||
|
$" \r\nLIMIT {(offset > 0 ? $"{offset}, " : "")}{limit} BY ",
|
||||||
|
s0p._limitBy.Substring(" \r\nORDER BY ".Length)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ namespace FreeSql.ClickHouse.Curd
|
|||||||
}
|
}
|
||||||
sb.Append(_orderby);
|
sb.Append(_orderby);
|
||||||
if (string.IsNullOrEmpty(_limitBy) == false)
|
if (string.IsNullOrEmpty(_limitBy) == false)
|
||||||
sb.Append(" \r\n").Append(_limitBy);
|
sb.Append(_limitBy);
|
||||||
if (_skip > 0 || _limit > 0)
|
if (_skip > 0 || _limit > 0)
|
||||||
sb.Append(" \r\nLIMIT ").Append(Math.Max(0, _skip)).Append(",").Append(_limit > 0 ? _limit : -1);
|
sb.Append(" \r\nLIMIT ").Append(Math.Max(0, _skip)).Append(",").Append(_limit > 0 ? _limit : -1);
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ namespace FreeSql.ClickHouse.Curd
|
|||||||
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 ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<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 ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<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 ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<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 ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<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 ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<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 ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<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, _limitBy);
|
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, _limitBy, _sample);
|
||||||
}
|
}
|
||||||
class ClickHouseSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T2 : class
|
class ClickHouseSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T2 : class
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,11 @@ namespace FreeSql.Dameng.Curd
|
|||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DamengSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public DamengSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere)
|
||||||
|
{
|
||||||
|
if (FreeSqlGlobalExtensions._dicSetGlobalSelectWithLock.TryGetValue(orm.Ado.Identifier, out var tryval))
|
||||||
|
this.WithLock(tryval.Item1, tryval.Item2);
|
||||||
|
}
|
||||||
public override ISelect<T1, T2> From<T2>(Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new DamengSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null); DamengSelect<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 DamengSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null); DamengSelect<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 DamengSelect<T1, T2, T3>(_orm, _commonUtils, _commonExpression, null); DamengSelect<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 DamengSelect<T1, T2, T3>(_orm, _commonUtils, _commonExpression, null); DamengSelect<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 DamengSelect<T1, T2, T3, T4>(_orm, _commonUtils, _commonExpression, null); DamengSelect<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 DamengSelect<T1, T2, T3, T4>(_orm, _commonUtils, _commonExpression, null); DamengSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ where {(ignoreCase ? "lower(a.owner)" : "a.owner")} in ({databaseIn}){(tbname ==
|
|||||||
if (database.Length == 1)
|
if (database.Length == 1)
|
||||||
{
|
{
|
||||||
table_id = table_id.Substring(table_id.IndexOf('.') + 1);
|
table_id = table_id.Substring(table_id.IndexOf('.') + 1);
|
||||||
schema = "";
|
//schema = "";
|
||||||
}
|
}
|
||||||
loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
|
loc2.Add(table_id, new DbTableInfo { Id = table_id, Schema = schema, Name = table, Comment = comment, Type = type });
|
||||||
loc3.Add(table_id, new Dictionary<string, DbColumnInfo>());
|
loc3.Add(table_id, new Dictionary<string, DbColumnInfo>());
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using FreeSql.Internal;
|
using FreeSql.Internal;
|
||||||
using FreeSql.Internal.Model;
|
using FreeSql.Internal.Model;
|
||||||
|
using FreeSql.Provider.QuestDb;
|
||||||
|
using FreeSql.Provider.QuestDb.Models;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@@ -7,6 +9,7 @@ using System.Collections.Generic;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -32,15 +35,16 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
internal void InternalClearData() => ClearData();
|
internal void InternalClearData() => ClearData();
|
||||||
internal string InternalTableRuleInvoke() => TableRuleInvoke();
|
internal string InternalTableRuleInvoke() => TableRuleInvoke();
|
||||||
|
|
||||||
private int InternelExecuteAffrows()
|
private async Task<int> RestApiExecuteAffrowsAsync()
|
||||||
{
|
{
|
||||||
//如果设置了RestAPI的Url则走HTTP
|
//如果设置了RestAPI的Url则走HTTP
|
||||||
|
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
|
||||||
var sql = ToSql();
|
var sql = ToSql();
|
||||||
var execAsync = RestAPIExtension.ExecAsync(sql).GetAwaiter().GetResult();
|
var execAsync = await apiFeatures.ExecAsync(sql);
|
||||||
var resultHash = new Hashtable();
|
var result = new RestApiExecResponseJsonBody();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resultHash = JsonConvert.DeserializeObject<Hashtable>(execAsync);
|
result = JsonConvert.DeserializeObject<RestApiExecResponseJsonBody>(execAsync);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -49,18 +53,20 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
throw new Exception("请确认new FreeSqlBuilder().UseQuestDbRestAPI()中设置的用户名密码是否正确.");
|
throw new Exception("请确认new FreeSqlBuilder().UseQuestDbRestAPI()中设置的用户名密码是否正确.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var ddl = resultHash["ddl"]?.ToString();
|
|
||||||
return ddl?.ToLower() == "ok" ? 1 : 0;
|
return result.IsSuccessful ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int ExecuteAffrows()
|
public override int ExecuteAffrows()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(RestAPIExtension.BaseUrl))
|
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
|
||||||
|
if (apiFeatures == null || string.IsNullOrWhiteSpace(apiFeatures.BaseAddress))
|
||||||
{
|
{
|
||||||
return base.SplitExecuteAffrows(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
return base.SplitExecuteAffrows(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
||||||
_batchParameterLimit > 0 ? _batchParameterLimit : 3000);
|
_batchParameterLimit > 0 ? _batchParameterLimit : 3000);
|
||||||
}
|
}
|
||||||
return InternelExecuteAffrows();
|
|
||||||
|
return RestApiExecuteAffrowsAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override long ExecuteIdentity() => base.SplitExecuteIdentity(
|
public override long ExecuteIdentity() => base.SplitExecuteIdentity(
|
||||||
@@ -170,14 +176,16 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
#else
|
#else
|
||||||
public override Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default)
|
public override Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(RestAPIExtension.BaseUrl))
|
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
|
||||||
|
if (apiFeatures == null || string.IsNullOrWhiteSpace(apiFeatures.BaseAddress))
|
||||||
{
|
{
|
||||||
return base.SplitExecuteAffrowsAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
return base.SplitExecuteAffrowsAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
||||||
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
||||||
}
|
}
|
||||||
return Task.FromResult(InternelExecuteAffrows());
|
|
||||||
|
return RestApiExecuteAffrowsAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override Task<long> ExecuteIdentityAsync(CancellationToken cancellationToken = default) =>
|
public override Task<long> ExecuteIdentityAsync(CancellationToken cancellationToken = default) =>
|
||||||
base.SplitExecuteIdentityAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
base.SplitExecuteIdentityAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
||||||
@@ -187,7 +195,7 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
base.SplitExecuteInsertedAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
base.SplitExecuteInsertedAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
|
||||||
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
||||||
|
|
||||||
async protected override Task<long> RawExecuteIdentityAsync(CancellationToken cancellationToken = default)
|
protected override async Task<long> RawExecuteIdentityAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var sql = this.ToSql();
|
var sql = this.ToSql();
|
||||||
if (string.IsNullOrEmpty(sql)) return 0;
|
if (string.IsNullOrEmpty(sql)) return 0;
|
||||||
@@ -243,7 +251,7 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
async protected override Task<List<T1>> RawExecuteInsertedAsync(CancellationToken cancellationToken = default)
|
protected override async Task<List<T1>> RawExecuteInsertedAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var sql = this.ToSql();
|
var sql = this.ToSql();
|
||||||
if (string.IsNullOrEmpty(sql)) return new List<T1>();
|
if (string.IsNullOrEmpty(sql)) return new List<T1>();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using FreeSql.Internal;
|
using FreeSql.Internal;
|
||||||
using FreeSql.Internal.Model;
|
using FreeSql.Internal.Model;
|
||||||
|
using FreeSql.Provider.QuestDb;
|
||||||
|
using FreeSql.Provider.QuestDb.Models;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@@ -31,14 +33,16 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
|
|
||||||
internal void InternalToSqlCaseWhenEnd(StringBuilder sb, ColumnInfo col) => ToSqlCaseWhenEnd(sb, col);
|
internal void InternalToSqlCaseWhenEnd(StringBuilder sb, ColumnInfo col) => ToSqlCaseWhenEnd(sb, col);
|
||||||
|
|
||||||
private int InternelExecuteAffrows()
|
private async Task<int> RestApiExecuteAffrowsAsync()
|
||||||
{
|
{
|
||||||
|
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
|
||||||
var sql = ToSql();
|
var sql = ToSql();
|
||||||
var execAsync = RestAPIExtension.ExecAsync(sql).GetAwaiter().GetResult();
|
|
||||||
var resultHash = new Hashtable();
|
var execAsync = await apiFeatures.ExecAsync(sql);
|
||||||
|
var result = new RestApiExecResponseJsonBody();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resultHash = JsonConvert.DeserializeObject<Hashtable>(execAsync);
|
result = JsonConvert.DeserializeObject<RestApiExecResponseJsonBody>(execAsync);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -47,26 +51,29 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
throw new Exception("请确认new FreeSqlBuilder().UseQuestDbRestAPI()中设置的用户名密码是否正确.");
|
throw new Exception("请确认new FreeSqlBuilder().UseQuestDbRestAPI()中设置的用户名密码是否正确.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var ddl = resultHash["ddl"]?.ToString();
|
|
||||||
var updated = Convert.ToInt32(resultHash["updated"]);
|
return result.IsSuccessful ? result.Updated : 0;
|
||||||
return ddl?.ToLower() == "ok" ? updated : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int ExecuteAffrows()
|
public override int ExecuteAffrows()
|
||||||
{
|
{
|
||||||
//如果设置了RestAPI中Url则走HTTP
|
//如果设置了RestApi 则走HTTP执行Sql
|
||||||
if (string.IsNullOrWhiteSpace(RestAPIExtension.BaseUrl))
|
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
|
||||||
|
if (apiFeatures == null || string.IsNullOrWhiteSpace(apiFeatures.BaseAddress))
|
||||||
{
|
{
|
||||||
return base.SplitExecuteAffrows(_batchRowsLimit > 0 ? _batchRowsLimit : 500,
|
return base.SplitExecuteAffrows(_batchRowsLimit > 0 ? _batchRowsLimit : 500,
|
||||||
_batchParameterLimit > 0 ? _batchParameterLimit : 3000);
|
_batchParameterLimit > 0 ? _batchParameterLimit : 3000);
|
||||||
}
|
}
|
||||||
return InternelExecuteAffrows();
|
|
||||||
|
return RestApiExecuteAffrowsAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override List<TReturn> ExecuteUpdated<TReturn>(IEnumerable<ColumnInfo> columns) => base.SplitExecuteUpdated<TReturn>(_batchRowsLimit > 0 ? _batchRowsLimit : 500, _batchParameterLimit > 0 ? _batchParameterLimit : 3000, columns);
|
protected override List<TReturn> ExecuteUpdated<TReturn>(IEnumerable<ColumnInfo> columns) =>
|
||||||
|
base.SplitExecuteUpdated<TReturn>(_batchRowsLimit > 0 ? _batchRowsLimit : 500,
|
||||||
|
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, columns);
|
||||||
|
|
||||||
protected override List<TReturn> RawExecuteUpdated<TReturn>(IEnumerable<ColumnInfo> columns)
|
protected override List<TReturn> RawExecuteUpdated<TReturn>(IEnumerable<ColumnInfo> columns)
|
||||||
{
|
{
|
||||||
var ret = new List<TReturn>();
|
var ret = new List<TReturn>();
|
||||||
DbParameter[] dbParms = null;
|
DbParameter[] dbParms = null;
|
||||||
StringBuilder sbret = null;
|
StringBuilder sbret = null;
|
||||||
@@ -94,10 +101,11 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
|
|
||||||
Exception exception = null;
|
Exception exception = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
|
var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
|
||||||
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
|
var rettmp = _orm.Ado.Query<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql,
|
||||||
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
|
_commandTimeout, dbParms);
|
||||||
|
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
|
||||||
ret.AddRange(rettmp);
|
ret.AddRange(rettmp);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -178,20 +186,25 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
#else
|
#else
|
||||||
public override Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default)
|
public override Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(RestAPIExtension.BaseUrl))
|
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
|
||||||
|
if (apiFeatures == null || string.IsNullOrWhiteSpace(apiFeatures.BaseAddress))
|
||||||
{
|
{
|
||||||
return base.SplitExecuteAffrowsAsync(_batchRowsLimit > 0 ? _batchRowsLimit : 500,
|
return base.SplitExecuteAffrowsAsync(_batchRowsLimit > 0 ? _batchRowsLimit : 500,
|
||||||
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.FromResult(InternelExecuteAffrows());
|
return RestApiExecuteAffrowsAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override Task<List<TReturn>> ExecuteUpdatedAsync<TReturn>(IEnumerable<ColumnInfo> columns, CancellationToken cancellationToken = default) => base.SplitExecuteUpdatedAsync<TReturn>(_batchRowsLimit > 0 ? _batchRowsLimit : 500, _batchParameterLimit > 0 ? _batchParameterLimit : 3000, columns, cancellationToken);
|
protected override Task<List<TReturn>> ExecuteUpdatedAsync<TReturn>(IEnumerable<ColumnInfo> columns,
|
||||||
|
CancellationToken cancellationToken = default) => base.SplitExecuteUpdatedAsync<TReturn>(
|
||||||
|
_batchRowsLimit > 0 ? _batchRowsLimit : 500, _batchParameterLimit > 0 ? _batchParameterLimit : 3000,
|
||||||
|
columns, cancellationToken);
|
||||||
|
|
||||||
async protected override Task<List<TReturn>> RawExecuteUpdatedAsync<TReturn>(IEnumerable<ColumnInfo> columns, CancellationToken cancellationToken = default)
|
protected override async Task<List<TReturn>> RawExecuteUpdatedAsync<TReturn>(IEnumerable<ColumnInfo> columns,
|
||||||
{
|
CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
var ret = new List<TReturn>();
|
var ret = new List<TReturn>();
|
||||||
DbParameter[] dbParms = null;
|
DbParameter[] dbParms = null;
|
||||||
StringBuilder sbret = null;
|
StringBuilder sbret = null;
|
||||||
@@ -219,10 +232,11 @@ namespace FreeSql.QuestDb.Curd
|
|||||||
|
|
||||||
Exception exception = null;
|
Exception exception = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
|
var queryType = typeof(TReturn) == typeof(T1) ? (_table.TypeLazy ?? _table.Type) : null;
|
||||||
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
|
var rettmp = await _orm.Ado.QueryAsync<TReturn>(queryType, _connection, _transaction,
|
||||||
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
|
CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
|
||||||
|
ValidateVersionAndThrow(rettmp.Count, sql, dbParms);
|
||||||
ret.AddRange(rettmp);
|
ret.AddRange(rettmp);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace FreeSql.Provider.QuestDb.Models
|
||||||
|
{
|
||||||
|
internal class QuestResetApiFeatures
|
||||||
|
{
|
||||||
|
internal string BaseAddress { get; set; }
|
||||||
|
|
||||||
|
internal string BasicToken { get; set; }
|
||||||
|
|
||||||
|
internal HttpClient HttpClient => ServiceContainer.GetService<IHttpClientFactory>().CreateClient("QuestDb");
|
||||||
|
|
||||||
|
internal async Task<string> ExecAsync(string sql)
|
||||||
|
{
|
||||||
|
//HTTP GET 执行SQL
|
||||||
|
var url = $"exec?query={HttpUtility.UrlEncode(sql)}";
|
||||||
|
if (!string.IsNullOrWhiteSpace(BasicToken))
|
||||||
|
HttpClient.DefaultRequestHeaders.Add("Authorization", BasicToken);
|
||||||
|
var httpResponseMessage = await HttpClient.GetAsync(url);
|
||||||
|
var result = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace FreeSql.Provider.QuestDb.Models
|
||||||
|
{
|
||||||
|
internal class RestApiExecResponseJsonBody
|
||||||
|
{
|
||||||
|
[JsonProperty("ddl")]
|
||||||
|
public string Ddl { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("dml")]
|
||||||
|
public string Dml { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("updated")]
|
||||||
|
public int Updated { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IsSuccessful => string.Equals(Ddl, "ok", StringComparison.CurrentCultureIgnoreCase) ||
|
||||||
|
string.Equals(Dml, "ok", StringComparison.CurrentCultureIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace FreeSql.Provider.QuestDb
|
|
||||||
{
|
|
||||||
internal class QuestDbContainer
|
|
||||||
{
|
|
||||||
//作用于HttpClientFatory
|
|
||||||
private static IServiceCollection Services;
|
|
||||||
internal static IServiceProvider ServiceProvider { get; private set; }
|
|
||||||
|
|
||||||
internal static void Initialize(Action<IServiceCollection> service)
|
|
||||||
{
|
|
||||||
Services = new ServiceCollection();
|
|
||||||
service?.Invoke(Services);
|
|
||||||
ServiceProvider = Services.BuildServiceProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static T GetService<T>()
|
|
||||||
{
|
|
||||||
return ServiceProvider.GetService<T>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
using CsvHelper;
|
using CsvHelper;
|
||||||
using FreeSql;
|
using FreeSql;
|
||||||
using FreeSql.Internal.CommonProvider;
|
using FreeSql.Provider.QuestDb;
|
||||||
using FreeSql.Internal.Model;
|
using FreeSql.Provider.QuestDb.Models;
|
||||||
using FreeSql.QuestDb;
|
using FreeSql.QuestDb;
|
||||||
using FreeSql.QuestDb.Curd;
|
using FreeSql.QuestDb.Curd;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Npgsql;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -18,9 +17,6 @@ using System.Net.Http;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
|
||||||
using FreeSql.Provider.QuestDb;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
public static partial class QuestDbGlobalExtensions
|
public static partial class QuestDbGlobalExtensions
|
||||||
{
|
{
|
||||||
@@ -35,8 +31,51 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
|
|
||||||
private static readonly QuestDbAdo _questDbAdo = new QuestDbAdo();
|
private static readonly QuestDbAdo _questDbAdo = new QuestDbAdo();
|
||||||
|
|
||||||
public static FreeSqlBuilder UseQuestDbRestAPI(this FreeSqlBuilder build, string host, string username = "",
|
/// <summary>
|
||||||
string password = "") => RestAPIExtension.UseQuestDbRestAPI(build, host, username, password);
|
/// 启动QuestDb Http功能
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder"></param>
|
||||||
|
/// <param name="host"></param>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <param name="password"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static FreeSqlBuilder UseQuestDbRestAPI(this FreeSqlBuilder builder, string host, string username = "",
|
||||||
|
string password = "")
|
||||||
|
{
|
||||||
|
//初始化容器,添加HttpClient
|
||||||
|
ServiceContainer.Initialize(service =>
|
||||||
|
{
|
||||||
|
var apiFeatures = new QuestResetApiFeatures
|
||||||
|
{
|
||||||
|
BaseAddress = host.StartsWith("http") ? host : $"http://{host}"
|
||||||
|
};
|
||||||
|
|
||||||
|
service.AddHttpClient("QuestDb", client => client.BaseAddress = new Uri(apiFeatures.BaseAddress))
|
||||||
|
.ConfigurePrimaryHttpMessageHandler(handlerBuilder =>
|
||||||
|
{
|
||||||
|
//忽略SSL验证
|
||||||
|
return new HttpClientHandler
|
||||||
|
{
|
||||||
|
ClientCertificateOptions = ClientCertificateOption.Manual,
|
||||||
|
ServerCertificateCustomValidationCallback =
|
||||||
|
(httpRequestMessage, cert, certChain, policyErrors) => true
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password))
|
||||||
|
{
|
||||||
|
var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));
|
||||||
|
apiFeatures.BasicToken = $"Basic {base64}";
|
||||||
|
}
|
||||||
|
|
||||||
|
service.AddSingleton(apiFeatures);
|
||||||
|
});
|
||||||
|
|
||||||
|
//RestApi需要无参数
|
||||||
|
builder.UseNoneCommandParameter(true);
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。
|
/// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。
|
||||||
@@ -50,7 +89,7 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
public static ISelect<T1> LatestOn<T1, TKey>(this ISelect<T1> select, Expression<Func<T1, DateTime?>> timestamp,
|
public static ISelect<T1> LatestOn<T1, TKey>(this ISelect<T1> select, Expression<Func<T1, DateTime?>> timestamp,
|
||||||
Expression<Func<T1, TKey>> partition)
|
Expression<Func<T1, TKey>> partition)
|
||||||
{
|
{
|
||||||
LatestOnExtension.InternelImpl(timestamp, partition);
|
LatestOnExtension.InternalImpl(timestamp, partition);
|
||||||
return select;
|
return select;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +106,7 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
Expression<Func<T1, DateTime?>> timestamp,
|
Expression<Func<T1, DateTime?>> timestamp,
|
||||||
Expression<Func<T1, TKey>> partition) where T2 : class
|
Expression<Func<T1, TKey>> partition) where T2 : class
|
||||||
{
|
{
|
||||||
LatestOnExtension.InternelImpl(timestamp, partition);
|
LatestOnExtension.InternalImpl(timestamp, partition);
|
||||||
return select;
|
return select;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +123,7 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
Expression<Func<T1, DateTime?>> timestamp,
|
Expression<Func<T1, DateTime?>> timestamp,
|
||||||
Expression<Func<T1, TKey>> partition) where T2 : class where T3 : class
|
Expression<Func<T1, TKey>> partition) where T2 : class where T3 : class
|
||||||
{
|
{
|
||||||
LatestOnExtension.InternelImpl(timestamp, partition);
|
LatestOnExtension.InternalImpl(timestamp, partition);
|
||||||
return select;
|
return select;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +140,7 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
Expression<Func<T1, DateTime?>> timestamp,
|
Expression<Func<T1, DateTime?>> timestamp,
|
||||||
Expression<Func<T1, TKey>> partition) where T2 : class where T3 : class where T4 : class
|
Expression<Func<T1, TKey>> partition) where T2 : class where T3 : class where T4 : class
|
||||||
{
|
{
|
||||||
LatestOnExtension.InternelImpl(timestamp, partition);
|
LatestOnExtension.InternalImpl(timestamp, partition);
|
||||||
return select;
|
return select;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,19 +201,19 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
public static async Task<int> ExecuteQuestDbBulkCopyAsync<T>(this IInsert<T> that,
|
public static async Task<int> ExecuteQuestDbBulkCopyAsync<T>(this IInsert<T> that,
|
||||||
string dateFormat = "yyyy/M/d H:mm:ss") where T : class
|
string dateFormat = "yyyy/M/d H:mm:ss") where T : class
|
||||||
{
|
{
|
||||||
//思路:通过提供的RestAPI imp,实现快速复制
|
var features = ServiceContainer.GetService<QuestResetApiFeatures>();
|
||||||
if (string.IsNullOrWhiteSpace(RestAPIExtension.BaseUrl))
|
|
||||||
|
if (string.IsNullOrWhiteSpace(features.BaseAddress))
|
||||||
{
|
{
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"BulkCopy功能需要启用RestAPI,启用方式:new FreeSqlBuilder().UseQuestDbRestAPI(\"localhost:9000\", \"username\", \"password\")");
|
@"BulkCopy功能需要启用RestAPI,启用方式:new FreeSqlBuilder().UseQuestDbRestAPI(""localhost:9000"", ""username"", ""password"")");
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = 0;
|
var result = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var client = QuestDbContainer.GetService<IHttpClientFactory>().CreateClient();
|
var boundary = $"---------------{DateTime.Now.Ticks:x}";
|
||||||
var boundary = "---------------" + DateTime.Now.Ticks.ToString("x");
|
|
||||||
var list = new List<Hashtable>();
|
var list = new List<Hashtable>();
|
||||||
var insert = that as QuestDbInsert<T>;
|
var insert = that as QuestDbInsert<T>;
|
||||||
var name = insert.InternalTableRuleInvoke(); //获取表名
|
var name = insert.InternalTableRuleInvoke(); //获取表名
|
||||||
@@ -199,7 +238,7 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
var schema = JsonConvert.SerializeObject(list);
|
var schema = JsonConvert.SerializeObject(list);
|
||||||
using (MemoryStream stream = new MemoryStream())
|
using (var stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
//写入CSV文件
|
//写入CSV文件
|
||||||
using (var writer = new StreamWriter(stream))
|
using (var writer = new StreamWriter(stream))
|
||||||
@@ -208,29 +247,27 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
await csv.WriteRecordsAsync(insert._source);
|
await csv.WriteRecordsAsync(insert._source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var client = features.HttpClient;
|
||||||
var httpContent = new MultipartFormDataContent(boundary);
|
var httpContent = new MultipartFormDataContent(boundary);
|
||||||
if (!string.IsNullOrWhiteSpace(RestAPIExtension.authorization))
|
if (!string.IsNullOrWhiteSpace(features.BasicToken))
|
||||||
client.DefaultRequestHeaders.Add("Authorization", RestAPIExtension.authorization);
|
client.DefaultRequestHeaders.Add("Authorization", features.BasicToken);
|
||||||
httpContent.Add(new StringContent(schema), "schema");
|
httpContent.Add(new StringContent(schema), "schema");
|
||||||
httpContent.Add(new ByteArrayContent(stream.ToArray()), "data");
|
httpContent.Add(new ByteArrayContent(stream.ToArray()), "data");
|
||||||
//boundary带双引号 可能导致服务器错误情况
|
|
||||||
httpContent.Headers.Remove("Content-Type");
|
httpContent.Headers.Remove("Content-Type");
|
||||||
httpContent.Headers.TryAddWithoutValidation("Content-Type",
|
httpContent.Headers.TryAddWithoutValidation("Content-Type",
|
||||||
"multipart/form-data; boundary=" + boundary);
|
$"multipart/form-data; boundary={boundary}");
|
||||||
var httpResponseMessage =
|
var httpResponseMessage =
|
||||||
await client.PostAsync($"{RestAPIExtension.BaseUrl}/imp?name={name}", httpContent);
|
await client.PostAsync($"imp?name={name}", httpContent);
|
||||||
var readAsStringAsync = await httpResponseMessage.Content.ReadAsStringAsync();
|
var readAsStringAsync = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||||
var splitByLine = SplitByLine(readAsStringAsync);
|
var splitByLine = SplitByLine(readAsStringAsync);
|
||||||
foreach (var s in splitByLine)
|
foreach (var strings in from s in splitByLine
|
||||||
|
where s.Contains("Rows")
|
||||||
|
select s.Split('|')
|
||||||
|
into strings
|
||||||
|
where strings[1].Trim() == "Rows imported"
|
||||||
|
select strings)
|
||||||
{
|
{
|
||||||
if (s.Contains("Rows"))
|
result = Convert.ToInt32(strings[2].Trim());
|
||||||
{
|
|
||||||
var strings = s.Split('|');
|
|
||||||
if (strings[1].Trim() == "Rows imported")
|
|
||||||
{
|
|
||||||
result = Convert.ToInt32(strings[2].Trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,7 +286,8 @@ public static partial class QuestDbGlobalExtensions
|
|||||||
/// <param name="insert"></param>
|
/// <param name="insert"></param>
|
||||||
/// <param name="dateFormat">导入时,时间格式 默认:yyyy/M/d H:mm:ss</param>
|
/// <param name="dateFormat">导入时,时间格式 默认:yyyy/M/d H:mm:ss</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static int ExecuteQuestDbBulkCopy<T>(this IInsert<T> insert, string dateFormat = "yyyy/M/d H:mm:ss") where T : class
|
public static int ExecuteQuestDbBulkCopy<T>(this IInsert<T> insert, string dateFormat = "yyyy/M/d H:mm:ss")
|
||||||
|
where T : class
|
||||||
{
|
{
|
||||||
return ExecuteQuestDbBulkCopyAsync(insert, dateFormat).ConfigureAwait(false).GetAwaiter().GetResult();
|
return ExecuteQuestDbBulkCopyAsync(insert, dateFormat).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
@@ -294,7 +332,7 @@ static class LatestOnExtension
|
|||||||
LatestOnString.Value = string.Empty;
|
LatestOnString.Value = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void InternelImpl<T1, TKey>(Expression<Func<T1, DateTime?>> timestamp,
|
internal static void InternalImpl<T1, TKey>(Expression<Func<T1, DateTime?>> timestamp,
|
||||||
Expression<Func<T1, TKey>> partition)
|
Expression<Func<T1, TKey>> partition)
|
||||||
{
|
{
|
||||||
IsExistence.Value = true;
|
IsExistence.Value = true;
|
||||||
@@ -306,44 +344,4 @@ static class LatestOnExtension
|
|||||||
var _partition = expressionVisitor.Fields();
|
var _partition = expressionVisitor.Fields();
|
||||||
LatestOnString.Value = string.Format(latestOnTemple, _timestamp, _partition);
|
LatestOnString.Value = string.Format(latestOnTemple, _timestamp, _partition);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static class RestAPIExtension
|
|
||||||
{
|
|
||||||
internal static string BaseUrl = string.Empty;
|
|
||||||
internal static string authorization = string.Empty;
|
|
||||||
|
|
||||||
internal static async Task<string> ExecAsync(string sql)
|
|
||||||
{
|
|
||||||
//HTTP GET 执行SQL
|
|
||||||
var result = string.Empty;
|
|
||||||
var client = QuestDbContainer.GetService<IHttpClientFactory>().CreateClient();
|
|
||||||
var url = $"{BaseUrl}/exec?query={HttpUtility.UrlEncode(sql)}";
|
|
||||||
if (!string.IsNullOrWhiteSpace(authorization))
|
|
||||||
client.DefaultRequestHeaders.Add("Authorization", authorization);
|
|
||||||
var httpResponseMessage = await client.GetAsync(url);
|
|
||||||
result = await httpResponseMessage.Content.ReadAsStringAsync();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static FreeSqlBuilder UseQuestDbRestAPI(FreeSqlBuilder buider, string host, string username = "",
|
|
||||||
string password = "")
|
|
||||||
{
|
|
||||||
BaseUrl = host;
|
|
||||||
if (BaseUrl.EndsWith("/"))
|
|
||||||
BaseUrl = BaseUrl.Remove(BaseUrl.Length - 1);
|
|
||||||
|
|
||||||
if (!BaseUrl.ToLower().StartsWith("http"))
|
|
||||||
BaseUrl = $"http://{BaseUrl}";
|
|
||||||
//生成TOKEN
|
|
||||||
if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password))
|
|
||||||
{
|
|
||||||
var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));
|
|
||||||
authorization = $"Basic {base64}";
|
|
||||||
}
|
|
||||||
|
|
||||||
//RestApi需要无参数
|
|
||||||
buider.UseNoneCommandParameter(true);
|
|
||||||
return buider;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -118,10 +118,6 @@ namespace FreeSql.QuestDb
|
|||||||
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] =
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] =
|
||||||
typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
|
|
||||||
QuestDbContainer.Initialize(service =>
|
|
||||||
{
|
|
||||||
service.AddHttpClient();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
Providers/FreeSql.Provider.QuestDb/ServiceContainer.cs
Normal file
28
Providers/FreeSql.Provider.QuestDb/ServiceContainer.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace FreeSql.Provider.QuestDb
|
||||||
|
{
|
||||||
|
internal class ServiceContainer
|
||||||
|
{
|
||||||
|
private static IServiceCollection _services;
|
||||||
|
private static IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
|
internal static void Initialize(Action<IServiceCollection> service)
|
||||||
|
{
|
||||||
|
_services = new ServiceCollection();
|
||||||
|
service?.Invoke(_services);
|
||||||
|
_serviceProvider = _services.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static T GetService<T>()
|
||||||
|
{
|
||||||
|
return _serviceProvider == null ? default : _serviceProvider.GetService<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ namespace FreeSql.SqlServer.Curd
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
|
public SqlServerSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) {
|
||||||
if (FreeSqlSqlServerGlobalExtensions._dicSetGlobalSelectWithLock.TryGetValue(orm.Ado.Identifier, out var tryval))
|
if (FreeSqlGlobalExtensions._dicSetGlobalSelectWithLock.TryGetValue(orm.Ado.Identifier, out var tryval))
|
||||||
this.WithLock(tryval.Item1, tryval.Item2);
|
this.WithLock(tryval.Item1, tryval.Item2);
|
||||||
}
|
}
|
||||||
public override ISelect<T1, T2> From<T2>(Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new SqlServerSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null); SqlServerSelect<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 SqlServerSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null); SqlServerSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -28,133 +28,6 @@ public static partial class FreeSqlSqlServerGlobalExtensions
|
|||||||
public static string FormatSqlServer(this string that, params object[] args) => _sqlserverAdo.Addslashes(that, args);
|
public static string FormatSqlServer(this string that, params object[] args) => _sqlserverAdo.Addslashes(that, args);
|
||||||
static FreeSql.SqlServer.SqlServerAdo _sqlserverAdo = new FreeSql.SqlServer.SqlServerAdo();
|
static FreeSql.SqlServer.SqlServerAdo _sqlserverAdo = new FreeSql.SqlServer.SqlServerAdo();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// SqlServer with(nolock) 查询
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="that"></param>
|
|
||||||
/// <param name="lockType"></param>
|
|
||||||
/// <param name="rule">多表查询时的锁规则</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static ISelect<T> WithLock<T>(this ISelect<T> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2> WithLock<T1, T2>(this ISelect<T1, T2> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3> WithLock<T1, T2, T3>(this ISelect<T1, T2, T3> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4> WithLock<T1, T2, T3, T4>(this ISelect<T1, T2, T3, T4> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5> WithLock<T1, T2, T3, T4, T5>(this ISelect<T1, T2, T3, T4, T5> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6> WithLock<T1, T2, T3, T4, T5, T6>(this ISelect<T1, T2, T3, T4, T5, T6> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7> WithLock<T1, T2, T3, T4, T5, T6, T7>(this ISelect<T1, T2, T3, T4, T5, T6, T7> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> rule = null) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8> WithLock<T1, T2, T3, T4, T5, T6, T7, T8>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> WithLock<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithLock<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> that, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> WithLock<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, SqlServerLock lockType = SqlServerLock.NoLock, Dictionary<Type, bool> 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 => LocalWithLock(that, lockType, rule);
|
|
||||||
static TReturn LocalWithLock<TReturn>(TReturn query, SqlServerLock lockType, Dictionary<Type, bool> rule)
|
|
||||||
{
|
|
||||||
var selectProvider = query as Select0Provider;
|
|
||||||
switch (selectProvider._orm.Ado.DataType)
|
|
||||||
{
|
|
||||||
case DataType.SqlServer:
|
|
||||||
case DataType.OdbcSqlServer:
|
|
||||||
case DataType.CustomSqlServer:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
var oldalias = selectProvider._aliasRule;
|
|
||||||
selectProvider._aliasRule = (type, old) =>
|
|
||||||
{
|
|
||||||
if (oldalias != null) old = oldalias(type, old);
|
|
||||||
if (rule == null) return LocalAppendWithString(old, lockType.ToString());
|
|
||||||
return rule.TryGetValue(type, out var trybool) && trybool ? LocalAppendWithString(old, lockType.ToString()) : old;
|
|
||||||
};
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// SqkServer with(index) 强制索引
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="that"></param>
|
|
||||||
/// <param name="rule"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
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) 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) && rule?.Any() != true) return query;
|
|
||||||
var selectProvider = query as Select0Provider;
|
|
||||||
switch (selectProvider._orm.Ado.DataType)
|
|
||||||
{
|
|
||||||
case DataType.SqlServer:
|
|
||||||
case DataType.OdbcSqlServer:
|
|
||||||
case DataType.CustomSqlServer:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
var oldalias = selectProvider._aliasRule;
|
|
||||||
selectProvider._aliasRule = (type, old) =>
|
|
||||||
{
|
|
||||||
if (oldalias != null) old = oldalias(type, old);
|
|
||||||
if (string.IsNullOrWhiteSpace(indexName) == false && type == selectProvider._tables[0].Table.Type) return LocalAppendWithString(old, $"index={indexName}");
|
|
||||||
if (rule == null) return old;
|
|
||||||
return rule.TryGetValue(type, out var tryidxName) && string.IsNullOrWhiteSpace(tryidxName) == false ? LocalAppendWithString(old, $"index={tryidxName}") : old;
|
|
||||||
};
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
static string LocalAppendWithString(string old, string str) => old?.Contains(" With(") == true ? old.Replace(" With(", $" With({str}, ") : $"{old} With({str})";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置全局 SqlServer with(nolock) 查询
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="that"></param>
|
|
||||||
/// <param name="options"></param>
|
|
||||||
public static IFreeSql SetGlobalSelectWithLock(this IFreeSql that, SqlServerLock lockType, Dictionary<Type, bool> rule)
|
|
||||||
{
|
|
||||||
var value = NativeTuple.Create(lockType, rule);
|
|
||||||
_dicSetGlobalSelectWithLock.AddOrUpdate(that.Ado.Identifier, value, (_, __) => value);
|
|
||||||
return that;
|
|
||||||
}
|
|
||||||
internal static ConcurrentDictionary<Guid, NativeTuple<SqlServerLock, Dictionary<Type, bool>>> _dicSetGlobalSelectWithLock = new ConcurrentDictionary<Guid, NativeTuple<SqlServerLock, Dictionary<Type, bool>>>();
|
|
||||||
|
|
||||||
#region ExecuteSqlBulkCopy
|
#region ExecuteSqlBulkCopy
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 批量插入或更新(操作的字段数量超过 2000 时收益大)<para></para>
|
/// 批量插入或更新(操作的字段数量超过 2000 时收益大)<para></para>
|
||||||
@@ -440,22 +313,3 @@ public static partial class FreeSqlSqlServerGlobalExtensions
|
|||||||
#endif
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum SqlServerLock
|
|
||||||
{
|
|
||||||
NoLock = 1,
|
|
||||||
HoldLock = 2,
|
|
||||||
UpdLock = 4,
|
|
||||||
RowLock = 8,
|
|
||||||
ReadCommitted = 16,
|
|
||||||
ReadPast = 32,
|
|
||||||
ReadUnCommitted = 64,
|
|
||||||
RepeaTableRead = 256,
|
|
||||||
PagLock = 512,
|
|
||||||
Serializable = 1024,
|
|
||||||
TabLock = 2048,
|
|
||||||
TabLockX = 4096,
|
|
||||||
XLock = 8192,
|
|
||||||
NoWait = 16384
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ namespace FreeSql.Sqlite
|
|||||||
if (ignoreCase) tbname = tbname.Select(a => a.ToLower()).ToArray();
|
if (ignoreCase) tbname = tbname.Select(a => a.ToLower()).ToArray();
|
||||||
database = new[] { tbname[0] };
|
database = new[] { tbname[0] };
|
||||||
}
|
}
|
||||||
else if (database == null || database.Any() == false)
|
else if (database == null || database.Any() == false || string.IsNullOrEmpty(database.FirstOrDefault()))
|
||||||
database = GetDatabases().ToArray();
|
database = GetDatabases().ToArray();
|
||||||
if (database.Any() == false) return loc1;
|
if (database.Any() == false) return loc1;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<DelaySign>false</DelaySign>
|
<DelaySign>false</DelaySign>
|
||||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<Title>$(AssemblyName)</Title>
|
<Title>$(AssemblyName)</Title>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
<Version>3.5.213</Version>
|
<Version>3.5.215</Version>
|
||||||
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
<PackageReadmeFile>readme.md</PackageReadmeFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user