fix(IDataService): update data service extensions (#1866)

* doc: 更正单词拼写错误

* chore: 更正命名空间

* chore: 更新 FreeSql 扩展服务

* chore: 更新 PetaPoco 扩展服务

* chore: 更新 EFCore 扩展服务

* chore: 更新文件夹名称

* chore: 更新组件包
This commit is contained in:
Argo Zhang 2023-08-03 00:06:45 +08:00 committed by GitHub
parent 3cc7553ad1
commit 7db8c7addf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 52 additions and 54 deletions

View File

@ -50,12 +50,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "components", "components",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "data-services", "data-services", "{56FEFF09-85FC-408D-A397-6E264E68414E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.DataAcces.EntityFrameworkCore", "src\Extensions\DataServices\BootstrapBlazor.DataAcces.EntityFrameworkCore\BootstrapBlazor.DataAcces.EntityFrameworkCore.csproj", "{A6C321C4-CDB4-4432-8137-6D09D815261B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.DataAcces.PetaPoco", "src\Extensions\DataServices\BootstrapBlazor.DataAcces.PetaPoco\BootstrapBlazor.DataAcces.PetaPoco.csproj", "{90989C67-C908-41BD-ADF8-58A51F1CE612}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.DataAcces.FreeSql", "src\Extensions\DataServices\BootstrapBlazor.DataAcces.FreeSql\BootstrapBlazor.DataAcces.FreeSql.csproj", "{D501B535-B6CC-46FD-A497-08AA87731ED6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.Chart", "src\Extensions\Components\BootstrapBlazor.Chart\BootstrapBlazor.Chart.csproj", "{337FABF3-4318-408E-8544-C0F20D0197A1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.Markdown", "src\Extensions\Components\BootstrapBlazor.Markdown\BootstrapBlazor.Markdown.csproj", "{EEB9751A-5C06-4725-8037-FA9C0F140018}"
@ -127,7 +121,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.Html2Pdf",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.Live2DDisplay", "src\Extensions\Components\BootstrapBlazor.Live2DDisplay\BootstrapBlazor.Live2DDisplay.csproj", "{975D45E4-C354-4AFD-8D6F-571938E19105}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestDocs", "test\UnitTestDocs\UnitTestDocs.csproj", "{6D73FED6-0086-460B-84FA-1FA78176BF59}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTestDocs", "test\UnitTestDocs\UnitTestDocs.csproj", "{6D73FED6-0086-460B-84FA-1FA78176BF59}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.DataAccess.EntityFrameworkCore", "src\Extensions\DataServices\BootstrapBlazor.DataAccess.EntityFrameworkCore\BootstrapBlazor.DataAccess.EntityFrameworkCore.csproj", "{45AD6614-EA04-46E0-B71C-2B12D5F326FE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.DataAccess.FreeSql", "src\Extensions\DataServices\BootstrapBlazor.DataAccess.FreeSql\BootstrapBlazor.DataAccess.FreeSql.csproj", "{DC144D99-C0A9-41CC-92A6-034D7E1E0363}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor.DataAccess.PetaPoco", "src\Extensions\DataServices\BootstrapBlazor.DataAccess.PetaPoco\BootstrapBlazor.DataAccess.PetaPoco.csproj", "{8F189E6D-EC14-479F-8411-B5D967229D78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -143,18 +143,6 @@ Global
{190F25CF-C6F9-4964-97E9-F6A912D527AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{190F25CF-C6F9-4964-97E9-F6A912D527AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{190F25CF-C6F9-4964-97E9-F6A912D527AE}.Release|Any CPU.Build.0 = Release|Any CPU
{A6C321C4-CDB4-4432-8137-6D09D815261B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6C321C4-CDB4-4432-8137-6D09D815261B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6C321C4-CDB4-4432-8137-6D09D815261B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6C321C4-CDB4-4432-8137-6D09D815261B}.Release|Any CPU.Build.0 = Release|Any CPU
{90989C67-C908-41BD-ADF8-58A51F1CE612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90989C67-C908-41BD-ADF8-58A51F1CE612}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90989C67-C908-41BD-ADF8-58A51F1CE612}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90989C67-C908-41BD-ADF8-58A51F1CE612}.Release|Any CPU.Build.0 = Release|Any CPU
{D501B535-B6CC-46FD-A497-08AA87731ED6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D501B535-B6CC-46FD-A497-08AA87731ED6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D501B535-B6CC-46FD-A497-08AA87731ED6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D501B535-B6CC-46FD-A497-08AA87731ED6}.Release|Any CPU.Build.0 = Release|Any CPU
{337FABF3-4318-408E-8544-C0F20D0197A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{337FABF3-4318-408E-8544-C0F20D0197A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{337FABF3-4318-408E-8544-C0F20D0197A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -263,6 +251,18 @@ Global
{6D73FED6-0086-460B-84FA-1FA78176BF59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D73FED6-0086-460B-84FA-1FA78176BF59}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D73FED6-0086-460B-84FA-1FA78176BF59}.Release|Any CPU.Build.0 = Release|Any CPU
{45AD6614-EA04-46E0-B71C-2B12D5F326FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45AD6614-EA04-46E0-B71C-2B12D5F326FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45AD6614-EA04-46E0-B71C-2B12D5F326FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45AD6614-EA04-46E0-B71C-2B12D5F326FE}.Release|Any CPU.Build.0 = Release|Any CPU
{DC144D99-C0A9-41CC-92A6-034D7E1E0363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC144D99-C0A9-41CC-92A6-034D7E1E0363}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC144D99-C0A9-41CC-92A6-034D7E1E0363}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC144D99-C0A9-41CC-92A6-034D7E1E0363}.Release|Any CPU.Build.0 = Release|Any CPU
{8F189E6D-EC14-479F-8411-B5D967229D78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F189E6D-EC14-479F-8411-B5D967229D78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F189E6D-EC14-479F-8411-B5D967229D78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F189E6D-EC14-479F-8411-B5D967229D78}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -277,9 +277,6 @@ Global
{C8E79F4C-8C55-4E13-96B5-3D2BD6A07B74} = {A2182155-43ED-44C1-BF6F-1B70EBD2DFFE}
{CD062AB6-244D-402A-8F33-C37DAC5856CC} = {22328011-53B3-447A-B781-AC3C196B2847}
{56FEFF09-85FC-408D-A397-6E264E68414E} = {22328011-53B3-447A-B781-AC3C196B2847}
{A6C321C4-CDB4-4432-8137-6D09D815261B} = {56FEFF09-85FC-408D-A397-6E264E68414E}
{90989C67-C908-41BD-ADF8-58A51F1CE612} = {56FEFF09-85FC-408D-A397-6E264E68414E}
{D501B535-B6CC-46FD-A497-08AA87731ED6} = {56FEFF09-85FC-408D-A397-6E264E68414E}
{337FABF3-4318-408E-8544-C0F20D0197A1} = {CD062AB6-244D-402A-8F33-C37DAC5856CC}
{EEB9751A-5C06-4725-8037-FA9C0F140018} = {CD062AB6-244D-402A-8F33-C37DAC5856CC}
{5ED0DD16-1583-4FC3-B2E9-FE5DBA98BD47} = {CD062AB6-244D-402A-8F33-C37DAC5856CC}
@ -308,6 +305,9 @@ Global
{CA5BF6FD-257E-4D4B-8DF0-F4035B0C7CA2} = {CD062AB6-244D-402A-8F33-C37DAC5856CC}
{975D45E4-C354-4AFD-8D6F-571938E19105} = {CD062AB6-244D-402A-8F33-C37DAC5856CC}
{6D73FED6-0086-460B-84FA-1FA78176BF59} = {7C1D79F1-87BC-42C1-BD5A-CDE4044AC1BD}
{45AD6614-EA04-46E0-B71C-2B12D5F326FE} = {56FEFF09-85FC-408D-A397-6E264E68414E}
{DC144D99-C0A9-41CC-92A6-034D7E1E0363} = {56FEFF09-85FC-408D-A397-6E264E68414E}
{8F189E6D-EC14-479F-8411-B5D967229D78} = {56FEFF09-85FC-408D-A397-6E264E68414E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0DCB0756-34FA-4FD0-AE1D-D3F08B5B3A6B}

View File

@ -44,7 +44,7 @@
<PackageReference Include="BootstrapBlazor.SignaturePad" Version="7.0.3" />
<PackageReference Include="BootstrapBlazor.SummerNote" Version="7.3.4" />
<PackageReference Include="BootstrapBlazor.TableExport" Version="7.5.0" />
<PackageReference Include="BootstrapBlazor.Topology" Version="7.4.4" />
<PackageReference Include="BootstrapBlazor.Topology" Version="7.4.5" />
<PackageReference Include="BootstrapBlazor.VideoPlayer" Version="7.0.4" />
<PackageReference Include="BootstrapBlazor.MouseFollower" Version="7.0.0" />
</ItemGroup>

View File

@ -27,7 +27,7 @@ public abstract class BootstrapServiceBase<TOption>
: Cache.FirstOrDefault();
if (Callback == null)
{
throw new InvalidOperationException($"{GetType().Name} not registerd. refer doc https://www.blazor.zone/install-server step 7 for BootstrapBlazorRoot");
throw new InvalidOperationException($"{GetType().Name} not registered. refer doc https://www.blazor.zone/install-server step 7 for BootstrapBlazorRoot");
}
await Callback.Invoke(option);
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>7.0.0</Version>
<Version>7.1.0</Version>
<PackageTags>Bootstrap Blazor WebAssembly wasm UI Components EFCore</PackageTags>
<Description>Bootstrap UI components extensions of EFCore</Description>
</PropertyGroup>
@ -17,9 +17,9 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.*" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="7.0.0" />
<PackageReference Include="BootstrapBlazor" Version="7.9.0" />
</ItemGroup>
</Project>

View File

@ -5,7 +5,7 @@
using BootstrapBlazor.Components;
using Microsoft.EntityFrameworkCore;
namespace BootstrapBlazor.DataAcces.EntityFrameworkCore;
namespace BootstrapBlazor.DataAccess.EntityFrameworkCore;
/// <summary>
/// Entity Framework ORM 的 IDataService 接口实现
@ -106,7 +106,7 @@ internal class DefaultDataService<TModel> : DataServiceBase<TModel>, IEntityFram
{
// 处理过滤与快捷搜索框逻辑
var query = _db.Set<TModel>()
.Where(option.Searchs.GetFilterLambda<TModel>(FilterLogic.Or), option.Searchs.Any())
.Where(option.Searches.GetFilterLambda<TModel>(FilterLogic.Or), option.Searches.Any())
.Where(option.Filters.GetFilterLambda<TModel>(), option.Filters.Any())
.Sort(option.SortName!, option.SortOrder, !string.IsNullOrEmpty(option.SortName))
.Count(out var count)

View File

@ -3,7 +3,7 @@
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapBlazor.Components;
using BootstrapBlazor.DataAcces.EntityFrameworkCore;
using BootstrapBlazor.DataAccess.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace Microsoft.Extensions.DependencyInjection;

View File

@ -5,7 +5,7 @@
using BootstrapBlazor.Components;
using System.Linq.Expressions;
namespace BootstrapBlazor.DataAcces.EntityFrameworkCore;
namespace BootstrapBlazor.DataAccess.EntityFrameworkCore;
/// <summary>
/// IQueryable 扩展方法

View File

@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>7.0.0</Version>
<Version>7.1.0</Version>
<PackageTags>Bootstrap Blazor WebAssembly wasm UI Components FreeSql</PackageTags>
<Description>Bootstrap UI components extensions of FreeSql</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="7.0.0" />
<PackageReference Include="FreeSql.Repository" Version="3.2.682" />
<PackageReference Include="BootstrapBlazor" Version="7.9.0" />
<PackageReference Include="FreeSql.Repository" Version="3.2.698" />
</ItemGroup>
</Project>

View File

@ -4,7 +4,7 @@
using BootstrapBlazor.Components;
namespace BootstrapBlazor.DataAcces.FreeSql;
namespace BootstrapBlazor.DataAccess.FreeSql;
/// <summary>
/// FreeSql ORM 的 IDataService 接口实现

View File

@ -5,7 +5,7 @@
using BootstrapBlazor.Components;
using FreeSql.Internal.Model;
namespace BootstrapBlazor.DataAcces.FreeSql;
namespace BootstrapBlazor.DataAccess.FreeSql;
/// <summary>
///
@ -27,27 +27,27 @@ public static class FreeSqlExtensions
ret.Filters.Add(filter.ToDynamicFilter());
}
foreach (var search in option.CustomerSearchs)
foreach (var search in option.CustomerSearches)
{
// 自定义搜索条件 之间默认为 and
ret.Filters.Add(search.ToDynamicFilter());
}
foreach (var search in option.AdvanceSearchs)
foreach (var search in option.AdvanceSearches)
{
// 高级搜索条件 之间默认为 and
ret.Filters.Add(search.ToDynamicFilter());
}
if (option.Searchs.Any())
if (option.Searches.Any())
{
// Searchs 之间默认为 or
// Searches 之间默认为 or
var searchTextFilter = new DynamicFilterInfo()
{
Logic = DynamicFilterLogic.Or,
Filters = new List<DynamicFilterInfo>()
};
foreach (var search in option.Searchs)
foreach (var search in option.Searches)
{
searchTextFilter.Filters.Add(search.ToDynamicFilter());
}

View File

@ -3,9 +3,8 @@
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapBlazor.Components;
using BootstrapBlazor.DataAcces.FreeSql;
using BootstrapBlazor.DataAccess.FreeSql;
using FreeSql;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection;
@ -23,7 +22,7 @@ public static class FreeSqlServiceCollectionExtensions
/// <returns></returns>
public static IServiceCollection AddFreeSql(this IServiceCollection services, Action<FreeSqlBuilder> optionsAction, Action<IFreeSql>? configureAction = null)
{
services.TryAddSingleton<IFreeSql>(sp =>
services.AddSingleton<IFreeSql>(sp =>
{
var builder = new FreeSqlBuilder();
optionsAction(builder);
@ -32,7 +31,7 @@ public static class FreeSqlServiceCollectionExtensions
return instance;
});
services.TryAddSingleton(typeof(IDataService<>), typeof(DefaultDataService<>));
services.AddScoped(typeof(IDataService<>), typeof(DefaultDataService<>));
return services;
}
}

View File

@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>7.0.0</Version>
<Version>7.1.0</Version>
<PackageTags>Bootstrap Blazor WebAssembly wasm UI Components PetaPoco</PackageTags>
<Description>Bootstrap UI components extensions of PetaPoco</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="7.0.0" />
<PackageReference Include="BootstrapBlazor" Version="7.9.0" />
<PackageReference Include="Longbow.PetaPoco" Version="5.0.1" />
<PackageReference Include="PetaPoco.Extensions" Version="6.0.0" />
</ItemGroup>

View File

@ -7,7 +7,7 @@ using PetaPoco;
using System.Linq.Expressions;
using System.Reflection;
namespace BootstrapBlazor.DataAcces.PetaPoco;
namespace BootstrapBlazor.DataAccess.PetaPoco;
/// <summary>
///

View File

@ -6,7 +6,7 @@ using BootstrapBlazor.Components;
using PetaPoco;
using PetaPoco.Extensions;
namespace BootstrapBlazor.DataAcces.PetaPoco;
namespace BootstrapBlazor.DataAccess.PetaPoco;
/// <summary>
/// PetaPoco ORM 的 IDataService 接口实现
@ -64,14 +64,14 @@ internal class DefaultDataService<TModel> : DataServiceBase<TModel> where TModel
if (option.IsPage)
{
var items = await _db.PageAsync<TModel>(option.PageIndex, option.PageItems, option.Filters.Concat(option.Searchs), option.SortName, option.SortOrder);
var items = await _db.PageAsync<TModel>(option.PageIndex, option.PageItems, option.Filters.Concat(option.Searches), option.SortName, option.SortOrder);
ret.TotalCount = int.Parse(items.TotalItems.ToString());
ret.Items = items.Items;
}
else
{
var items = await _db.FetchAsync<TModel>(option.Filters.Concat(option.Searchs), option.SortName, option.SortOrder);
var items = await _db.FetchAsync<TModel>(option.Filters.Concat(option.Searches), option.SortName, option.SortOrder);
ret.TotalCount = items.Count;
ret.Items = items;
}

View File

@ -3,8 +3,7 @@
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapBlazor.Components;
using BootstrapBlazor.DataAcces.PetaPoco;
using Microsoft.Extensions.DependencyInjection.Extensions;
using BootstrapBlazor.DataAccess.PetaPoco;
using PetaPoco;
namespace Microsoft.Extensions.DependencyInjection;
@ -28,7 +27,7 @@ public static class PetaPocoServiceCollectionExtensions
optionsAction(builder);
return new Database(builder);
});
services.TryAddSingleton(typeof(IDataService<>), typeof(DefaultDataService<>));
services.AddScoped(typeof(IDataService<>), typeof(DefaultDataService<>));
return services;
}
}