mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 20:38:16 +08:00
- 移除 Repository.DataFilter 功能通知;#1208
This commit is contained in:
@ -614,7 +614,7 @@ namespace FreeSql.Tests
|
||||
{
|
||||
g.sqlite.Insert(new AddUpdateInfo()).ExecuteAffrows();
|
||||
|
||||
var repos = g.sqlite.GetGuidRepository<object>();
|
||||
var repos = g.sqlite.GetRepository<object, Guid>();
|
||||
repos.AsType(typeof(AddUpdateInfo));
|
||||
|
||||
var item = new AddUpdateInfo();
|
||||
@ -627,7 +627,6 @@ namespace FreeSql.Tests
|
||||
var item2 = repos.Find(item.Id) as AddUpdateInfo;
|
||||
Assert.Equal(item.Clicks, item2.Clicks);
|
||||
|
||||
repos.DataFilter.Apply("xxx", a => (a as AddUpdateInfo).Clicks == 2);
|
||||
Assert.Null(repos.Find(item.Id));
|
||||
}
|
||||
|
||||
|
@ -65,23 +65,23 @@ WHERE (exists(SELECT 1
|
||||
limit 0,1))
|
||||
ORDER BY a.""Id"" DESC", sql);
|
||||
|
||||
using (userRepository.DataFilter.Disable("TenantQuery"))
|
||||
{
|
||||
sql = userRepository.Select
|
||||
.Where(i => i.DoorDevices.AsSelect().Any(x => x.Id == deviceId))
|
||||
.OrderByDescending(true, a => a.Id)
|
||||
.ToSql();
|
||||
Assert.Equal(@"SELECT a.""Id"", a.""TenantId""
|
||||
FROM ""issues1208_User"" a
|
||||
WHERE (exists(SELECT 1
|
||||
FROM ""issues1208_DoorDeviceUser"" Mx_Mi
|
||||
WHERE (Mx_Mi.""UserId"" = a.""Id"") AND (exists(SELECT 1
|
||||
FROM ""issues1208_DoorDevice"" x
|
||||
WHERE (x.""Id"" = 100) AND (x.""Id"" = Mx_Mi.""DoorDeviceId"")
|
||||
limit 0,1))
|
||||
limit 0,1))
|
||||
ORDER BY a.""Id"" DESC", sql);
|
||||
}
|
||||
// using (userRepository.DataFilter.Disable("TenantQuery"))
|
||||
// {
|
||||
// sql = userRepository.Select
|
||||
// .Where(i => i.DoorDevices.AsSelect().Any(x => x.Id == deviceId))
|
||||
// .OrderByDescending(true, a => a.Id)
|
||||
// .ToSql();
|
||||
// Assert.Equal(@"SELECT a.""Id"", a.""TenantId""
|
||||
//FROM ""issues1208_User"" a
|
||||
//WHERE (exists(SELECT 1
|
||||
// FROM ""issues1208_DoorDeviceUser"" Mx_Mi
|
||||
// WHERE (Mx_Mi.""UserId"" = a.""Id"") AND (exists(SELECT 1
|
||||
// FROM ""issues1208_DoorDevice"" x
|
||||
// WHERE (x.""Id"" = 100) AND (x.""Id"" = Mx_Mi.""DoorDeviceId"")
|
||||
// limit 0,1))
|
||||
// limit 0,1))
|
||||
//ORDER BY a.""Id"" DESC", sql);
|
||||
// }
|
||||
|
||||
sql = userRepository.Select
|
||||
.Where(i => i.DoorDevices.Any(x => x.Id == deviceId))
|
||||
@ -113,23 +113,23 @@ WHERE (exists(SELECT 1
|
||||
limit 0,1))
|
||||
ORDER BY a.""Id"" DESC", sql);
|
||||
|
||||
using (userRepository.DataFilter.Disable("TenantQuery"))
|
||||
{
|
||||
sql = userRepository.Select
|
||||
.Where(i => i.DoorDevices.Any(x => x.Id == deviceId))
|
||||
.OrderByDescending(true, a => a.Id)
|
||||
.ToSql();
|
||||
Assert.Equal(@"SELECT a.""Id"", a.""TenantId""
|
||||
FROM ""issues1208_User"" a
|
||||
WHERE (exists(SELECT 1
|
||||
FROM ""issues1208_DoorDevice"" x
|
||||
WHERE (exists(SELECT 1
|
||||
FROM ""issues1208_DoorDeviceUser"" Mx_Ma
|
||||
WHERE (Mx_Ma.""DoorDeviceId"" = x.""Id"") AND (Mx_Ma.""UserId"" = a.""Id"")
|
||||
limit 0,1)) AND (x.""Id"" = 100)
|
||||
limit 0,1))
|
||||
ORDER BY a.""Id"" DESC", sql);
|
||||
}
|
||||
// using (userRepository.DataFilter.Disable("TenantQuery"))
|
||||
// {
|
||||
// sql = userRepository.Select
|
||||
// .Where(i => i.DoorDevices.Any(x => x.Id == deviceId))
|
||||
// .OrderByDescending(true, a => a.Id)
|
||||
// .ToSql();
|
||||
// Assert.Equal(@"SELECT a.""Id"", a.""TenantId""
|
||||
//FROM ""issues1208_User"" a
|
||||
//WHERE (exists(SELECT 1
|
||||
// FROM ""issues1208_DoorDevice"" x
|
||||
// WHERE (exists(SELECT 1
|
||||
// FROM ""issues1208_DoorDeviceUser"" Mx_Ma
|
||||
// WHERE (Mx_Ma.""DoorDeviceId"" = x.""Id"") AND (Mx_Ma.""UserId"" = a.""Id"")
|
||||
// limit 0,1)) AND (x.""Id"" = 100)
|
||||
// limit 0,1))
|
||||
//ORDER BY a.""Id"" DESC", sql);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,23 +231,23 @@ WHERE (exists(SELECT 1
|
||||
limit 0,1)) AND (a.""SoftDeleted"" = 0)
|
||||
ORDER BY a.""Id"" DESC", sql);
|
||||
|
||||
using (userRepository.DataFilter.Disable("TenantQuery"))
|
||||
{
|
||||
sql = userRepository.Select
|
||||
.Where(i => i.DoorDevices.AsSelect().Any(x => x.Id == deviceId))
|
||||
.OrderByDescending(true, a => a.Id)
|
||||
.ToSql();
|
||||
Assert.Equal(@"SELECT a.""Id"", a.""TenantId"", a.""SoftDeleted""
|
||||
FROM ""issues1208_User02"" a
|
||||
WHERE (exists(SELECT 1
|
||||
FROM ""issues1208_DoorDeviceUser02"" Mx_Mi
|
||||
WHERE (Mx_Mi.""UserId"" = a.""Id"") AND (exists(SELECT 1
|
||||
FROM ""issues1208_DoorDevice02"" x
|
||||
WHERE (x.""Id"" = 100) AND (x.""Id"" = Mx_Mi.""DoorDeviceId"") AND (x.""SoftDeleted"" = 0)
|
||||
limit 0,1)) AND (Mx_Mi.""SoftDeleted"" = 0)
|
||||
limit 0,1)) AND (a.""SoftDeleted"" = 0)
|
||||
ORDER BY a.""Id"" DESC", sql);
|
||||
}
|
||||
// using (userRepository.DataFilter.Disable("TenantQuery"))
|
||||
// {
|
||||
// sql = userRepository.Select
|
||||
// .Where(i => i.DoorDevices.AsSelect().Any(x => x.Id == deviceId))
|
||||
// .OrderByDescending(true, a => a.Id)
|
||||
// .ToSql();
|
||||
// Assert.Equal(@"SELECT a.""Id"", a.""TenantId"", a.""SoftDeleted""
|
||||
//FROM ""issues1208_User02"" a
|
||||
//WHERE (exists(SELECT 1
|
||||
// FROM ""issues1208_DoorDeviceUser02"" Mx_Mi
|
||||
// WHERE (Mx_Mi.""UserId"" = a.""Id"") AND (exists(SELECT 1
|
||||
// FROM ""issues1208_DoorDevice02"" x
|
||||
// WHERE (x.""Id"" = 100) AND (x.""Id"" = Mx_Mi.""DoorDeviceId"") AND (x.""SoftDeleted"" = 0)
|
||||
// limit 0,1)) AND (Mx_Mi.""SoftDeleted"" = 0)
|
||||
// limit 0,1)) AND (a.""SoftDeleted"" = 0)
|
||||
//ORDER BY a.""Id"" DESC", sql);
|
||||
// }
|
||||
|
||||
sql = userRepository.Select
|
||||
.Where(i => i.DoorDevices.Any(x => x.Id == deviceId))
|
||||
@ -279,23 +279,23 @@ WHERE (exists(SELECT 1
|
||||
limit 0,1)) AND (a.""SoftDeleted"" = 0)
|
||||
ORDER BY a.""Id"" DESC", sql);
|
||||
|
||||
using (userRepository.DataFilter.Disable("TenantQuery"))
|
||||
{
|
||||
sql = userRepository.Select
|
||||
.Where(i => i.DoorDevices.Any(x => x.Id == deviceId))
|
||||
.OrderByDescending(true, a => a.Id)
|
||||
.ToSql();
|
||||
Assert.Equal(@"SELECT a.""Id"", a.""TenantId"", a.""SoftDeleted""
|
||||
FROM ""issues1208_User02"" a
|
||||
WHERE (exists(SELECT 1
|
||||
FROM ""issues1208_DoorDevice02"" x
|
||||
WHERE (exists(SELECT 1
|
||||
FROM ""issues1208_DoorDeviceUser02"" Mx_Ma
|
||||
WHERE (Mx_Ma.""DoorDeviceId"" = x.""Id"") AND (Mx_Ma.""UserId"" = a.""Id"") AND (Mx_Ma.""SoftDeleted"" = 0)
|
||||
limit 0,1)) AND (x.""Id"" = 100) AND (x.""SoftDeleted"" = 0)
|
||||
limit 0,1)) AND (a.""SoftDeleted"" = 0)
|
||||
ORDER BY a.""Id"" DESC", sql);
|
||||
}
|
||||
// using (userRepository.DataFilter.Disable("TenantQuery"))
|
||||
// {
|
||||
// sql = userRepository.Select
|
||||
// .Where(i => i.DoorDevices.Any(x => x.Id == deviceId))
|
||||
// .OrderByDescending(true, a => a.Id)
|
||||
// .ToSql();
|
||||
// Assert.Equal(@"SELECT a.""Id"", a.""TenantId"", a.""SoftDeleted""
|
||||
//FROM ""issues1208_User02"" a
|
||||
//WHERE (exists(SELECT 1
|
||||
// FROM ""issues1208_DoorDevice02"" x
|
||||
// WHERE (exists(SELECT 1
|
||||
// FROM ""issues1208_DoorDeviceUser02"" Mx_Ma
|
||||
// WHERE (Mx_Ma.""DoorDeviceId"" = x.""Id"") AND (Mx_Ma.""UserId"" = a.""Id"") AND (Mx_Ma.""SoftDeleted"" = 0)
|
||||
// limit 0,1)) AND (x.""Id"" = 100) AND (x.""SoftDeleted"" = 0)
|
||||
// limit 0,1)) AND (a.""SoftDeleted"" = 0)
|
||||
//ORDER BY a.""Id"" DESC", sql);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,16 +382,6 @@ namespace FreeSql.Tests
|
||||
var gft2 = g.mysql.Select<gf_t2>().Where(a => a.id == Guid.NewGuid()).ToList();
|
||||
var gft3 = g.mysql.Select<gf_t3>().Where(a => a.id == Guid.NewGuid()).ToList();
|
||||
|
||||
var repo1 = g.mysql.GetRepository<gf_t1, Guid>();
|
||||
using (repo1.DataFilter.Disable("gft1", "gft2", "gft3"))
|
||||
repo1.Get(Guid.NewGuid());
|
||||
var repo2 = g.mysql.GetRepository<gf_t2, Guid>();
|
||||
using (repo2.DataFilter.Disable("gft1", "gft2", "gft3"))
|
||||
repo2.Get(Guid.NewGuid());
|
||||
var repo3 = g.mysql.GetRepository<gf_t3, Guid>();
|
||||
using (repo3.DataFilter.Disable("gft1", "gft2", "gft3"))
|
||||
repo3.Get(Guid.NewGuid());
|
||||
|
||||
g.sqlserver.Delete<TBatInst>().Where("1=1").ExecuteAffrows();
|
||||
g.mysql.Delete<TBatInst>().Where("1=1").ExecuteAffrows();
|
||||
g.pgsql.Delete<TBatInst>().Where("1=1").ExecuteAffrows();
|
||||
|
Reference in New Issue
Block a user