diff --git a/Examples/repository_01/Controllers/SongController.cs b/Examples/repository_01/Controllers/SongController.cs index a6bb50de..bb7869e0 100644 --- a/Examples/repository_01/Controllers/SongController.cs +++ b/Examples/repository_01/Controllers/SongController.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; namespace restful.Controllers { - public class SongRepository : GuidRepository + public class SongRepository : BaseRepository { public SongRepository(IFreeSql fsql) : base(fsql) { @@ -43,18 +43,6 @@ namespace restful.Controllers Console.Write(reposTest.Select.ToSql()); _songRepository = repos4; - //test code - var curd1 = fsql.GetRepository(); - var curd2 = fsql.GetRepository(); - var curd3 = fsql.GetRepository(); - var curd4 = fsql.GetGuidRepository(); - - Console.WriteLine(reposSong.Select.ToSql()); - - using (reposSong.DataFilter.DisableAll()) - { - Console.WriteLine(reposSong.Select.ToSql()); - } } [HttpGet] diff --git a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntity.cs b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntity.cs index 4ff412d9..5deee117 100644 --- a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntity.cs +++ b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntity.cs @@ -162,18 +162,5 @@ namespace FreeSql Repository.UnitOfWork = _resolveUow?.Invoke(); return Repository.InsertOrUpdate(this as TEntity); } - - /// - /// To completely save the navigation properties of the entity in the form of sub-tables.
- /// 【完整】保存导航属性,子表 - ///
- /// Navigation property name - public virtual void SaveMany(string navigatePropertyName) - { - if (Repository == null) - Repository = Orm.GetRepository(); - Repository.UnitOfWork = _resolveUow?.Invoke(); - Repository.SaveMany(this as TEntity, navigatePropertyName); - } } } \ No newline at end of file diff --git a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityAsync.cs b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityAsync.cs index da57e203..90828818 100644 --- a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityAsync.cs +++ b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityAsync.cs @@ -149,19 +149,6 @@ namespace FreeSql Repository.UnitOfWork = _resolveUow?.Invoke(); return Repository.InsertOrUpdateAsync(this as TEntity); } - - /// - /// To completely save the navigation properties of the entity in the form of sub-tables.
- /// 【完整】保存导航属性,子表 - ///
- /// Navigation property name - public virtual Task SaveManyAsync(string navigatePropertyName) - { - if (Repository == null) - Repository = Orm.GetRepository(); - Repository.UnitOfWork = _resolveUow?.Invoke(); - return Repository.SaveManyAsync(this as TEntity, navigatePropertyName); - } #endif } } \ No newline at end of file diff --git a/Extensions/FreeSql.Extensions.BaseEntity/FreeSql.Extensions.BaseEntity.xml b/Extensions/FreeSql.Extensions.BaseEntity/FreeSql.Extensions.BaseEntity.xml index f5d4630c..1508d48f 100644 --- a/Extensions/FreeSql.Extensions.BaseEntity/FreeSql.Extensions.BaseEntity.xml +++ b/Extensions/FreeSql.Extensions.BaseEntity/FreeSql.Extensions.BaseEntity.xml @@ -82,13 +82,6 @@ - - - To completely save the navigation properties of the entity in the form of sub-tables.
- 【完整】保存导航属性,子表 -
- Navigation property name -
Entity base class, including CreateTime/UpdateTime/IsDeleted, the async CRUD methods, and ID primary key definition. @@ -159,13 +152,6 @@ - - - To completely save the navigation properties of the entity in the form of sub-tables.
- 【完整】保存导航属性,子表 -
- Navigation property name -
Entity base class, including CreateTime/UpdateTime/IsDeleted. diff --git a/FreeSql.DbContext/FreeSql.DbContext.csproj b/FreeSql.DbContext/FreeSql.DbContext.csproj index a9389d2d..8db92b80 100644 --- a/FreeSql.DbContext/FreeSql.DbContext.csproj +++ b/FreeSql.DbContext/FreeSql.DbContext.csproj @@ -22,7 +22,7 @@ - + diff --git a/FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs b/FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs index 24e29736..957f7cae 100644 --- a/FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs +++ b/FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs @@ -21,9 +21,10 @@ namespace FreeSql { } - public IBaseRepository GetRepository() where TEntity : class + public IBaseRepository GetRepository() where TEntity : class => GetRepository(); + public IBaseRepository GetRepository() where TEntity : class { - var repo = new DefaultRepository(_fsql); + var repo = new DefaultRepository(_fsql); repo.UnitOfWork = this; return repo; } diff --git a/FreeSql.DbContext/Repository/Extensions/FreeSqlRepositoryExtensions.cs b/FreeSql.DbContext/Repository/Extensions/FreeSqlRepositoryExtensions.cs index 65344b1d..632c02eb 100644 --- a/FreeSql.DbContext/Repository/Extensions/FreeSqlRepositoryExtensions.cs +++ b/FreeSql.DbContext/Repository/Extensions/FreeSqlRepositoryExtensions.cs @@ -11,9 +11,10 @@ partial class FreeSqlDbContextExtensions /// /// /// - public static IBaseRepository GetRepository(this IFreeSql that) where TEntity : class + public static IBaseRepository GetRepository(this IFreeSql that) where TEntity : class => GetRepository(that); + public static IBaseRepository GetRepository(this IFreeSql that) where TEntity : class { - return new DefaultRepository(that); + return new DefaultRepository(that); } /// diff --git a/FreeSql.Tests/FreeSql.Tests.DbContext/RepositoryTests.cs b/FreeSql.Tests/FreeSql.Tests.DbContext/RepositoryTests.cs index 8f82d3cc..7b26828b 100644 --- a/FreeSql.Tests/FreeSql.Tests.DbContext/RepositoryTests.cs +++ b/FreeSql.Tests/FreeSql.Tests.DbContext/RepositoryTests.cs @@ -614,7 +614,7 @@ namespace FreeSql.Tests { g.sqlite.Insert(new AddUpdateInfo()).ExecuteAffrows(); - var repos = g.sqlite.GetGuidRepository(); + var repos = g.sqlite.GetRepository(); 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)); } diff --git a/FreeSql.Tests/FreeSql.Tests/Issues/1208.cs b/FreeSql.Tests/FreeSql.Tests/Issues/1208.cs index 5358365d..c58b3d68 100644 --- a/FreeSql.Tests/FreeSql.Tests/Issues/1208.cs +++ b/FreeSql.Tests/FreeSql.Tests/Issues/1208.cs @@ -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); +// } } } diff --git a/FreeSql.Tests/FreeSql.Tests/UnitTest2.cs b/FreeSql.Tests/FreeSql.Tests/UnitTest2.cs index 19a7dedf..6521ac81 100644 --- a/FreeSql.Tests/FreeSql.Tests/UnitTest2.cs +++ b/FreeSql.Tests/FreeSql.Tests/UnitTest2.cs @@ -382,16 +382,6 @@ namespace FreeSql.Tests var gft2 = g.mysql.Select().Where(a => a.id == Guid.NewGuid()).ToList(); var gft3 = g.mysql.Select().Where(a => a.id == Guid.NewGuid()).ToList(); - var repo1 = g.mysql.GetRepository(); - using (repo1.DataFilter.Disable("gft1", "gft2", "gft3")) - repo1.Get(Guid.NewGuid()); - var repo2 = g.mysql.GetRepository(); - using (repo2.DataFilter.Disable("gft1", "gft2", "gft3")) - repo2.Get(Guid.NewGuid()); - var repo3 = g.mysql.GetRepository(); - using (repo3.DataFilter.Disable("gft1", "gft2", "gft3")) - repo3.Get(Guid.NewGuid()); - g.sqlserver.Delete().Where("1=1").ExecuteAffrows(); g.mysql.Delete().Where("1=1").ExecuteAffrows(); g.pgsql.Delete().Where("1=1").ExecuteAffrows(); diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index a656490c..a7a29088 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -1104,93 +1104,6 @@ - - - 动态创建实体类型 - - - - - 配置Class - - 类名 - 类标记的特性[Table(Name = "xxx")] [Index(xxxx)] - - - - - 获取类型构建器,可作为要构建的Type来引用 - - - - - 配置属性 - - 属性名称 - 属性类型 - 属性标记的特性-支持多个 - - - - - 配置属性 - - 属性名称 - 属性类型 - 该属性是否重写父类属性 - 属性标记的特性-支持多个 - - - - - 配置属性 - - 属性名称 - 属性类型 - 该属性是否重写父类属性 - 属性默认值 - 属性标记的特性-支持多个 - - - - - 配置父类 - - 父类类型 - - - - - Override属性 - - - - - - Emit动态创建出Class - Type - - - - - - Emit动态创建出Class - Type,不附带获取TableInfo - - - - - - 首字母小写 - - - - - - - 首字母大写 - - - - 获取实体的主键值,以 "*|_,[,_|*" 分割,当任意一个主键属性无值时,返回 "" @@ -5913,28 +5826,6 @@ 请使用 fsql.InsertDict(dict) 方法插入字典数据 - - - 动态构建Class Type - - - - - - 根据字典,创建 table 对应的实体对象 - - - - - - - - 根据实体对象,创建 table 对应的字典 - - - - - C#: that >= between && that <= and