mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
Optimize single table read performance
This commit is contained in:
parent
7290109734
commit
105947c2ed
@ -1,4 +1,6 @@
|
|||||||
using FreeSql.Internal;
|
using Dapper;
|
||||||
|
using FreeSql.Internal;
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
@ -12,14 +14,15 @@ using System.Linq.Expressions;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql;
|
||||||
|
|
||||||
namespace orm_vs
|
namespace orm_vs
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=20")
|
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=tedb;Pooling=true;Max Pool Size=20")
|
||||||
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=20")
|
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=20")
|
||||||
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=20")
|
//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=20")
|
||||||
.UseAutoSyncStructure(false)
|
.UseAutoSyncStructure(false)
|
||||||
.UseNoneCommandParameter(true)
|
.UseNoneCommandParameter(true)
|
||||||
@ -32,19 +35,19 @@ namespace orm_vs
|
|||||||
{
|
{
|
||||||
var db = new SqlSugarClient(new ConnectionConfig()
|
var db = new SqlSugarClient(new ConnectionConfig()
|
||||||
{
|
{
|
||||||
//ConnectionString = "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Min Pool Size=20;Max Pool Size=20",
|
ConnectionString = "Data Source=.;Integrated Security=True;Initial Catalog=tedb;Pooling=true;Min Pool Size=20;Max Pool Size=20",
|
||||||
//DbType = DbType.SqlServer,
|
DbType = DbType.SqlServer,
|
||||||
ConnectionString = "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Min Pool Size=20;Max Pool Size=20",
|
//ConnectionString = "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Min Pool Size=20;Max Pool Size=20",
|
||||||
DbType = DbType.MySql,
|
//DbType = DbType.MySql,
|
||||||
//ConnectionString = "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=21",
|
//ConnectionString = "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=21",
|
||||||
//DbType = DbType.PostgreSQL,
|
//DbType = DbType.PostgreSQL,
|
||||||
IsAutoCloseConnection = true,
|
IsAutoCloseConnection = true,
|
||||||
InitKeyType = InitKeyType.Attribute
|
InitKeyType = InitKeyType.Attribute
|
||||||
});
|
});
|
||||||
db.Aop.OnLogExecuting = (sql, pars) =>
|
//db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
{
|
//{
|
||||||
Console.WriteLine(sql);//输出sql,查看执行sql
|
// Console.WriteLine(sql);//输出sql,查看执行sql
|
||||||
};
|
//};
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,10 +55,11 @@ namespace orm_vs
|
|||||||
class SongContext : DbContext
|
class SongContext : DbContext
|
||||||
{
|
{
|
||||||
public DbSet<Song> Songs { get; set; }
|
public DbSet<Song> Songs { get; set; }
|
||||||
|
public DbSet<PatientExamination_2022> PatientExamination_2022s { get; set; }
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
//optionsBuilder.UseSqlServer(@"Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Min Pool Size=21;Max Pool Size=21");
|
optionsBuilder.UseSqlServer(@"Data Source=.;Integrated Security=True;Initial Catalog=tedb;Pooling=true;Min Pool Size=21;Max Pool Size=21");
|
||||||
optionsBuilder.UseMySql("Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Min Pool Size=21;Max Pool Size=21");
|
//optionsBuilder.UseMySql("Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Min Pool Size=21;Max Pool Size=21");
|
||||||
//optionsBuilder.UseNpgsql("Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=21");
|
//optionsBuilder.UseNpgsql("Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=21");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,8 +73,101 @@ namespace orm_vs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CREATE TABLE [dbo].[PatientExamination_2022] (
|
||||||
|
// [Id] uniqueidentifier NOT NULL,
|
||||||
|
// [CreateTime] datetime NOT NULL,
|
||||||
|
// [ExamKindId] uniqueidentifier NOT NULL,
|
||||||
|
// [ExamKindName] nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
// [PatientGuid] uniqueidentifier NOT NULL,
|
||||||
|
// [PatientName] nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
// [AnesthesiaType] int NOT NULL,
|
||||||
|
// [DiaRoomId] uniqueidentifier NULL,
|
||||||
|
// [DiaRoomName] nvarchar(255) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
// [QueueIndex] int NOT NULL,
|
||||||
|
// [QueueNum] int NOT NULL,
|
||||||
|
// [OrderDateTime] datetime NOT NULL,
|
||||||
|
// [TimeType] int NOT NULL,
|
||||||
|
// [SignInTime] datetime NULL,
|
||||||
|
// [StartCheckTime] datetime NULL,
|
||||||
|
// [EndCheckTime] datetime NULL,
|
||||||
|
// [VerifyTime] datetime NULL,
|
||||||
|
// [ReportTime] datetime NULL,
|
||||||
|
// [ExaminationState] int NOT NULL
|
||||||
|
//)
|
||||||
|
[Table("PatientExamination_2022")]
|
||||||
|
class PatientExamination_2022
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
public Guid ExamKindId { get; set; }
|
||||||
|
public string ExamKindName { get; set; }
|
||||||
|
public Guid PatientGuid { get; set; }
|
||||||
|
public string PatientName { get; set; }
|
||||||
|
public int AnesthesiaType { get; set; }
|
||||||
|
public Guid? DiaRoomId { get; set; }
|
||||||
|
public string DiaRoomName { get; set; }
|
||||||
|
public int QueueIndex { get; set; }
|
||||||
|
public int QueueNum { get; set; }
|
||||||
|
public DateTime OrderDateTime { get; set; }
|
||||||
|
public int TimeType { get; set; }
|
||||||
|
public DateTime? SignInTime { get; set; }
|
||||||
|
public DateTime? StartCheckTime { get; set; }
|
||||||
|
public DateTime? EndCheckTime { get; set; }
|
||||||
|
public DateTime? VerifyTime { get; set; }
|
||||||
|
public DateTime? ReportTime { get; set; }
|
||||||
|
public int ExaminationState { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TestFreeSqlSelectPatientExamination_2022()
|
||||||
|
{
|
||||||
|
var list = fsql.Select<PatientExamination_2022>().Limit(40000).ToList();
|
||||||
|
//var list = fsql.Ado.Query<PatientExamination_2022>("select top 40000 * from PatientExamination_2022");
|
||||||
|
}
|
||||||
|
static void TestEfSelectPatientExamination_2022()
|
||||||
|
{
|
||||||
|
using (var ctx = new SongContext())
|
||||||
|
{
|
||||||
|
var list = ctx.PatientExamination_2022s.Take(40000).AsNoTracking().ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void TestSqlSugarSelectPatientExamination_2022()
|
||||||
|
{
|
||||||
|
var list = sugar.Queryable<PatientExamination_2022>().Take(40000).ToList();
|
||||||
|
}
|
||||||
|
static void TestDapperSelectPatientExamination_2022()
|
||||||
|
{
|
||||||
|
using (var conn = new SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=tedb;Pooling=true;Min Pool Size=21;Max Pool Size=22"))
|
||||||
|
{
|
||||||
|
var list = conn.Query<PatientExamination_2022>("select top 40000 * from PatientExamination_2022");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static DbConnection fsqlConn = null;
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
var count = 0;
|
||||||
|
var sws = new List<long>();
|
||||||
|
Console.WriteLine("观察查询4万条记录内存,按 Enter 进入下一次,按任易键即出程序。。。");
|
||||||
|
//while(Console.ReadKey().Key == ConsoleKey.Enter)
|
||||||
|
//using (var fcon = fsql.Ado.MasterPool.Get())
|
||||||
|
//{
|
||||||
|
//fsqlConn = fcon.Value;
|
||||||
|
for (var a = 0; a < 80; a++)
|
||||||
|
{
|
||||||
|
Stopwatch sw = Stopwatch.StartNew();
|
||||||
|
TestFreeSqlSelectPatientExamination_2022();
|
||||||
|
//TestEfSelectPatientExamination_2022();
|
||||||
|
//TestSqlSugarSelectPatientExamination_2022();
|
||||||
|
//TestDapperSelectPatientExamination_2022();
|
||||||
|
sw.Stop();
|
||||||
|
sws.Add(sw.ElapsedMilliseconds);
|
||||||
|
Console.WriteLine($"第 {++count} 次,查询4万条记录, {sw.ElapsedMilliseconds}ms,平均 {(long)sws.Average()}ms");
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
Console.ReadKey();
|
||||||
|
fsql.Dispose();
|
||||||
|
return;
|
||||||
|
|
||||||
//fsql.CodeFirst.SyncStructure(typeof(Song), typeof(Song_tag), typeof(Tag));
|
//fsql.CodeFirst.SyncStructure(typeof(Song), typeof(Song_tag), typeof(Tag));
|
||||||
//sugar.CodeFirst.InitTables(typeof(Song), typeof(Song_tag), typeof(Tag));
|
//sugar.CodeFirst.InitTables(typeof(Song), typeof(Song_tag), typeof(Tag));
|
||||||
//sugar创建表失败:SqlSugar.SqlSugarException: Sequence contains no elements
|
//sugar创建表失败:SqlSugar.SqlSugarException: Sequence contains no elements
|
||||||
|
@ -795,14 +795,5 @@
|
|||||||
<param name="that"></param>
|
<param name="that"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
|
||||||
<summary>
|
|
||||||
批量注入 Repository,可以参考代码自行调整
|
|
||||||
</summary>
|
|
||||||
<param name="services"></param>
|
|
||||||
<param name="globalDataFilter"></param>
|
|
||||||
<param name="assemblies"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
@ -3303,177 +3303,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>
|
||||||
可自定义解析表达式
|
可自定义解析表达式
|
||||||
@ -4480,12 +4309,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>
|
||||||
使用完毕后,归还资源
|
使用完毕后,归还资源
|
||||||
@ -4561,12 +4384,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>
|
||||||
归还对象给对象池的时候触发
|
归还对象给对象池的时候触发
|
||||||
|
@ -174,6 +174,20 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MethodInfo _MethodDataReaderIsDBNull = typeof(DbDataReader).GetMethod("IsDBNull", new Type[] { typeof(int) });
|
||||||
|
public static Dictionary<Type, MethodInfo> _dicMethodDataReaderGetValue = new Dictionary<Type, MethodInfo>
|
||||||
|
{
|
||||||
|
[typeof(bool)] = typeof(DbDataReader).GetMethod("GetBoolean", new Type[] { typeof(int) }),
|
||||||
|
[typeof(int)] = typeof(DbDataReader).GetMethod("GetInt32", new Type[] { typeof(int) }),
|
||||||
|
[typeof(long)] = typeof(DbDataReader).GetMethod("GetInt64", new Type[] { typeof(int) }),
|
||||||
|
[typeof(double)] = typeof(DbDataReader).GetMethod("GetDouble", new Type[] { typeof(int) }),
|
||||||
|
[typeof(float)] = typeof(DbDataReader).GetMethod("GetFloat", new Type[] { typeof(int) }),
|
||||||
|
[typeof(decimal)] = typeof(DbDataReader).GetMethod("GetDecimal", new Type[] { typeof(int) }),
|
||||||
|
[typeof(DateTime)] = typeof(DbDataReader).GetMethod("GetDateTime", new Type[] { typeof(int) }),
|
||||||
|
[typeof(string)] = typeof(DbDataReader).GetMethod("GetString", new Type[] { typeof(int) }),
|
||||||
|
//[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) }) 有些驱动不兼容
|
||||||
|
};
|
||||||
|
|
||||||
public static MethodInfo MethodStringContains = typeof(string).GetMethod("Contains", new[] { typeof(string) });
|
public static MethodInfo MethodStringContains = typeof(string).GetMethod("Contains", new[] { typeof(string) });
|
||||||
public static MethodInfo MethodStringStartsWith = typeof(string).GetMethod("StartsWith", new[] { typeof(string) });
|
public static MethodInfo MethodStringStartsWith = typeof(string).GetMethod("StartsWith", new[] { typeof(string) });
|
||||||
public static MethodInfo MethodStringEndsWith = typeof(string).GetMethod("EndsWith", new[] { typeof(string) });
|
public static MethodInfo MethodStringEndsWith = typeof(string).GetMethod("EndsWith", new[] { typeof(string) });
|
||||||
|
@ -748,18 +748,6 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static MethodInfo _MethodDataReaderIsDBNull = typeof(DbDataReader).GetMethod("IsDBNull", new Type[] { typeof(int) });
|
|
||||||
static Dictionary<Type, MethodInfo> _dicMethodDataReaderGetValue = new Dictionary<Type, MethodInfo>
|
|
||||||
{
|
|
||||||
[typeof(bool)] = typeof(DbDataReader).GetMethod("GetBoolean", new Type[] { typeof(int) }),
|
|
||||||
[typeof(int)] = typeof(DbDataReader).GetMethod("GetInt32", new Type[] { typeof(int) }),
|
|
||||||
[typeof(long)] = typeof(DbDataReader).GetMethod("GetInt64", new Type[] { typeof(int) }),
|
|
||||||
[typeof(double)] = typeof(DbDataReader).GetMethod("GetDouble", new Type[] { typeof(int) }),
|
|
||||||
[typeof(float)] = typeof(DbDataReader).GetMethod("GetFloat", new Type[] { typeof(int) }),
|
|
||||||
[typeof(decimal)] = typeof(DbDataReader).GetMethod("GetDecimal", new Type[] { typeof(int) }),
|
|
||||||
[typeof(DateTime)] = typeof(DbDataReader).GetMethod("GetDateTime", new Type[] { typeof(int) }),
|
|
||||||
[typeof(string)] = typeof(DbDataReader).GetMethod("GetString", new Type[] { typeof(int) }),
|
|
||||||
};
|
|
||||||
|
|
||||||
protected double InternalAvg(Expression exp)
|
protected double InternalAvg(Expression exp)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,8 @@ namespace FreeSql.MySql
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new MySqlSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new MySqlSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
|
@ -21,7 +21,6 @@ namespace FreeSql.PostgreSQL
|
|||||||
|
|
||||||
public class PostgreSQLProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class PostgreSQLProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
|
|
||||||
static PostgreSQLProvider()
|
static PostgreSQLProvider()
|
||||||
{
|
{
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
||||||
@ -104,7 +103,9 @@ namespace FreeSql.PostgreSQL
|
|||||||
Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJsonConvertDeserializeObject, Expression.Convert(valueExp, typeof(string)), Expression.Constant(type, typeof(Type))), type)),
|
Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJsonConvertDeserializeObject, Expression.Convert(valueExp, typeof(string)), Expression.Constant(type, typeof(Type))), type)),
|
||||||
Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJsonConvertDeserializeObject, Expression.Convert(Expression.Call(MethodToString, valueExp), typeof(string)), Expression.Constant(type, typeof(Type))), type)));
|
Expression.Return(returnTarget, Expression.TypeAs(Expression.Call(MethodJsonConvertDeserializeObject, Expression.Convert(Expression.Call(MethodToString, valueExp), typeof(string)), Expression.Constant(type, typeof(Type))), type)));
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new PostgreSQLSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new PostgreSQLSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
|
@ -9,6 +9,11 @@ namespace FreeSql.SqlServer
|
|||||||
|
|
||||||
public class SqlServerProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class SqlServerProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
|
static SqlServerProvider()
|
||||||
|
{
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new SqlServerSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new SqlServerSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
public override IInsert<T1> CreateInsertProvider<T1>() => new SqlServerInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
public override IInsert<T1> CreateInsertProvider<T1>() => new SqlServerInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
public override IUpdate<T1> CreateUpdateProvider<T1>(object dywhere) => new SqlServerUpdate<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override IUpdate<T1> CreateUpdateProvider<T1>(object dywhere) => new SqlServerUpdate<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
|
@ -9,6 +9,11 @@ namespace FreeSql.Sqlite
|
|||||||
|
|
||||||
public class SqliteProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class SqliteProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
|
static SqliteProvider()
|
||||||
|
{
|
||||||
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new SqliteSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new SqliteSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
public override IInsert<T1> CreateInsertProvider<T1>() => new SqliteInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
public override IInsert<T1> CreateInsertProvider<T1>() => new SqliteInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
public override IUpdate<T1> CreateUpdateProvider<T1>(object dywhere) => new SqliteUpdate<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override IUpdate<T1> CreateUpdateProvider<T1>(object dywhere) => new SqliteUpdate<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user