mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
## v0.3.25
- 修复 全局过滤器一个赋值低级错误; - 增加 IFreeSql<TMark> 空接口,现实多个 IFreeSql 注入使用,使用泛型标识区分;
This commit is contained in:
parent
07d0de8093
commit
bf72bf423c
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using FreeSql;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace dbcontext_01.Controllers
|
namespace dbcontext_01.Controllers
|
||||||
@ -12,9 +13,12 @@ namespace dbcontext_01.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
IFreeSql _orm;
|
IFreeSql _orm;
|
||||||
public ValuesController(SongContext songContext, IFreeSql orm) {
|
public ValuesController(SongContext songContext,
|
||||||
|
IFreeSql orm1, IFreeSql orm2,
|
||||||
|
IFreeSql<long> orm3
|
||||||
|
) {
|
||||||
|
|
||||||
_orm = orm;
|
_orm = orm1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ namespace dbcontext_01
|
|||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
|
|
||||||
Fsql = new FreeSql.FreeSqlBuilder()
|
Fsql = new FreeSql.FreeSqlBuilder()
|
||||||
//.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document.db;Pooling=true;Max Pool Size=10")
|
.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document.db;Pooling=true;Max Pool Size=10")
|
||||||
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
|
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
|
||||||
.UseLogger(loggerFactory.CreateLogger<IFreeSql>())
|
.UseLogger(loggerFactory.CreateLogger<IFreeSql>())
|
||||||
.UseAutoSyncStructure(true)
|
.UseAutoSyncStructure(true)
|
||||||
.UseLazyLoading(true)
|
.UseLazyLoading(true)
|
||||||
@ -30,11 +30,27 @@ namespace dbcontext_01
|
|||||||
(cmd, log) => Trace.WriteLine(log)
|
(cmd, log) => Trace.WriteLine(log)
|
||||||
)
|
)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
Fsql2 = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document222.db;Pooling=true;Max Pool Size=10")
|
||||||
|
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
|
||||||
|
.UseLogger(loggerFactory.CreateLogger<IFreeSql>())
|
||||||
|
.UseAutoSyncStructure(true)
|
||||||
|
.UseLazyLoading(true)
|
||||||
|
|
||||||
|
.UseMonitorCommand(cmd => Trace.WriteLine(cmd.CommandText),
|
||||||
|
(cmd, log) => Trace.WriteLine(log)
|
||||||
|
)
|
||||||
|
.Build<long>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
enum MySql { }
|
||||||
|
enum PgSql { }
|
||||||
|
|
||||||
|
public IConfiguration Configuration { get; }
|
||||||
public static IFreeSql Fsql { get; private set; }
|
public static IFreeSql Fsql { get; private set; }
|
||||||
|
public static IFreeSql<long> Fsql2 { get; private set; }
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
@ -46,7 +62,10 @@ namespace dbcontext_01
|
|||||||
//options.IncludeXmlComments(xmlPath);
|
//options.IncludeXmlComments(xmlPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
services.AddSingleton<IFreeSql>(Fsql);
|
services.AddSingleton<IFreeSql>(Fsql);
|
||||||
|
services.AddSingleton<IFreeSql<long>>(Fsql2);
|
||||||
services.AddFreeDbContext<SongContext>(options => options.UseFreeSql(Fsql));
|
services.AddFreeDbContext<SongContext>(options => options.UseFreeSql(Fsql));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.3" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.3" />
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.0" />
|
||||||
<PackageReference Include="sqlSugarCore" Version="4.9.9.3" />
|
<PackageReference Include="sqlSugarCore" Version="4.9.9.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ namespace restful.Controllers {
|
|||||||
|
|
||||||
public class xxxx {
|
public class xxxx {
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public bool IsDeleted { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
|
using repository_01;
|
||||||
|
|
||||||
namespace restful.Entitys {
|
namespace restful.Entitys {
|
||||||
public class Song {
|
public class Song {
|
||||||
|
@ -19,15 +19,15 @@ namespace repository_01 {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户密码信息
|
/// 用户密码信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SysUserLogOn {
|
public class Sys1UserLogOn {
|
||||||
[Column(IsPrimary = true, Name = "Id")]
|
[Column(IsPrimary = true, Name = "Id")]
|
||||||
public Guid UserLogOnId { get; set; }
|
public Guid UserLogOnId { get; set; }
|
||||||
public virtual SysUser User { get; set; }
|
public virtual Sys1User User { get; set; }
|
||||||
}
|
}
|
||||||
public class SysUser {
|
public class Sys1User {
|
||||||
[Column(IsPrimary = true, Name = "Id")]
|
[Column(IsPrimary = true, Name = "Id")]
|
||||||
public Guid UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
public virtual SysUserLogOn UserLogOn { get; set; }
|
public virtual Sys1UserLogOn UserLogOn { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Startup {
|
public class Startup {
|
||||||
@ -43,11 +43,11 @@ namespace repository_01 {
|
|||||||
.UseMonitorCommand(cmd => Trace.WriteLine(cmd.CommandText))
|
.UseMonitorCommand(cmd => Trace.WriteLine(cmd.CommandText))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var sysu = new SysUser { };
|
var sysu = new Sys1User { };
|
||||||
Fsql.Insert<SysUser>().AppendData(sysu).ExecuteAffrows();
|
Fsql.Insert<Sys1User>().AppendData(sysu).ExecuteAffrows();
|
||||||
Fsql.Insert<SysUserLogOn>().AppendData(new SysUserLogOn { UserLogOnId = sysu.UserId }).ExecuteAffrows();
|
Fsql.Insert<Sys1UserLogOn>().AppendData(new Sys1UserLogOn { UserLogOnId = sysu.UserId }).ExecuteAffrows();
|
||||||
var a = Fsql.Select<SysUserLogOn>().ToList();
|
var a = Fsql.Select<Sys1UserLogOn>().ToList();
|
||||||
var b = Fsql.Select<SysUserLogOn>().Any();
|
var b = Fsql.Select<Sys1UserLogOn>().Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
@ -92,8 +92,10 @@ namespace repository_01 {
|
|||||||
|
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
|
|
||||||
builder.RegisterFreeRepository(
|
builder.RegisterFreeRepository(filter => filter
|
||||||
filter => filter.Apply<Song>("test", a => a.Title == DateTime.Now.ToString() + System.Threading.Thread.CurrentThread.ManagedThreadId),
|
.Apply<Song>("test", a => a.Title == DateTime.Now.ToString() + System.Threading.Thread.CurrentThread.ManagedThreadId)
|
||||||
|
.Apply<ISoftDelete>("softdelete", a => a.IsDeleted == false)
|
||||||
|
,
|
||||||
this.GetType().Assembly
|
this.GetType().Assembly
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -121,4 +123,8 @@ namespace repository_01 {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface ISoftDelete {
|
||||||
|
bool IsDeleted { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>0.3.24</Version>
|
<Version>0.3.25</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>0.3.24</Version>
|
<Version>0.3.25</Version>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite, and read/write separation、and split table.</Description>
|
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite, and read/write separation、and split table.</Description>
|
||||||
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>
|
||||||
|
@ -46,7 +46,7 @@ namespace FreeSql {
|
|||||||
notExists.TryAdd(gf.name, true); //防止第二次错误
|
notExists.TryAdd(gf.name, true); //防止第二次错误
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
newFilter.Add(gf.name, gf.exp);
|
newFilter.Add(gf.name, newExp);
|
||||||
}
|
}
|
||||||
if (newFilter.Any() == false) return;
|
if (newFilter.Any() == false) return;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>0.3.24</Version>
|
<Version>0.3.25</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
||||||
|
@ -124,14 +124,15 @@ namespace FreeSql {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFreeSql Build() {
|
public IFreeSql Build() => Build<IFreeSql>();
|
||||||
IFreeSql ret = null;
|
public IFreeSql<TMark> Build<TMark>() {
|
||||||
|
IFreeSql<TMark> ret = null;
|
||||||
switch(_dataType) {
|
switch(_dataType) {
|
||||||
case DataType.MySql: ret = new MySql.MySqlProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
case DataType.MySql: ret = new MySql.MySqlProvider<TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
||||||
case DataType.SqlServer: ret = new SqlServer.SqlServerProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
case DataType.SqlServer: ret = new SqlServer.SqlServerProvider<TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
||||||
case DataType.PostgreSQL: ret = new PostgreSQL.PostgreSQLProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
case DataType.PostgreSQL: ret = new PostgreSQL.PostgreSQLProvider<TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
||||||
case DataType.Oracle: ret = new Oracle.OracleProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
case DataType.Oracle: ret = new Oracle.OracleProvider<TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
||||||
case DataType.Sqlite: ret = new Sqlite.SqliteProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
case DataType.Sqlite: ret = new Sqlite.SqliteProvider<TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
|
||||||
}
|
}
|
||||||
if (ret != null) {
|
if (ret != null) {
|
||||||
ret.CodeFirst.IsAutoSyncStructure = _isAutoSyncStructure;
|
ret.CodeFirst.IsAutoSyncStructure = _isAutoSyncStructure;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using FreeSql;
|
using FreeSql;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
|
||||||
using System.Text;
|
public interface IFreeSql<TMark> : IFreeSql { }
|
||||||
|
|
||||||
public interface IFreeSql {
|
public interface IFreeSql {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -10,7 +10,7 @@ using System.Data.Common;
|
|||||||
|
|
||||||
namespace FreeSql.MySql {
|
namespace FreeSql.MySql {
|
||||||
|
|
||||||
class MySqlProvider : IFreeSql {
|
class MySqlProvider<TMark> : IFreeSql<TMark> {
|
||||||
|
|
||||||
static MySqlProvider() {
|
static MySqlProvider() {
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple.Add(typeof(MygisPoint), true);
|
Utils.dicExecuteArrayRowReadClassOrTuple.Add(typeof(MygisPoint), true);
|
||||||
|
@ -10,7 +10,7 @@ using System.Data.Common;
|
|||||||
|
|
||||||
namespace FreeSql.Oracle {
|
namespace FreeSql.Oracle {
|
||||||
|
|
||||||
class OracleProvider : IFreeSql {
|
class OracleProvider<TMark> : IFreeSql<TMark> {
|
||||||
|
|
||||||
public ISelect<T1> Select<T1>() where T1 : class => new OracleSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, null);
|
public ISelect<T1> Select<T1>() where T1 : class => new OracleSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, null);
|
||||||
public ISelect<T1> Select<T1>(object dywhere) where T1 : class => new OracleSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public ISelect<T1> Select<T1>(object dywhere) where T1 : class => new OracleSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
|
@ -16,7 +16,7 @@ using System.Net.NetworkInformation;
|
|||||||
|
|
||||||
namespace FreeSql.PostgreSQL {
|
namespace FreeSql.PostgreSQL {
|
||||||
|
|
||||||
class PostgreSQLProvider : IFreeSql {
|
class PostgreSQLProvider<TMark> : IFreeSql<TMark> {
|
||||||
|
|
||||||
static PostgreSQLProvider() {
|
static PostgreSQLProvider() {
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple.Add(typeof(BitArray), true);
|
Utils.dicExecuteArrayRowReadClassOrTuple.Add(typeof(BitArray), true);
|
||||||
|
@ -9,7 +9,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace FreeSql.SqlServer {
|
namespace FreeSql.SqlServer {
|
||||||
|
|
||||||
class SqlServerProvider : IFreeSql {
|
class SqlServerProvider<TMark> : IFreeSql<TMark> {
|
||||||
|
|
||||||
public ISelect<T1> Select<T1>() where T1 : class => new SqlServerSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, null);
|
public ISelect<T1> Select<T1>() where T1 : class => new SqlServerSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, null);
|
||||||
public ISelect<T1> Select<T1>(object dywhere) where T1 : class => new SqlServerSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public ISelect<T1> Select<T1>(object dywhere) where T1 : class => new SqlServerSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
|
@ -10,7 +10,7 @@ using System.Data.Common;
|
|||||||
|
|
||||||
namespace FreeSql.Sqlite {
|
namespace FreeSql.Sqlite {
|
||||||
|
|
||||||
class SqliteProvider : IFreeSql {
|
class SqliteProvider<TMark> : IFreeSql<TMark> {
|
||||||
|
|
||||||
public ISelect<T1> Select<T1>() where T1 : class => new SqliteSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, null);
|
public ISelect<T1> Select<T1>() where T1 : class => new SqliteSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, null);
|
||||||
public ISelect<T1> Select<T1>(object dywhere) where T1 : class => new SqliteSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public ISelect<T1> Select<T1>(object dywhere) where T1 : class => new SqliteSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user