mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 增加 IFreeSql.GlobalFilter 全局过滤器;
- 移除 TableAttribute.SelectFilter 功能;
This commit is contained in:
@ -87,7 +87,7 @@ namespace FreeSql.Tests.MySqlConnector
|
||||
public virtual ICollection<Tag> Tags { get; set; }
|
||||
}
|
||||
|
||||
[Table(Name = "TestInfoT1", SelectFilter = " a.id > 0")]
|
||||
[Table(Name = "TestInfoT1")]
|
||||
class TestInfo
|
||||
{
|
||||
[Column(IsIdentity = true, IsPrimary = true)]
|
||||
|
@ -1003,7 +1003,7 @@ WHERE ROWNUM < 11";
|
||||
}
|
||||
|
||||
|
||||
[Table(Name = "TestInfoT1", SelectFilter = " a.id > 0")]
|
||||
[Table(Name = "TestInfoT1")]
|
||||
class TestInfo
|
||||
{
|
||||
[Column(IsIdentity = true, IsPrimary = true)]
|
||||
|
@ -68,21 +68,21 @@ namespace FreeSql.Tests.DataAnnotations
|
||||
{
|
||||
g.mysql.CodeFirst
|
||||
//.ConfigEntity<TestFluenttb1>(a => {
|
||||
// a.Name("xxdkdkdk1").SelectFilter("a.Id22 > 0");
|
||||
// a.Name("xxdkdkdk1");
|
||||
// a.Property(b => b.Id).Name("Id22").IsIdentity(true);
|
||||
// a.Property(b => b.name).DbType("varchar(100)").IsNullable(true);
|
||||
//})
|
||||
|
||||
.ConfigEntity(typeof(TestFluenttb1), a =>
|
||||
{
|
||||
a.Name("xxdkdkdk1222").SelectFilter("a.Id22dd > 1");
|
||||
a.Name("xxdkdkdk1222");
|
||||
a.Property("Id").Name("Id22dd").IsIdentity(true);
|
||||
a.Property("Name").DbType("varchar(101)").IsNullable(true);
|
||||
})
|
||||
|
||||
.ConfigEntity<TestFluenttb2>(a =>
|
||||
{
|
||||
a.Name("xxdkdkdk2").SelectFilter("a.Idx > 0");
|
||||
a.Name("xxdkdkdk2");
|
||||
a.Property(b => b.Id).Name("Id22").IsIdentity(true);
|
||||
a.Property(b => b.name).DbType("varchar(100)").IsNullable(true);
|
||||
})
|
||||
|
@ -41,21 +41,21 @@ namespace FreeSql.Tests.DataAnnotations
|
||||
{
|
||||
_sqlserverFixture.SqlServer.CodeFirst
|
||||
//.ConfigEntity<TestFluenttb1>(a => {
|
||||
// a.Name("xxdkdkdk1").SelectFilter("a.Id22 > 0");
|
||||
// a.Name("xxdkdkdk1");
|
||||
// a.Property(b => b.Id).Name("Id22").IsIdentity(true);
|
||||
// a.Property(b => b.name).DbType("varchar(100)").IsNullable(true);
|
||||
//})
|
||||
|
||||
.ConfigEntity(typeof(TestFluenttb1), a =>
|
||||
{
|
||||
a.Name("xxdkdkdk1222").SelectFilter("a.Id22dd > 1");
|
||||
a.Name("xxdkdkdk1222");
|
||||
a.Property("Id").Name("Id22dd").IsIdentity(true);
|
||||
a.Property("Name").DbType("varchar(101)").IsNullable(true);
|
||||
})
|
||||
|
||||
.ConfigEntity<TestFluenttb2>(a =>
|
||||
{
|
||||
a.Name("xxdkdkdk2").SelectFilter("a.Idx > 0");
|
||||
a.Name("xxdkdkdk2");
|
||||
a.Property(b => b.Id).Name("Id22").IsIdentity(true);
|
||||
a.Property(b => b.name).DbType("varchar(100)").IsNullable(true);
|
||||
})
|
||||
|
@ -1106,7 +1106,6 @@ namespace FreeSql.Tests.Sqlite
|
||||
[Fact]
|
||||
public void Include_ManyToMany()
|
||||
{
|
||||
|
||||
var tag1 = new Tag
|
||||
{
|
||||
Ddd = DateTime.Now.Second,
|
||||
|
@ -15,6 +15,7 @@ using Zeus;
|
||||
using Zeus.Domain.Enum;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
||||
namespace FreeSql.Tests
|
||||
{
|
||||
@ -415,10 +416,27 @@ namespace FreeSql.Tests
|
||||
}
|
||||
public enum TestAddEnumType { 中国人, 日本人 }
|
||||
|
||||
public static AsyncLocal<Guid> TenrantId { get; set; } = new AsyncLocal<Guid>();
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
//g.mysql.GlobalFilter
|
||||
// .Apply<TestAddEnum>("test1", a => a.Id == TenrantId.Value)
|
||||
// .Apply<AuthorTest>("test2", a => a.Id == 111)
|
||||
// .Apply<AuthorTest>("test3", a => a.Name == "11");
|
||||
|
||||
TenrantId.Value = Guid.NewGuid();
|
||||
g.mysql.Select<TestAddEnum>().ToList();
|
||||
g.mysql.Select<TestAddEnum>().DisableGlobalFilter("test1").ToList();
|
||||
g.mysql.Select<TestAddEnum>().DisableGlobalFilter().ToList();
|
||||
|
||||
g.mysql.Delete<TestAddEnum>().Where(a => a.Id == Guid.Empty).ExecuteAffrows();
|
||||
g.mysql.Delete<TestAddEnum>().DisableGlobalFilter("test1").Where(a => a.Id == Guid.Empty).ExecuteAffrows();
|
||||
g.mysql.Delete<TestAddEnum>().DisableGlobalFilter().Where(a => a.Id == Guid.Empty).ExecuteAffrows();
|
||||
|
||||
g.mysql.Update<TestAddEnum>().SetSource(new TestAddEnum { Id = Guid.Empty }).ExecuteAffrows();
|
||||
g.mysql.Update<TestAddEnum>().DisableGlobalFilter("test1").SetSource(new TestAddEnum { Id = Guid.Empty }).ExecuteAffrows();
|
||||
g.mysql.Update<TestAddEnum>().DisableGlobalFilter().SetSource(new TestAddEnum { Id = Guid.Empty }).ExecuteAffrows();
|
||||
|
||||
g.sqlite.Insert(new TestGuidId { xxx = "111" }).ExecuteAffrows();
|
||||
g.sqlite.Insert(new TestGuidId { xxx = "222" }).ExecuteAffrows();
|
||||
@ -1217,7 +1235,7 @@ namespace FreeSql.Tests
|
||||
}
|
||||
|
||||
|
||||
[Table(Name = "TestInfoT1", SelectFilter = " a.id > 0")]
|
||||
[Table(Name = "TestInfoT1")]
|
||||
class TestInfo
|
||||
{
|
||||
[Column(IsIdentity = true, IsPrimary = true)]
|
||||
|
Reference in New Issue
Block a user