From fbc9ff470325c10e278b2a471a3485dd4a1f3ac8 Mon Sep 17 00:00:00 2001 From: Hamza Albreem <94292623+braim23@users.noreply.github.com> Date: Wed, 12 Jan 2022 17:14:47 +0300 Subject: [PATCH 01/11] Update POST.md Updated and fixed a few things --- .../2022-01-11 v5_1_Release_Stable/POST.md | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST.md b/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST.md index 8ff63e3edd..2e09e9fb21 100644 --- a/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST.md +++ b/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST.md @@ -1,14 +1,14 @@ # ABP.IO Platform 5.1 Has Been Released -Today, we are releasing the [ABP Framework](https://abp.io/) and the [ABP Commercial](https://commercial.abp.io/) version 5.1 (with a version number `5.1.1`). This blog post introduces the new features and important changes in this new version. +Today, we are releasing the [ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) version 5.1 (with a version number `5.1.1`). This blog post introduces the new features and important changes in this new version. > **Warning** > -> For a long time we were releasing RC (Release Candidate) versions a few weeks before every minor and major release. **This version has been released without a preview version.** This is because we've accidently released all the packages with a stable version number, without a `-rc.1` suffix and there is no clear way to unpublish all the NuGet and NPM packages. Sorry about that. However, it doesn't mean that this release is buggy. We've already resolved known problems. We will publish one or more patch releases if needed. You can follow [this milestone](https://github.com/abpframework/abp/milestone/64?closed=1) for known problems or submit your own bug report. If you are worried about its stability, you can wait for the next patch release. +> For a long time we've been releasing RC (Release Candidate) versions a few weeks prior to every minor and major release. **This version has been released without a preview version.** This is because we've accidently released all the packages with a stable version number, without a `-rc.1` suffix and there is no clear way to unpublish all the NuGet and NPM packages. We're sorry about that. However, it doesn't mean that this release is buggy. We've already resolved the known problems. We will publish one or more patch releases if needed. You can follow [this milestone](https://github.com/abpframework/abp/milestone/64?closed=1) for the common problems or submit your own bug report. If you are worried about its stability, you can wait for the next patch release. -## Get Started with the 5.1 +## Get Started with 5.1 -follow the steps below to try the version 5.1 today; +Follow the steps below to try the 5.1 version today: 1) **Upgrade** the ABP CLI to the latest version using a command line terminal: @@ -16,7 +16,7 @@ follow the steps below to try the version 5.1 today; dotnet tool update Volo.Abp.Cli -g ```` -**or install** if you haven't installed before: +**or install** if you haven't installed it before: ````bash dotnet tool install Volo.Abp.Cli -g @@ -28,7 +28,7 @@ dotnet tool install Volo.Abp.Cli -g abp new BookStore ```` -See the [ABP CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all the available options. +Check out the [ABP CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all the available options. > You can also use the *Direct Download* tab on the [Get Started](https://abp.io/get-started) page. @@ -36,11 +36,11 @@ You can use any IDE that supports .NET 6.x development (e.g. [Visual Studio 2022 ### Migration Notes & Breaking Changes -This is an minor feature release, mostly with enhancements and improvements based on the [version 5.0](https://blog.abp.io/abp/ABP-IO-Platform-5-0-Final-Has-Been-Released). There is no breaking change except the Angular UI upgrade. ABP 5.1 startup templates use **Angular 13**. +This is a minor feature release, mostly with enhancements and improvements based on [version 5.0](https://blog.abp.io/abp/ABP-IO-Platform-5-0-Final-Has-Been-Released). There aren't any breaking changes except for the Angular UI upgrade. ABP 5.1 startup templates use **Angular 13**. ### Angular UI -**If you want to upgrade ABP Framework but want to continue with Angular 12**, add the following section to `package.json` file of the Angular project: +**If you want to upgrade the ABP Framework but want to continue with Angular 12**, add the following section to the `package.json` file of the Angular project: ````json "resolutions": { @@ -49,19 +49,19 @@ This is an minor feature release, mostly with enhancements and improvements base } ```` -## What's new with ABP Framework 5.1? +## What's New with the ABP Framework 5.1? In this section, I will introduce some major features released with this version. -### The new hosting model +### The New Hosting Model -ABP startup application template now uses the new ASP.NET Core hosting APIs ([see the Microsoft's minimal APIs document](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0)) on application startup ([see the exact place in the ABP startup template](https://github.com/abpframework/abp/blob/46cdfbe7b06c93690181633be4e96bf62e7f34e2/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs#L33-L40)). So, the `Startup.cs` file has been removed. +The ABP startup application template now uses the new ASP.NET Core hosting APIs ([check out the Microsoft's minimal APIs document](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0)) on application startup ([check out the exact place in the ABP startup template](https://github.com/abpframework/abp/blob/46cdfbe7b06c93690181633be4e96bf62e7f34e2/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs#L33-L40)). So, the `Startup.cs` file has been removed. -Old-style hosting logic will continue to work as long as ASP.NET Core supports it. It is recommended to switch to the new model if possible for your solution. See [this guide](https://docs.abp.io/en/abp/latest/Migration-Guides/Upgrading-Startup-Template) if you need to know how you can to do that. +Old-style hosting logic will continue to work as long as ASP.NET Core supports it. It is recommended to switch to the new model if it's possible for your solution. Check out [this guide](https://docs.abp.io/en/abp/latest/Migration-Guides/Upgrading-Startup-Template) if you need to know how to do that. -### Asynchronous startup lifecycle methods +### Asynchronous Startup Lifecycle Methods -The new hosting model allows us to execute asynchronous code on application initialization in [ABP module](https://docs.abp.io/en/abp/latest/Module-Development-Basics) classes. If you are using the new hosting model (which is default with 5.1 startup templates), you can override the `Async` versions of the module lifecycle methods. +The new hosting model allows us to execute asynchronous code on application initialization in the [ABP module](https://docs.abp.io/en/abp/latest/Module-Development-Basics) classes. If you are using the new hosting model (which is default with 5.1 startup templates), you can override the `Async` versions of the module lifecycle methods. For example, you can now override the `ConfigureServicesAsync` (instead of `ConfigureServices`) or `OnApplicationInitializationAsync` (instead of `OnApplicationInitialization`) as shown in the following code block: @@ -80,46 +80,46 @@ public class MyModule : AbpModule } ```` -If you override both of asynchronous and synchronous versions of the same method, only the asynchronous one will be executed. So, override only one of them based on your needs. +If you override both the asynchronous and synchronous versions of the same method, only the asynchronous one will be executed. So, override only one of them based on your needs. -### eShopOnABP is getting mature +### eShopOnABP Is Getting More Stable -Our team is working to finalize the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) example solution, which is a reference **microservice solution** built with the ABP Framework. They will explain the project status and show what's done in the next **ABP Community Talks** meeting (see the *ABP Community Talks 2021.1* section below in this post). +Our team is working to finalize the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) example solution, which is a reference **microservice solution** built with the ABP Framework. They will explain the project status and show what's done in the next **ABP Community Talks** meeting (Check out the *ABP Community Talks 2021.1* section at the bottom of this post). -### The new ABP.IO design! +### The New ABP.IO Design! -We were working on a new design for the [abp.io](https://abp.io/) websites for a while. We are making the final touches; the new design will be live very soon. Here a screenshot from the design work: +We've been working on a new design for the [abp.io](https://abp.io/) websites for a while. We are adding the final touches; the new design will be live very soon. Here's a screenshot from the design work: ![new-abp-io-design](new-abp-io-design.png) -[ABP Commercial](https://commercial.abp.io/) and [ABP Community](https://community.abp.io/) websites will also have new designs as a part of this update. +The [ABP Commercial](https://commercial.abp.io/) and [ABP Community](https://community.abp.io/) websites will also have new designs as part of this update. -### Other changes +### Other Changes -Here some other notable changes that come with this release: +Here are some other notable changes that come with this release: * Support markdown in [CMS-Kit comments ](https://docs.abp.io/en/abp/latest/Modules/Cms-Kit/Comments)feature ([#10792](https://github.com/abpframework/abp/pull/10792)) * Used file scoped namespaces for all the ABP Framework source code :) ([#10552](https://github.com/abpframework/abp/pull/10696)) All issues & PRs in [5.1 milesone](https://github.com/abpframework/abp/milestone/60?closed=1). -### About the ABP Commercial +### About ABP Commercial -The core team is also working on the ABP Commercial (which provides pre-built modules, themes, tooling and support on top of the ABP Framework). We've done a lot of minor improvements and fixes to the modules and tooling. +The core team is also working on ABP Commercial (which provides pre-built modules, themes, tooling and support on top of the ABP Framework). We've done a lot of minor improvements and fixes to the modules and tooling. -One exiting new is about the **LeptonX theme**; We are working on to make it available in **MVC (Razor Pages)** and **Blazor** UI options too (in addition to the Angular UI). We are also adding more components, layout options, demo pages, etc... We are planning to release a beta version in the next weeks. Here an animated GIF from the dashboard we've prepared as a demonstration: +There's some exciting news about the **LeptonX theme**; We are working on making it available in the **MVC (Razor Pages)** and **Blazor** UI options too (in addition to Angular UI). We are also adding more components, layout options, demo pages, etc... We are planning to release a beta version in the next weeks. Here's an animated GIF from the dashboard we've prepared as a demonstration: ![leptonx-dash](leptonx-dash.gif) -If you are wondering what is the LeptonX project, please see [that blog post](https://blog.abp.io/abp/LeptonX-Theme-for-ABP-Framework-Alpha-Release). +If you are wondering what is the LeptonX project, please check out this [blog post](https://blog.abp.io/abp/LeptonX-Theme-for-ABP-Framework-Alpha-Release). As another visible functionality, we've added a new feature to the [CMS Kit Pro](https://docs.abp.io/en/commercial/latest/modules/cms-kit/index) module that is used to forward a URL to another URL. This is a screenshot from the management UI: ![url-forward](url-forward.png) -This feature can be used to create short URLs in your application (like URL shortening services provide) or forward old pages to their new URLs. +This feature can be used to create short URLs in your application (like URL shortening services providers) or forward old pages to their new URLs. -In addition to the new features shipped in every minor version, we are working on long-term projects for ABP.IO Platform and ABP Commercial (a little secret for now :). We will have announcements once these projects get mature. +In addition to the new features shipped in every minor version, we are working on long-term projects for ABP.IO Platform and ABP Commercial (a little secret for now :). We will have announcements once these projects get more stable. ## Community News @@ -127,15 +127,15 @@ In addition to the new features shipped in every minor version, we are working o ![abp-community-talks-2022-1](abp-community-talks-2022-1.png) -This is the second episode of the ABP Community Talks and we are talking about microservice development with the ABP Framework, based on the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) reference solution. We will also briefly talk about the changes that come with ABP version 5.1. This **live meeting** will be at **January 20, 2022, 17:00 (UTC)** on YouTube. +This is the second episode of the ABP Community Talks and we are talking about microservice development with the ABP Framework, based on the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) reference solution. We will also briefly talk about the changes that come with ABP version 5.1. This **live meeting** will be on **January 20, 2022, 17:00 (UTC)** on YouTube. **Join this event on the Kommunity platform: https://kommunity.com/volosoft/events/abp-community-talks-20221-microservice-development-acd0f44b** -You can also [subscribe to the Volosoft channel](https://www.youtube.com/channel/UCO3XKlpvq8CA5MQNVS6b3dQ) for reminders for further ABP events and videos. +You can also [subscribe to Volosoft YouTube channel](https://www.youtube.com/channel/UCO3XKlpvq8CA5MQNVS6b3dQ) for reminders of further ABP events and videos. -### New ABP Community posts +### New ABP Community Posts -Here, some of the recent posts added to the [ABP community](https://community.abp.io/): +Here are some of the recent posts added to the [ABP community](https://community.abp.io/): * [Minimal API development with the ABP Framework](https://community.abp.io/articles/minimal-api-with-abp-hello-world-part-1-sg5i44p8) by [@antosubash](https://github.com/antosubash) (three parts, video tutorial). * [Integrating the Syncfusion MVC Components to the ABP MVC UI](https://community.abp.io/articles/integrating-the-syncfusion-mvc-components-to-the-abp-mvc-ui-0gpkr1if) by [@EngincanV](https://github.com/EngincanV). @@ -146,4 +146,4 @@ Thanks to the ABP Community for all the contents they have published. You can al ## Conclusion -In this blog post, I summarized the news about that new version and the ABP Community. Please try it and provide feedback by opening issues on [the GitHub repository](https://github.com/abpframework/abp). Thank you all! +In this blog post, I summarized the news about the new version and the ABP Community. Please try it and provide feedback by opening issues on the [GitHub repository](https://github.com/abpframework/abp). Thank you all! From 8167a62c9f103ea6424815853d20e1353f81c72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Jan 2022 08:41:13 +0300 Subject: [PATCH 02/11] Create POST-on-blog.md --- .../POST-on-blog.md | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md diff --git a/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md b/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md new file mode 100644 index 0000000000..2e09e9fb21 --- /dev/null +++ b/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md @@ -0,0 +1,149 @@ +# ABP.IO Platform 5.1 Has Been Released + +Today, we are releasing the [ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) version 5.1 (with a version number `5.1.1`). This blog post introduces the new features and important changes in this new version. + +> **Warning** +> +> For a long time we've been releasing RC (Release Candidate) versions a few weeks prior to every minor and major release. **This version has been released without a preview version.** This is because we've accidently released all the packages with a stable version number, without a `-rc.1` suffix and there is no clear way to unpublish all the NuGet and NPM packages. We're sorry about that. However, it doesn't mean that this release is buggy. We've already resolved the known problems. We will publish one or more patch releases if needed. You can follow [this milestone](https://github.com/abpframework/abp/milestone/64?closed=1) for the common problems or submit your own bug report. If you are worried about its stability, you can wait for the next patch release. + +## Get Started with 5.1 + +Follow the steps below to try the 5.1 version today: + +1) **Upgrade** the ABP CLI to the latest version using a command line terminal: + +````bash +dotnet tool update Volo.Abp.Cli -g +```` + +**or install** if you haven't installed it before: + +````bash +dotnet tool install Volo.Abp.Cli -g +```` + +2) Create a **new application**: + +````bash +abp new BookStore +```` + +Check out the [ABP CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all the available options. + +> You can also use the *Direct Download* tab on the [Get Started](https://abp.io/get-started) page. + +You can use any IDE that supports .NET 6.x development (e.g. [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/)). + +### Migration Notes & Breaking Changes + +This is a minor feature release, mostly with enhancements and improvements based on [version 5.0](https://blog.abp.io/abp/ABP-IO-Platform-5-0-Final-Has-Been-Released). There aren't any breaking changes except for the Angular UI upgrade. ABP 5.1 startup templates use **Angular 13**. + +### Angular UI + +**If you want to upgrade the ABP Framework but want to continue with Angular 12**, add the following section to the `package.json` file of the Angular project: + +````json +"resolutions": { + "ng-zorro-antd": "^12.1.1", + "@ng-bootstrap/ng-bootstrap": "11.0.0-beta.2" + } +```` + +## What's New with the ABP Framework 5.1? + +In this section, I will introduce some major features released with this version. + +### The New Hosting Model + +The ABP startup application template now uses the new ASP.NET Core hosting APIs ([check out the Microsoft's minimal APIs document](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0)) on application startup ([check out the exact place in the ABP startup template](https://github.com/abpframework/abp/blob/46cdfbe7b06c93690181633be4e96bf62e7f34e2/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs#L33-L40)). So, the `Startup.cs` file has been removed. + +Old-style hosting logic will continue to work as long as ASP.NET Core supports it. It is recommended to switch to the new model if it's possible for your solution. Check out [this guide](https://docs.abp.io/en/abp/latest/Migration-Guides/Upgrading-Startup-Template) if you need to know how to do that. + +### Asynchronous Startup Lifecycle Methods + +The new hosting model allows us to execute asynchronous code on application initialization in the [ABP module](https://docs.abp.io/en/abp/latest/Module-Development-Basics) classes. If you are using the new hosting model (which is default with 5.1 startup templates), you can override the `Async` versions of the module lifecycle methods. + +For example, you can now override the `ConfigureServicesAsync` (instead of `ConfigureServices`) or `OnApplicationInitializationAsync` (instead of `OnApplicationInitialization`) as shown in the following code block: + +````csharp +public class MyModule : AbpModule +{ + public override async Task ConfigureServicesAsync(ServiceConfigurationContext context) + { + /* You can use await here and safely execute other async methods */ + } + + public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context) + { + /* You can use await here and safely execute other async methods */ + } +} +```` + +If you override both the asynchronous and synchronous versions of the same method, only the asynchronous one will be executed. So, override only one of them based on your needs. + +### eShopOnABP Is Getting More Stable + +Our team is working to finalize the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) example solution, which is a reference **microservice solution** built with the ABP Framework. They will explain the project status and show what's done in the next **ABP Community Talks** meeting (Check out the *ABP Community Talks 2021.1* section at the bottom of this post). + +### The New ABP.IO Design! + +We've been working on a new design for the [abp.io](https://abp.io/) websites for a while. We are adding the final touches; the new design will be live very soon. Here's a screenshot from the design work: + +![new-abp-io-design](new-abp-io-design.png) + +The [ABP Commercial](https://commercial.abp.io/) and [ABP Community](https://community.abp.io/) websites will also have new designs as part of this update. + +### Other Changes + +Here are some other notable changes that come with this release: + +* Support markdown in [CMS-Kit comments ](https://docs.abp.io/en/abp/latest/Modules/Cms-Kit/Comments)feature ([#10792](https://github.com/abpframework/abp/pull/10792)) +* Used file scoped namespaces for all the ABP Framework source code :) ([#10552](https://github.com/abpframework/abp/pull/10696)) + +All issues & PRs in [5.1 milesone](https://github.com/abpframework/abp/milestone/60?closed=1). + +### About ABP Commercial + +The core team is also working on ABP Commercial (which provides pre-built modules, themes, tooling and support on top of the ABP Framework). We've done a lot of minor improvements and fixes to the modules and tooling. + +There's some exciting news about the **LeptonX theme**; We are working on making it available in the **MVC (Razor Pages)** and **Blazor** UI options too (in addition to Angular UI). We are also adding more components, layout options, demo pages, etc... We are planning to release a beta version in the next weeks. Here's an animated GIF from the dashboard we've prepared as a demonstration: + +![leptonx-dash](leptonx-dash.gif) + +If you are wondering what is the LeptonX project, please check out this [blog post](https://blog.abp.io/abp/LeptonX-Theme-for-ABP-Framework-Alpha-Release). + +As another visible functionality, we've added a new feature to the [CMS Kit Pro](https://docs.abp.io/en/commercial/latest/modules/cms-kit/index) module that is used to forward a URL to another URL. This is a screenshot from the management UI: + +![url-forward](url-forward.png) + +This feature can be used to create short URLs in your application (like URL shortening services providers) or forward old pages to their new URLs. + +In addition to the new features shipped in every minor version, we are working on long-term projects for ABP.IO Platform and ABP Commercial (a little secret for now :). We will have announcements once these projects get more stable. + +## Community News + +### ABP Community Talks 2021.1 + +![abp-community-talks-2022-1](abp-community-talks-2022-1.png) + +This is the second episode of the ABP Community Talks and we are talking about microservice development with the ABP Framework, based on the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) reference solution. We will also briefly talk about the changes that come with ABP version 5.1. This **live meeting** will be on **January 20, 2022, 17:00 (UTC)** on YouTube. + +**Join this event on the Kommunity platform: https://kommunity.com/volosoft/events/abp-community-talks-20221-microservice-development-acd0f44b** + +You can also [subscribe to Volosoft YouTube channel](https://www.youtube.com/channel/UCO3XKlpvq8CA5MQNVS6b3dQ) for reminders of further ABP events and videos. + +### New ABP Community Posts + +Here are some of the recent posts added to the [ABP community](https://community.abp.io/): + +* [Minimal API development with the ABP Framework](https://community.abp.io/articles/minimal-api-with-abp-hello-world-part-1-sg5i44p8) by [@antosubash](https://github.com/antosubash) (three parts, video tutorial). +* [Integrating the Syncfusion MVC Components to the ABP MVC UI](https://community.abp.io/articles/integrating-the-syncfusion-mvc-components-to-the-abp-mvc-ui-0gpkr1if) by [@EngincanV](https://github.com/EngincanV). +* [Add Tailwind CSS to your ABP Blazor UI](https://community.abp.io/articles/add-tailwindcss-to-your-abp-blazor-ui-vidiwzcy) by [@antosubash](https://github.com/antosubash) (video tutorial). +* [Import external users into the users Table from an ABP Framework application](https://community.abp.io/articles/import-external-users-into-the-users-table-from-an-abp-framework-application-7lnyw415) by [@bartvanhoey](https://github.com/bartvanhoey). + +Thanks to the ABP Community for all the contents they have published. You can also [post your ABP and .NET related (text or video) contents](https://community.abp.io/articles/submit) to the ABP Community. + +## Conclusion + +In this blog post, I summarized the news about the new version and the ABP Community. Please try it and provide feedback by opening issues on the [GitHub repository](https://github.com/abpframework/abp). Thank you all! From 6669fbcc676df0a149590deddc237b765d02638b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Jan 2022 08:47:20 +0300 Subject: [PATCH 03/11] Update POST-on-blog.md --- .../2022-01-11 v5_1_Release_Stable/POST-on-blog.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md b/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md index 2e09e9fb21..4105cfdf18 100644 --- a/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md +++ b/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md @@ -1,5 +1,3 @@ -# ABP.IO Platform 5.1 Has Been Released - Today, we are releasing the [ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) version 5.1 (with a version number `5.1.1`). This blog post introduces the new features and important changes in this new version. > **Warning** @@ -90,7 +88,7 @@ Our team is working to finalize the [eShopOnAbp](https://github.com/abpframework We've been working on a new design for the [abp.io](https://abp.io/) websites for a while. We are adding the final touches; the new design will be live very soon. Here's a screenshot from the design work: -![new-abp-io-design](new-abp-io-design.png) +![new-abp-io-design.png](/api/blogging/files/www/04c9be6a819f74d7d7003a0165ff0d88.png) The [ABP Commercial](https://commercial.abp.io/) and [ABP Community](https://community.abp.io/) websites will also have new designs as part of this update. @@ -109,13 +107,13 @@ The core team is also working on ABP Commercial (which provides pre-built module There's some exciting news about the **LeptonX theme**; We are working on making it available in the **MVC (Razor Pages)** and **Blazor** UI options too (in addition to Angular UI). We are also adding more components, layout options, demo pages, etc... We are planning to release a beta version in the next weeks. Here's an animated GIF from the dashboard we've prepared as a demonstration: -![leptonx-dash](leptonx-dash.gif) +![leptonx-dash-2.png](/api/blogging/files/www/1b50e6d6317b84f963ab3a016602cca7.png) If you are wondering what is the LeptonX project, please check out this [blog post](https://blog.abp.io/abp/LeptonX-Theme-for-ABP-Framework-Alpha-Release). As another visible functionality, we've added a new feature to the [CMS Kit Pro](https://docs.abp.io/en/commercial/latest/modules/cms-kit/index) module that is used to forward a URL to another URL. This is a screenshot from the management UI: -![url-forward](url-forward.png) +![url-forward.png](/api/blogging/files/www/3104802a0898db35a15c3a0166002a3f.png) This feature can be used to create short URLs in your application (like URL shortening services providers) or forward old pages to their new URLs. @@ -125,7 +123,7 @@ In addition to the new features shipped in every minor version, we are working o ### ABP Community Talks 2021.1 -![abp-community-talks-2022-1](abp-community-talks-2022-1.png) +![abp-community-talks-2022-1.png](/api/blogging/files/www/79374b567169e34b283f3a016603708f.png) This is the second episode of the ABP Community Talks and we are talking about microservice development with the ABP Framework, based on the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) reference solution. We will also briefly talk about the changes that come with ABP version 5.1. This **live meeting** will be on **January 20, 2022, 17:00 (UTC)** on YouTube. @@ -146,4 +144,4 @@ Thanks to the ABP Community for all the contents they have published. You can al ## Conclusion -In this blog post, I summarized the news about the new version and the ABP Community. Please try it and provide feedback by opening issues on the [GitHub repository](https://github.com/abpframework/abp). Thank you all! +In this blog post, I summarized the news about the new version and the ABP Community. Please try it and provide feedback by opening issues on the [GitHub repository](https://github.com/abpframework/abp). Thank you all! \ No newline at end of file From 37ca1ed382da1a9ebb76b62d068a2934aa486326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 14 Jan 2022 08:47:36 +0300 Subject: [PATCH 04/11] Delete POST-on-blog.md --- .../POST-on-blog.md | 147 ------------------ 1 file changed, 147 deletions(-) delete mode 100644 docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md diff --git a/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md b/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md deleted file mode 100644 index 4105cfdf18..0000000000 --- a/docs/en/Blog-Posts/2022-01-11 v5_1_Release_Stable/POST-on-blog.md +++ /dev/null @@ -1,147 +0,0 @@ -Today, we are releasing the [ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) version 5.1 (with a version number `5.1.1`). This blog post introduces the new features and important changes in this new version. - -> **Warning** -> -> For a long time we've been releasing RC (Release Candidate) versions a few weeks prior to every minor and major release. **This version has been released without a preview version.** This is because we've accidently released all the packages with a stable version number, without a `-rc.1` suffix and there is no clear way to unpublish all the NuGet and NPM packages. We're sorry about that. However, it doesn't mean that this release is buggy. We've already resolved the known problems. We will publish one or more patch releases if needed. You can follow [this milestone](https://github.com/abpframework/abp/milestone/64?closed=1) for the common problems or submit your own bug report. If you are worried about its stability, you can wait for the next patch release. - -## Get Started with 5.1 - -Follow the steps below to try the 5.1 version today: - -1) **Upgrade** the ABP CLI to the latest version using a command line terminal: - -````bash -dotnet tool update Volo.Abp.Cli -g -```` - -**or install** if you haven't installed it before: - -````bash -dotnet tool install Volo.Abp.Cli -g -```` - -2) Create a **new application**: - -````bash -abp new BookStore -```` - -Check out the [ABP CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all the available options. - -> You can also use the *Direct Download* tab on the [Get Started](https://abp.io/get-started) page. - -You can use any IDE that supports .NET 6.x development (e.g. [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/)). - -### Migration Notes & Breaking Changes - -This is a minor feature release, mostly with enhancements and improvements based on [version 5.0](https://blog.abp.io/abp/ABP-IO-Platform-5-0-Final-Has-Been-Released). There aren't any breaking changes except for the Angular UI upgrade. ABP 5.1 startup templates use **Angular 13**. - -### Angular UI - -**If you want to upgrade the ABP Framework but want to continue with Angular 12**, add the following section to the `package.json` file of the Angular project: - -````json -"resolutions": { - "ng-zorro-antd": "^12.1.1", - "@ng-bootstrap/ng-bootstrap": "11.0.0-beta.2" - } -```` - -## What's New with the ABP Framework 5.1? - -In this section, I will introduce some major features released with this version. - -### The New Hosting Model - -The ABP startup application template now uses the new ASP.NET Core hosting APIs ([check out the Microsoft's minimal APIs document](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0)) on application startup ([check out the exact place in the ABP startup template](https://github.com/abpframework/abp/blob/46cdfbe7b06c93690181633be4e96bf62e7f34e2/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs#L33-L40)). So, the `Startup.cs` file has been removed. - -Old-style hosting logic will continue to work as long as ASP.NET Core supports it. It is recommended to switch to the new model if it's possible for your solution. Check out [this guide](https://docs.abp.io/en/abp/latest/Migration-Guides/Upgrading-Startup-Template) if you need to know how to do that. - -### Asynchronous Startup Lifecycle Methods - -The new hosting model allows us to execute asynchronous code on application initialization in the [ABP module](https://docs.abp.io/en/abp/latest/Module-Development-Basics) classes. If you are using the new hosting model (which is default with 5.1 startup templates), you can override the `Async` versions of the module lifecycle methods. - -For example, you can now override the `ConfigureServicesAsync` (instead of `ConfigureServices`) or `OnApplicationInitializationAsync` (instead of `OnApplicationInitialization`) as shown in the following code block: - -````csharp -public class MyModule : AbpModule -{ - public override async Task ConfigureServicesAsync(ServiceConfigurationContext context) - { - /* You can use await here and safely execute other async methods */ - } - - public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context) - { - /* You can use await here and safely execute other async methods */ - } -} -```` - -If you override both the asynchronous and synchronous versions of the same method, only the asynchronous one will be executed. So, override only one of them based on your needs. - -### eShopOnABP Is Getting More Stable - -Our team is working to finalize the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) example solution, which is a reference **microservice solution** built with the ABP Framework. They will explain the project status and show what's done in the next **ABP Community Talks** meeting (Check out the *ABP Community Talks 2021.1* section at the bottom of this post). - -### The New ABP.IO Design! - -We've been working on a new design for the [abp.io](https://abp.io/) websites for a while. We are adding the final touches; the new design will be live very soon. Here's a screenshot from the design work: - -![new-abp-io-design.png](/api/blogging/files/www/04c9be6a819f74d7d7003a0165ff0d88.png) - -The [ABP Commercial](https://commercial.abp.io/) and [ABP Community](https://community.abp.io/) websites will also have new designs as part of this update. - -### Other Changes - -Here are some other notable changes that come with this release: - -* Support markdown in [CMS-Kit comments ](https://docs.abp.io/en/abp/latest/Modules/Cms-Kit/Comments)feature ([#10792](https://github.com/abpframework/abp/pull/10792)) -* Used file scoped namespaces for all the ABP Framework source code :) ([#10552](https://github.com/abpframework/abp/pull/10696)) - -All issues & PRs in [5.1 milesone](https://github.com/abpframework/abp/milestone/60?closed=1). - -### About ABP Commercial - -The core team is also working on ABP Commercial (which provides pre-built modules, themes, tooling and support on top of the ABP Framework). We've done a lot of minor improvements and fixes to the modules and tooling. - -There's some exciting news about the **LeptonX theme**; We are working on making it available in the **MVC (Razor Pages)** and **Blazor** UI options too (in addition to Angular UI). We are also adding more components, layout options, demo pages, etc... We are planning to release a beta version in the next weeks. Here's an animated GIF from the dashboard we've prepared as a demonstration: - -![leptonx-dash-2.png](/api/blogging/files/www/1b50e6d6317b84f963ab3a016602cca7.png) - -If you are wondering what is the LeptonX project, please check out this [blog post](https://blog.abp.io/abp/LeptonX-Theme-for-ABP-Framework-Alpha-Release). - -As another visible functionality, we've added a new feature to the [CMS Kit Pro](https://docs.abp.io/en/commercial/latest/modules/cms-kit/index) module that is used to forward a URL to another URL. This is a screenshot from the management UI: - -![url-forward.png](/api/blogging/files/www/3104802a0898db35a15c3a0166002a3f.png) - -This feature can be used to create short URLs in your application (like URL shortening services providers) or forward old pages to their new URLs. - -In addition to the new features shipped in every minor version, we are working on long-term projects for ABP.IO Platform and ABP Commercial (a little secret for now :). We will have announcements once these projects get more stable. - -## Community News - -### ABP Community Talks 2021.1 - -![abp-community-talks-2022-1.png](/api/blogging/files/www/79374b567169e34b283f3a016603708f.png) - -This is the second episode of the ABP Community Talks and we are talking about microservice development with the ABP Framework, based on the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) reference solution. We will also briefly talk about the changes that come with ABP version 5.1. This **live meeting** will be on **January 20, 2022, 17:00 (UTC)** on YouTube. - -**Join this event on the Kommunity platform: https://kommunity.com/volosoft/events/abp-community-talks-20221-microservice-development-acd0f44b** - -You can also [subscribe to Volosoft YouTube channel](https://www.youtube.com/channel/UCO3XKlpvq8CA5MQNVS6b3dQ) for reminders of further ABP events and videos. - -### New ABP Community Posts - -Here are some of the recent posts added to the [ABP community](https://community.abp.io/): - -* [Minimal API development with the ABP Framework](https://community.abp.io/articles/minimal-api-with-abp-hello-world-part-1-sg5i44p8) by [@antosubash](https://github.com/antosubash) (three parts, video tutorial). -* [Integrating the Syncfusion MVC Components to the ABP MVC UI](https://community.abp.io/articles/integrating-the-syncfusion-mvc-components-to-the-abp-mvc-ui-0gpkr1if) by [@EngincanV](https://github.com/EngincanV). -* [Add Tailwind CSS to your ABP Blazor UI](https://community.abp.io/articles/add-tailwindcss-to-your-abp-blazor-ui-vidiwzcy) by [@antosubash](https://github.com/antosubash) (video tutorial). -* [Import external users into the users Table from an ABP Framework application](https://community.abp.io/articles/import-external-users-into-the-users-table-from-an-abp-framework-application-7lnyw415) by [@bartvanhoey](https://github.com/bartvanhoey). - -Thanks to the ABP Community for all the contents they have published. You can also [post your ABP and .NET related (text or video) contents](https://community.abp.io/articles/submit) to the ABP Community. - -## Conclusion - -In this blog post, I summarized the news about the new version and the ABP Community. Please try it and provide feedback by opening issues on the [GitHub repository](https://github.com/abpframework/abp). Thank you all! \ No newline at end of file From 40ca476ea0a1956357aae55a8408df8ffdcc8215 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 14 Jan 2022 10:44:18 +0300 Subject: [PATCH 05/11] Cli: Fix blazor namespaces --- .../Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs index babfabdc56..a3637266bc 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs @@ -704,13 +704,13 @@ public class SolutionModuleAdder : ITransientDependency new NugetPackageInfo { Name = $"{module.Name}.Blazor.WebAssembly", - ModuleClass = $"{module.Name}.Blazor.{moduleProjectName}BlazorWebAssemblyModule", + ModuleClass = $"{module.Name}.Blazor.WebAssembly.{moduleProjectName}BlazorWebAssemblyModule", Target = NuGetPackageTarget.BlazorWebAssembly }, new NugetPackageInfo { Name = $"{module.Name}.Blazor.Server", - ModuleClass = $"{module.Name}.Blazor.{moduleProjectName}BlazorServerModule", + ModuleClass = $"{module.Name}.Blazor.Server.{moduleProjectName}BlazorServerModule", Target = NuGetPackageTarget.BlazorServer }, new NugetPackageInfo From 6ec11e1eb5861bdcf1487b81205c30d03c73ec96 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 14 Jan 2022 10:44:37 +0300 Subject: [PATCH 06/11] Cli: Class parsing should support File-Scoped Namespaces --- .../Abp/Cli/ProjectModification/DerivedClassFinder.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DerivedClassFinder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DerivedClassFinder.cs index 52a2fb93b1..5462f3e9fb 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DerivedClassFinder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/DerivedClassFinder.cs @@ -54,8 +54,14 @@ public class DerivedClassFinder : ITransientDependency protected bool IsDerived(string csFile, string baseClass) { var root = CSharpSyntaxTree.ParseText(File.ReadAllText(csFile)).GetRoot(); - var namespaceSyntax = root.DescendantNodes().OfType().First(); - var classDeclaration = (namespaceSyntax.DescendantNodes().OfType()).First(); + var namespaceSyntax = root.DescendantNodes().OfType().FirstOrDefault(); + var classDeclaration = (namespaceSyntax?.DescendantNodes().OfType())?.FirstOrDefault(); + + if (classDeclaration == null) + { + classDeclaration = root.DescendantNodes().OfType().First(); + } + var baseTypeList = classDeclaration.BaseList?.Types.Select(t => t.ToString()).ToList(); if (baseTypeList == null) From 780f6af370e22cf30b0077c4172fb52666603863 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 14 Jan 2022 10:45:05 +0300 Subject: [PATCH 07/11] Cli: upgrade roslyn version --- framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj index 5ec6217ca2..2b2f815b7c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj +++ b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj @@ -19,7 +19,7 @@ - + From d049720c1cf6b72d869f13f83903347c1bd517cc Mon Sep 17 00:00:00 2001 From: Luke Ni Date: Mon, 17 Jan 2022 09:39:07 +0800 Subject: [PATCH 08/11] translate to zh-Hans --- docs/en/Entity-Framework-Core.md | 9 +- docs/zh-Hans/Entity-Framework-Core.md | 280 +++++++++++++++++++++----- 2 files changed, 235 insertions(+), 54 deletions(-) diff --git a/docs/en/Entity-Framework-Core.md b/docs/en/Entity-Framework-Core.md index 989123c060..ab6d3b6adb 100644 --- a/docs/en/Entity-Framework-Core.md +++ b/docs/en/Entity-Framework-Core.md @@ -425,10 +425,10 @@ namespace AbpDemo.Orders { //Get a IQueryable by including sub collections var queryable = await _orderRepository.WithDetailsAsync(x => x.Lines); - + //Apply additional LINQ extension methods var query = queryable.Where(x => x.Id == id); - + //Execute the query and get the result var order = await AsyncExecuter.FirstOrDefaultAsync(query); } @@ -576,7 +576,7 @@ Configure(options => { opts.DbContextOptions.UseLazyLoadingProxies(); //Enable lazy loading }); - + options.UseSqlServer(); }); ```` @@ -874,7 +874,7 @@ Configure(options => ### Customize Bulk Operations -If you have better logic or using an external library for bulk operations, you can override the logic via implementing`IEfCoreBulkOperationProvider`. +If you have better logic or using an external library for bulk operations, you can override the logic via implementing `IEfCoreBulkOperationProvider`. - You may use example template below: @@ -920,4 +920,3 @@ public class MyCustomEfCoreBulkOperationProvider ## See Also * [Entities](Entities.md) -* [Repositories](Repositories.md) diff --git a/docs/zh-Hans/Entity-Framework-Core.md b/docs/zh-Hans/Entity-Framework-Core.md index 78df73150c..fe5e779d3c 100644 --- a/docs/zh-Hans/Entity-Framework-Core.md +++ b/docs/zh-Hans/Entity-Framework-Core.md @@ -30,9 +30,7 @@ namespace MyCompany.MyProject ### 数据库管理系统选择 -EF Core支持多种数据库管理系统([查看全部](https://docs.microsoft.com/zh-cn/ef/core/providers/)). ABP框架和本文档不依赖于任何特定的DBMS. - -如果要创建一个可重用的[应用程序模块](Modules/Index.md),应避免依赖于特定的DBMS包.但在最终的应用程序中,始终会选择一个DBMS. +EF Core支持多种数据库管理系统([查看全部](https://docs.microsoft.com/zh-cn/ef/core/providers/)). ABP框架和本文档不依赖于任何特定的DBMS. 如果要创建一个可重用的[应用程序模块](Modules/Index.md),应避免依赖于特定的DBMS包.但在最终的应用程序中,始终会选择一个DBMS. 参阅[为Entity Framework Core切换到其他DBMS](Entity-Framework-Core-Other-DBMS.md)文档学习如何切换DBMS. @@ -107,8 +105,7 @@ protected override void OnModelCreating(ModelBuilder builder) ### 配置连接字符串选择 -如果你的应用程序有多个数据库,你可以使用 `connectionStringName]` Attribute为你的DbContext配置连接字符串名称. -例: +如果你的应用程序有多个数据库,你可以使用 `connectionStringName]` Attribute为你的DbContext配置连接字符串名称.例: ```csharp [ConnectionStringName("MySecondConnString")] @@ -120,6 +117,62 @@ public class MyDbContext : AbpDbContext 如果不进行配置,则使用`Default`连接字符串. 如果你配置特定的连接字符串的名称,但在应用程序配置中没有定义这个连接字符串名称,那么它会回退到`Default`连接字符串(参阅[连接字符串文档](Connection-Strings.md)了解更多信息). +### AbpDbContextOptions + +`AbpDbContextOptions` 用于配置 `DbContext`. 当你使用ABP的应用程序启动模板新建解决方案时, 你会看到一个简单的配置 (在 `EntityFrameworkCore` 集成项目模块类) 如下: + +````csharp +Configure(options => +{ + options.UseSqlServer(); +}); +```` + +上面的配置为应用程序的所有 `DbContext`使用SQL Server作为默认DBMS. 上面的配置是简化的写法, 它也可以使用下面的方法进行配置: + +````csharp +Configure(options => +{ + options.Configure(opts => + { + opts.UseSqlServer(); + }); +}); +```` + +`options.Configure(...)` 方法有更多的选项进行配置. 例如, 你可以设置 `DbContextOptions` (EF Core自有的配置): + +````csharp +Configure(options => +{ + options.Configure(opts => + { + opts.DbContextOptions.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); + }); +}); +```` + +如果你有唯一的 `DbContext` 或者有多个 `DbContext`, 但是希望对所有的 `DbContext` 使用相同的DBMS, 你无需更多的配置. 但是, 如果你需要为某个特定的 `DbContext` 配置不同的DBMS或对配置进行定制, 你可以进行如下定制: + +````csharp +Configure(options => +{ + // Default configuration for all DbContexts + options.Configure(opts => + { + opts.UseSqlServer(); + }); + + // Customized configuration for a specific DbContext + options.Configure(opts => + { + opts.UseMySQL(); + }); +}); +```` + +> 参阅 [为Entity Framework Core切换DBMS](Entity-Framework-Core-Other-DBMS.md) 文档学习如何配置DBMS. + ## 将DbContext注册到依赖注入 在module中的ConfigureServices方法使用 `AddAbpDbContext` 在[依赖注入](Dependency-Injection.md)系统注册DbContext类. @@ -155,8 +208,7 @@ services.AddAbpDbContext(options => }); ```` -默认情况下为每个[聚合根实体](Entities.md)(`AggregateRoot`派生的子类)创建一个仓储. 如果想要为其他实体也创建仓储 -请将`includeAllEntities` 设置为 `true`: +默认情况下为每个[聚合根实体](Entities.md)(`AggregateRoot`派生的子类)创建一个仓储. 如果想要为其他实体也创建仓储, 请将`includeAllEntities` 设置为 `true`: ````C# services.AddAbpDbContext(options => @@ -165,9 +217,7 @@ services.AddAbpDbContext(options => }); ```` -然后你就可以在服务中注入和使用 `IRepository` 或 `IQueryableRepository`. - -假如你有一个主键是Guid名为Book实体(聚合根) +然后你就可以在服务中注入和使用 `IRepository` 或 `IQueryableRepository`. 假如你有一个主键是Guid名为Book实体(聚合根) ```csharp public class Book : AggregateRoot @@ -185,7 +235,8 @@ public class BookManager : DomainService { private readonly IRepository _bookRepository; - public BookManager(IRepository bookRepository) //注入默认仓储 + //inject default repository to the constructor + public BookManager(IRepository bookRepository) { _bookRepository = bookRepository; } @@ -201,7 +252,8 @@ public class BookManager : DomainService Type = type }; - await _bookRepository.InsertAsync(book); //使用仓储提供的标准方法 + //Use a standard repository method + await _bookRepository.InsertAsync(book); return book; } @@ -212,9 +264,9 @@ public class BookManager : DomainService #### 添加自定义仓储 -默认通用仓储可以满足大多数情况下的需求(它实现了`IQueryable`),但是你可能会需要自定义仓储与仓储方法. +默认通用仓储可以满足大多数情况下的需求(它实现了`IQueryable`),但是你可能会需要自定义仓储与仓储方法. 假设你需要根据图书类型删除所有的书籍. -假设你需要根据图书类型删除所有的书籍. 建议为自定义仓储定义一个接口: +建议为自定义仓储定义一个接口: ````csharp public interface IBookRepository : IRepository @@ -228,7 +280,8 @@ public interface IBookRepository : IRepository IBookRepository接口的实现示例: ````csharp -public class BookRepository : EfCoreRepository, IBookRepository +public class BookRepository + : EfCoreRepository, IBookRepository { public BookRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) @@ -237,7 +290,8 @@ public class BookRepository : EfCoreRepository, public async Task DeleteBooksByType(BookType type) { - await DbContext.Database.ExecuteSqlRawAsync( + var dbContext = await GetDbContextAsync(); + await dbContext.Database.ExecuteSqlRawAsync( $"DELETE FROM Books WHERE Type = {(int)type}" ); } @@ -256,11 +310,13 @@ public class BookRepository : EfCoreRepository, context.Services.AddAbpDbContext(options => { options.AddDefaultRepositories(); + + //Replaces IRepository options.AddRepository(); }); ```` -在你想要覆盖默认仓储方法对其自定义时,这一点非常需要. 例如你可能希望自定义`DeleteAsync`方法覆盖默认实现 +在你想要覆盖默认仓储方法对其自定义时,这一点非常需要. 例如你可能希望自定义`DeleteAsync`方法覆盖默认实现, 以使用更有效的方式删除特定的实体. ````csharp public async override Task DeleteAsync( @@ -369,10 +425,10 @@ namespace AbpDemo.Orders { //通过包含子集合获取一个 IQueryable var queryable = await _orderRepository.WithDetailsAsync(x => x.Lines); - + //应用其他的 LINQ 扩展方法 var query = queryable.Where(x => x.Id == id); - + //执行此查询并获取结果 var order = await AsyncExecuter.FirstOrDefaultAsync(query); } @@ -380,7 +436,7 @@ namespace AbpDemo.Orders } ```` -> `AsyncExecuter` 用于执行异步 LINQ 扩展,而无需依赖 EF Core. 如果你将 EF Core NuGet 包引用添加到你的项目中,则可以直接使用 `await query.FirstOrDefaultAsync()`. 但是, 这次你依赖于域层中的 EF 核心.请参阅. 请参阅 [仓储文档](Repositories.md) 以了解更多. +> `AsyncExecuter` 用于执行异步 LINQ 扩展,而无需依赖 EF Core. 如果你将 EF Core NuGet 包引用添加到你的项目中,则可以直接使用 `await query.FirstOrDefaultAsync()`. 但是, 这次你依赖于域层中的 EF Core. 请参阅 [仓储文档](Repositories.md) 以了解更多. **示例: 获取一个包含 `lines` 的 `orders` 列表** @@ -401,7 +457,7 @@ public async Task TestWithDetails() 如果你没有将任何表达式传递到 `WithDetailsAsync` 方法,则它包括使用你提供的 `DefaultWithDetailsFunc` 选项的所有详细信息. -你可以在你的 `EntityFrameworkCore` 项目[模块](Module-Development-Basics.md)的 `ConfigureServices`方法为一个实体配置 `DefaultWithDetailsFunc`. +你可以在你的 `EntityFrameworkCore` 项目[模块](Module-Development-Basics.md)的 `ConfigureServices` 方法为一个实体配置 `DefaultWithDetailsFunc`. **示例: 在查询一个 `Order` 时包含 `Lines`** @@ -470,7 +526,7 @@ public async Task TestWithDetails() } ```` -#### 选择 +#### 更多的替代选择 存储库模式尝试封装 EF Core, 因此你的选项是有限的. 如果你需要高级方案,你可以按照其中一个选项执行: @@ -479,7 +535,7 @@ public async Task TestWithDetails() 请参阅 EF Core 的 [预先加载文档](https://docs.microsoft.com/zh-cn/ef/core/querying/related-data/eager). -### 显示 / 延迟加载 +### 显式 / 延迟加载 如果你在查询实体时不包括关系,并且以后需要访问导航属性或集合,则你有不同的选择. @@ -506,7 +562,7 @@ public async Task TestWithDetails(Guid id) #### 使用代理的延时加载 -在某些情况下,可能无法使用显示加载,尤其是当你没有引用 `Repository` 或 `DbContext`时.延时加载是 EF Core 加载关联属性/集合的一个功能,,当你第一次访问它. +在某些情况下,可能无法使用显式加载,尤其是当你没有引用 `Repository` 或 `DbContext`时.延时加载是 EF Core 加载关联属性/集合的一个功能, 当你第一次访问它. 启用延时加载: @@ -520,7 +576,7 @@ Configure(options => { opts.DbContextOptions.UseLazyLoadingProxies(); //启用延时加载 }); - + options.UseSqlServer(); }); ```` @@ -553,35 +609,26 @@ public async Task TestWithDetails(Guid id) ## 访问 EF Core API -大多数情况下应该隐藏仓储后面的EF Core API(这也是仓储的设计目地). 但是如果想要通过仓储访问DbContext实现,则可以使用`GetDbContext()`或`GetDbSet()`扩展方法. 例: +大多数情况下应该隐藏仓储后面的EF Core API(这也是仓储的设计目的). 但是如果想要通过仓储访问DbContext实现,则可以使用`GetDbContext()`或`GetDbSet()`扩展方法. 例如: ````csharp -public class BookService +public async Task TestAsync() { - private readonly IRepository _bookRepository; - - public BookService(IRepository bookRepository) - { - _bookRepository = bookRepository; - } - - public void Foo() - { - DbContext dbContext = _bookRepository.GetDbContext(); - DbSet books = _bookRepository.GetDbSet(); - } + var dbContext = await _orderRepository.GetDbContextAsync(); + var dbSet = await _orderRepository.GetDbSetAsync(); + //var dbSet = dbContext.Set(); //Alternative, when you have the DbContext } ```` -* `GetDbContext` 返回 `DbContext` 引用,而不是 `BookStoreDbContext`. 你可以释放它, 但大多数情况下你不会需要它. +* `GetDbContext` 返回 `DbContext` 引用,而不是 `BookStoreDbContext`. 你可以强制转化它, 但大多数情况下你不会需要它. > 要点: 你必须在使用`DbContext`的项目里引用`Volo.Abp.EntityFrameworkCore`包. 这会破坏封装,但在这种情况下,这就是你需要的. -## Extra Properties & Object Extension Manager +## 额外属性 & Object Extension Manager 额外属性系统允许你为实现了 `IHasExtraProperties` 的实体set/get动态属性. 当你想将自定义属性添加到[应用程序模块](Modules/Index.md)中定义的实体时,它特别有用. -默认,实体的所有额外属性存储在数据库的一个 `JSON` 对象中. +默认情况下, 实体的所有额外属性存储在数据库的一个 `JSON` 对象中. 实体扩展系统允许你存储额外属性在数据库的单独字段中. 有关额外属性和实体扩展系统的更多信息,请参阅下列文档: @@ -611,28 +658,100 @@ ObjectExtensionManager.Instance ); ```` +### MapEfCoreEntity + +`MapEfCoreEntity` 一个配置 `Entity` 的快捷扩展方法. + +**示例**: 设置 `IdentityRole` 实体的 `Name` 的最大长度: + +````csharp +ObjectExtensionManager.Instance + .MapEfCoreEntity(builder => + { + builder.As>().Property(x => x.Name).HasMaxLength(200); + }); +```` + +### MapEfCoreDbContext + +`MapEfCoreDbContext` 一个配置 `DbContext` 的快捷扩展方法. + +**示例**: 设置 `IdentityDbContext` 的 `IdentityRole` 实体的 `IdentityRole` 的最大长度: + +````csharp +ObjectExtensionManager.Instance.MapEfCoreDbContext(b => +{ + b.Entity().Property(x => x.Name).HasMaxLength(200); +}); +```` + 如果相关模块已实现此功能(通过使用下面说明的 `ConfigureEfCoreEntity`)则将新属性添加到模型中. 然后你需要运行标准的 `Add-Migration` 和 `Update-Database` 命令更新数据库以添加新字段. ->`MapEfCoreProperty` 方法必须在使用相关的 `DbContext` 之前调用,它是一个静态方法. 最好的方法是尽早的应用程序中使用它. 应用程序启动模板含有 `YourProjectNameEntityExtensions` 类,可以在放心的在此类中使用此方法. +>`MapEfCoreProperty`, `MapEfCoreEntity` and `MapEfCoreDbContext` 方法必须在使用相关的 `DbContext` 之前调用,它是一个静态方法. 最好的方法是尽早的应用程序中使用它. 应用程序启动模板含有 `YourProjectNameEfCoreEntityExtensionMappings` 类,可以在放心的在此类中使用此方法. -### ConfigureEfCoreEntity +### ConfigureEfCoreEntity, ApplyObjectExtensionMappings 和 TryConfigureObjectExtensions 如果你正在开发一个可重用使用的模块,并允许应用程序开发人员将属性添加到你的实体,你可以在实体映射使用 `ConfigureEfCoreEntity` 扩展方法,但是在配置实体映射时可以使用快捷的扩展方法 `ConfigureObjectExtensions`: +**示例**: ````csharp -builder.Entity(b => +public static class QADbContextModelCreatingExtensions { - b.ConfigureObjectExtensions(); - //... -}); + public static void ConfigureQA( + this ModelBuilder builder, + Action optionsAction = null) + { + Check.NotNull(builder, nameof(builder)); + + var options = new QAModelBuilderConfigurationOptions( + QADatabaseDbProperties.DbTablePrefix, + QADatabaseDbProperties.DbSchema + ); + + optionsAction?.Invoke(options); + + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Questions", options.Schema); + b.ConfigureByConvention(); + //... + + //Call this in the end of buildAction. + b.ApplyObjectExtensionMappings(); + }); + + //... + + //Call this in the end of ConfigureQA. + builder.TryConfigureObjectExtensions(); + } +} ```` -如果你调用 `ConfigureByConvention()` 扩展方法(在此示例中 `b.ConfigureByConvention`),ABP框架内部会调用 `ConfigureObjectExtensions` 方法. 使用 `ConfigureByConvention` 方法是**最佳实践**,因为它还按照约定配置基本属性的数据库映射. +如果你调用 `ConfigureByConvention()` 扩展方法(在此示例中 `b.ConfigureByConvention`),ABP框架内部会调用 `ConfigureObjectExtensions` 和 `ConfigureEfCoreEntity` 方法. 使用 `ConfigureByConvention` 方法是**最佳实践**,因为它还按照约定配置基本属性的数据库映射. 参阅上面提到的 "*ConfigureByConvention 方法*" 了解更多信息. ## 高级主题 +### 控制多租户 + +如果你的方案是基于 [多租户](Multi-Tenancy.md)的, 租户可以拥有 **独立数据库**, 你在解决方案中可以拥有 **多个** `DbContext` 类, 并且其中的一些 `DbContext` 类 **只能在主机端** 可用, 这种情况下建议在 `DbContext` 类上添加 `[IgnoreMultiTenancy]` 属性. ABP 保证相关的 `DbContext` 始终使用主机 [连接字符串](Connection-Strings.md), 即使你在租户上下文中. + +**示例:** + +````csharp +[IgnoreMultiTenancy] +public class MyDbContext : AbpDbContext +{ + ... +} +```` + +不要使用 `[IgnoreMultiTenancy]` 特性如果 `DbContext` 中任何一个实体可以被持久化到多租户数据库中. + +> 当你使用repositories时, ABP 已经为未实现`IMultiTenant`接口的实体使用了主机数据库. 所以, 如果你使用repositories访问数据库, 多数时候你不需要 `[IgnoreMultiTenancy]` 特性. + ### 设置默认仓储类 默认的通用仓储的默认实现是`EfCoreRepository`类,你可以创建自己的实现,并将其做为默认实现 @@ -674,6 +793,7 @@ context.Services.AddAbpDbContext(options => typeof(MyRepositoryBase<,>), typeof(MyRepositoryBase<>) ); + //... }); ``` @@ -736,6 +856,68 @@ context.Services.AddAbpDbContext(options => 在这个例子中,`OtherDbContext`实现了`IBookStoreDbContext`. 此功能允许你在开发时使用多个DbContext(每个模块一个),但在运行时可以使用单个DbContext(实现所有DbContext的所有接口). +### 拆分查询 + +ABP 为了更好的性能, 默认全局启用 [拆分查询](https://docs.microsoft.com/en-us/ef/core/querying/single-split-queries). 你可以按需修改. + +**示例** + +````csharp +Configure(options => +{ + options.UseSqlServer(optionsBuilder => + { + optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery); + }); +}); +```` + +### 自定义批量操作 + +如果你有更好的逻辑或使用外部库实现批量操作, 你可以通过实现 `IEfCoreBulkOperationProvider` 覆写这个逻辑. + +- 你可以使用下面的示例模板: + +```csharp +public class MyCustomEfCoreBulkOperationProvider + : IEfCoreBulkOperationProvider, ITransientDependency +{ + public async Task DeleteManyAsync( + IEfCoreRepository repository, + IEnumerable entities, + bool autoSave, + CancellationToken cancellationToken) + where TDbContext : IEfCoreDbContext + where TEntity : class, IEntity + { + // Your logic here. + } + + public async Task InsertManyAsync( + IEfCoreRepository repository, + IEnumerable entities, + bool autoSave, + CancellationToken cancellationToken) + where TDbContext : IEfCoreDbContext + where TEntity : class, IEntity + { + // Your logic here. + } + + public async Task UpdateManyAsync( + IEfCoreRepository repository, + IEnumerable entities, + bool autoSave, + CancellationToken cancellationToken) + where TDbContext : IEfCoreDbContext + where TEntity : class, IEntity + { + // Your logic here. + } +} +``` + ## 另请参阅 * [实体](Entities.md) +* [仓储](Repositories.md) From d84df93147a2df06b95a18e744fd1b1d784b79ed Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 17 Jan 2022 09:45:04 +0800 Subject: [PATCH 09/11] Update Entity-Framework-Core.md --- docs/zh-Hans/Entity-Framework-Core.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh-Hans/Entity-Framework-Core.md b/docs/zh-Hans/Entity-Framework-Core.md index fe5e779d3c..036998bc73 100644 --- a/docs/zh-Hans/Entity-Framework-Core.md +++ b/docs/zh-Hans/Entity-Framework-Core.md @@ -105,7 +105,7 @@ protected override void OnModelCreating(ModelBuilder builder) ### 配置连接字符串选择 -如果你的应用程序有多个数据库,你可以使用 `connectionStringName]` Attribute为你的DbContext配置连接字符串名称.例: +如果你的应用程序有多个数据库,你可以使用 `[connectionStringName]` Attribute为你的DbContext配置连接字符串名称.例: ```csharp [ConnectionStringName("MySecondConnString")] From d012bf553d6ab3f8d74b1635ac912426b8bde18d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 17 Jan 2022 11:07:54 +0800 Subject: [PATCH 10/11] Enhanced EntityAction --- .../EntityActions/EntityAction.cs | 1 + .../Components/AbpExtensibleDataGrid.razor | 24 ++++++++++--------- .../Components/EntityAction.razor | 7 +++--- .../Components/EntityAction.razor.cs | 5 +++- .../Components/EntityActions.razor | 7 +++--- .../Components/EntityActions.razor.cs | 5 +++- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs index 2f800c7257..837eb2c96a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs @@ -12,6 +12,7 @@ public class EntityAction : IEquatable public object Color { get; set; } public string Icon { get; set; } public Func Visible { get; set; } + public bool Disabled { get; set; } public bool Equals(EntityAction other) { return string.Equals(Text, other?.Text, StringComparison.OrdinalIgnoreCase); diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor index 459e47f442..39a86456b8 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor @@ -44,7 +44,8 @@ Clicked="async () => await action.Clicked(context)" ConfirmationMessage="() => action.ConfirmationMessage.Invoke(context)" Visible="@(action.Visible != null ? action.Visible(context) : true)" - Text="@action.Text"> + Text="@action.Text" + Disabled="@action.Disabled"> } else @@ -54,7 +55,8 @@ Color="@(action.Color != null ? (Blazorise.Color) action.Color : Blazorise.Color.None)" Icon="@action.Icon" Visible="@(action.Visible != null ? action.Visible(context) : true)" - Text="@action.Text"> + Text="@action.Text" + Disabled="@action.Disabled"> } } @@ -78,18 +80,18 @@ { @if (column.ValueConverter == null) { - } else { - @(GetConvertedFieldValue(context, column)) @@ -143,4 +145,4 @@ } } - \ No newline at end of file + diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor index 8e4544e09c..63b0f26df0 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor @@ -6,14 +6,15 @@ { if (Primary == false) { - @Text + @Text } } else { } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs index 627c4bcdda..a38d915ff1 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs @@ -12,6 +12,9 @@ public partial class EntityAction : ComponentBase [Parameter] public bool Visible { get; set; } = true; + [Parameter] + public bool Disabled { get; set; } = false; + internal bool HasPermission { get; set; } = true; [Parameter] @@ -45,7 +48,7 @@ public partial class EntityAction : ComponentBase [Inject] protected IUiMessageService UiMessageService { get; set; } - protected override async Task OnInitializedAsync() + protected async override Task OnInitializedAsync() { await base.OnInitializedAsync(); await SetDefaultValuesAsync(); diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor index 7a2fd20145..b362358d70 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor @@ -2,12 +2,13 @@ @if ( Type == ActionType.Dropdown ) { - + @if ( HasPrimaryAction ) { @@ -27,4 +28,4 @@ { @ChildContent } - \ No newline at end of file + diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs index e6a7ff9c83..4ba27bf2f7 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs @@ -29,6 +29,9 @@ public partial class EntityActions : ComponentBase [Parameter] public ActionType Type { get; set; } = ActionType.Dropdown; + [Parameter] + public bool Disabled { get; set; } = false; + [CascadingParameter] public DataGridEntityActionsColumn ParentEntityActionsColumn { get; set; } @@ -46,7 +49,7 @@ public partial class EntityActions : ComponentBase ToggleText = UiLocalizer["Actions"]; } - protected override async Task OnAfterRenderAsync(bool firstRender) + protected async override Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { From 0df409d2279869dd942f2698c4e0085711f0b684 Mon Sep 17 00:00:00 2001 From: Luke Ni Date: Mon, 17 Jan 2022 11:23:48 +0800 Subject: [PATCH 11/11] revert unintended deletion --- docs/en/Entity-Framework-Core.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/Entity-Framework-Core.md b/docs/en/Entity-Framework-Core.md index ab6d3b6adb..568623a15d 100644 --- a/docs/en/Entity-Framework-Core.md +++ b/docs/en/Entity-Framework-Core.md @@ -920,3 +920,4 @@ public class MyCustomEfCoreBulkOperationProvider ## See Also * [Entities](Entities.md) +* [Repositories](Repositories.md)