diff --git a/.github/ISSUE_TEMPLATE/02_feature_request.yml b/.github/ISSUE_TEMPLATE/02_feature_request.yml
index 21189e3a30..029830c7c5 100644
--- a/.github/ISSUE_TEMPLATE/02_feature_request.yml
+++ b/.github/ISSUE_TEMPLATE/02_feature_request.yml
@@ -1,6 +1,6 @@
name: 💡 Feature request
description: Suggest an idea for this project
-labels: [feature]
+labels: [feature-request]
body:
- type: checkboxes
attributes:
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000000..43e9cba5de
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,14 @@
+# Security Policy
+
+## Supported Versions
+
+| Version | Supported |
+| ------- | ------------------ |
+| 7.x.x | :white_check_mark: |
+| < 7.0.0 | :x: |
+
+## Reporting a Vulnerability
+
+Please don not share vulnerabilities publicly in GitHub or other platforms.
+You can report security issues by sending a email to `security@abp.io`
+Your report is immediately evaluated. We publish patch versions for critical vulnerabilities in a week at most.
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/ar.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/ar.json
index 4a7e64125f..d3537d3742 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/ar.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/ar.json
@@ -167,7 +167,7 @@
"ABPDiscordServer": "ABP سيرفر الدسكورد",
"ABPCommunityTalks": "برامج منتدى ABP الحوارية",
"ABPCommunityPosts": "منشورات منتدى ABP",
- "BuyAndGetMonths": "شراء 12 شهر، احصل على 14 شهرا!",
+ "BuyAndGetMonths": "شراء 12 شهر، احصل على 14 شهرا!",
"GetYourDeal": "احصل على صفقتك",
"BuyOrRenewLicense": "اشترِ أو جدد الرخصة الآن واحصل على شهرين إضافيين!",
"BuyOrRenewLicenseToGetExtra2Months": "اشترِ أو جدد الرخصة الآن واحصل على شهرين إضافيين! اسرع! ⏰ آخر يوم: {0}",
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json
index 9ef432a8bd..63f78103d9 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json
@@ -171,7 +171,7 @@
"ABPDiscordServer": "ABP Discord Server",
"ABPCommunityTalks": "ABP Community Talks",
"ABPCommunityPosts": "ABP Community Posts",
- "BuyAndGetMonths": "BUY 12 MONTHS, GET 14 MONTHS!",
+ "BuyAndGetMonths": "BUY 12 MONTHS, GET 14 MONTHS!",
"GetYourDeal": "Get Your Deal",
"BuyOrRenewLicense": "Buy or Renew License Now and Get 2 Extra Months!",
"BuyOrRenewLicenseToGetExtra2Months": "Buy or Renew License Now and Get 2 Extra Months! HURRY UP! ⏰ Last Day: {0}",
@@ -187,7 +187,7 @@
"GiveAwayForNewPurchases": "Application Development Classroom Training will be given away for the new purchases!",
"BlackFriday": "BLACKFRIDAY",
"ValidForExistingCustomers": "Also valid for the existing customers!",
- "CampaignBetweenDates": "From {0} to {1}",
+ "CampaignBetweenDates": "From {0} To {1}",
"SaveUpTo": "SAVE UP TO${0}K",
"ImplementingDDD": "Implementing Domain Driven Design",
"ExploreTheEBook": "Explore the E-Book",
@@ -220,6 +220,7 @@
"NoContent": "No content",
"More": "More",
"WhyABPIOPlatform": "Why ABP.IO Platform?",
- "AbpStudio": "ABP Studio"
+ "AbpStudio": "ABP Studio",
+ "ExtraMonths": "{0}EXTRA MONTHS"
}
}
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/fi.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/fi.json
index 16437480ef..80f351043f 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/fi.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/fi.json
@@ -170,7 +170,7 @@
"ABPDiscordServer": "ABP Discord-palvelin",
"ABPCommunityTalks": "ABP Community Talks",
"ABPCommunityPosts": "ABP-yhteisön viestit",
- "BuyAndGetMonths": "OSTA 12 KUUKAUTA, SAAT 14 KUUKAUTA!",
+ "BuyAndGetMonths": "OSTA 12 KUUKAUTA, SAAT 14 KUUKAUTA!",
"GetYourDeal": "Hanki tarjouksesi",
"BuyOrRenewLicense": "Osta tai uusi lisenssi nyt ja saat 2 lisäkuukautta!",
"BuyOrRenewLicenseToGetExtra2Months": "Osta tai uusi lisenssi nyt ja saat 2 lisäkuukautta! KIIREHDI! ⏰ Viimeinen päivä: {0}",
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/hu.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/hu.json
index b9ccddecf4..d785f418aa 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/hu.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/hu.json
@@ -168,7 +168,7 @@
"ABPDiscordServer": "ABP Discord szerver",
"ABPCommunityTalks": "ABP közösségi beszélgetések",
"ABPCommunityPosts": "ABP közösségi bejegyzések",
- "BuyAndGetMonths": "VÁSÁROLJON 12 HÓNAPOT, 14 HÓNAPOT KAP!",
+ "BuyAndGetMonths": "VÁSÁROLJON 12 HÓNAPOT, 14 HÓNAPOT KAP!",
"GetYourDeal": "Szerezze meg az ajánlatát",
"BuyOrRenewLicense": "Vásároljon vagy újítson meg licencet most, és 2 további hónapot kap!",
"BuyOrRenewLicenseToGetExtra2Months": "Vásároljon vagy újítson meg licencet most, és 2 további hónapot kap! SIESS! ⏰ Utolsó nap: {0}",
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/zh-Hans.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/zh-Hans.json
index d1a0db7176..545a909abf 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/zh-Hans.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/zh-Hans.json
@@ -170,7 +170,7 @@
"ABPDiscordServer": "ABP Discord 服务器",
"ABPCommunityTalks": "ABP社区讲话",
"ABPCommunityPosts": "ABP社区文章",
- "BuyAndGetMonths": "购买 12 个月,获得 14 个月!",
+ "BuyAndGetMonths": "购买 12 个月,获得 14 个月!",
"GetYourDeal": "得到你的交易",
"BuyOrRenewLicense": "立即购买或续订许可证并额外获得 2 个月!",
"BuyOrRenewLicenseToGetExtra2Months": "立即购买或续订 ABP 商业许可证(适用于所有版本)并额外获得 2 个月!",
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
index 1b8c972d5c..d9794a06e4 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
@@ -567,7 +567,7 @@
"TotalPrice": "Total Price",
"ThereIsNoInvoice": "There is no invoice",
"MyOrganizations_Detail_PaymentProviderInfo": "If you have purchased your license through {0} gateway, it sends the PDF invoice to your email address, see {0} invoicing.",
- "MyOrganizations_Detail_PayUInfo": "If you have purchased through the PayU gateway, click the \"Request Invoice\" button and fill in the billing information.",
+ "MyOrganizations_Detail_PayUInfo": "If you have purchased through the Iyzico gateway, click the \"Request Invoice\" button and fill in the billing information.",
"MyOrganizations_Detail_ConclusionInfo": "Your invoice request will be concluded within {0} business days.",
"ExtendYourLicense": "Extend your {0} license",
"Continue": "Continue",
@@ -1001,19 +1001,19 @@
"ABPSOLUTION": "ABP SOLUTION",
"CreatingAnEmptySolution_ABPSOLUTION_Description": "ABP provides a well-architected, layered and production-ready startup solution based on the Domain Driven Design principles. The solution also includes a pre-configured unit and integration test projects for each layer.",
"CommonLibraries": "Common Libraries",
- "CommonLibraries_THEPROBLEM_Description": "Which libraries should you use to implement common requirements? The software development ecosystem is highly dynamic and it is hard to follow the latest tools, libraries, trends and approaches.",
- "CommonLibraries_ABPSOLUTION_Description": "ABP pre-integrates the popular, mature and up-to-date libraries into the solution. You don't spend time integrating them and talking to each other. They properly work out of the box.",
+ "CommonLibraries_THEPROBLEM_Description": "Which libraries should you use to implement common requirements? The software development ecosystem is highly dynamic, making it challenging to keep up with the latest tools, libraries, trends, and approaches.",
+ "CommonLibraries_ABPSOLUTION_Description": "ABP pre-integrates popular, mature, and up-to-date libraries into the solution. You don't need to spend time integrating them or making them communicate with each other. They work properly out of the box.",
"UITheme&Layout": "UI Theme & Layout",
- "UITheme&Layout_THEPROBLEM_Description": "When it comes to the UI, there are a lot of challenges, including preparing a foundation to create a responsive, modern and flexible UI kit with a consistent look & feel and tons of features (like left/top navigation menu, header, toolbar, footer, widgets and so.).",
- "UITheme&Layout_THEPROBLEM_Description2": "Even if you buy a pre-built theme, integrating it into your solution may take days of development. Upgrading such a theme is another problem. Most of the time, the theme's HTML/CSS structure is mixed with your UI code, and it is not easy to upgrade or change the theme later.",
- "UITheme&Layout_ABPSOLUTION_Description": "ABP Framework provides a theming system that makes your UI code independent from the theme. Themes are isolated, and they are NuGet/NPM packages. Installing or upgrading a theme is just a minute. While you can build your theme (or integrate an existing theme), ABP Commercial offers professional and modern themes.",
- "UITheme&Layout_ABPSOLUTION_Description2": "There are also UI component providers (like Telerik and DevExpress). But they only provide individual components. You are responsible for creating your own layout system. You can use such libraries in your ABP-based solutions just like in any other project.",
+ "UITheme&Layout_THEPROBLEM_Description": "When addressing UI concerns, a range of challenges surfaces. These include establishing the groundwork for a responsive, contemporary, and adaptable UI kit with a consistent appearance and a host of features like navigation menus, headers, toolbars, footers, widgets, and more.",
+ "UITheme&Layout_THEPROBLEM_Description2": "Even if you opt for a pre-designed theme, seamlessly integrating it into your project could demand days of development. An additional hurdle lies in upgrading such themes. Frequently, the theme's HTML/CSS structure becomes intertwined with your UI code, rendering future theme changes or upgrades intricate tasks. This interweaving of code and design complicates the flexibility of making adjustments down the line.",
+ "UITheme&Layout_ABPSOLUTION_Description": "ABP Framework offers a distinctive theming system that liberates your UI code from theme constraints. Themes exist in isolation, packaged as NuGet or NPM packages, making theme installation or upgrades a matter of minutes. While you retain the option to develop your custom theme or integrate an existing one, ABP Commercial presents a collection of polished and contemporary themes.",
+ "UITheme&Layout_ABPSOLUTION_Description2": "Additionally, there are UI component providers like Telerik and DevExpress. However, these providers primarily furnish individual components, placing the onus on you to establish your layout system. When working within ABP-based projects, you can seamlessly incorporate these libraries, similar to how you would in any other project.",
"TestInfrastructure": "Test Infrastructure",
- "TestInfrastructure_THEPROBLEM_Description": "Preparing a robust test environment takes time. You need to setup test projects in your solution, select the tools, mock the services and database, create the required base classes and utility services to reduce repeating code in the tests and so on.",
- "TestInfrastructure_ABPSOLUTION_Description": "ABP Startup Templates comes with the test projects already configured for you, and you can immediately write your first unit or integration test code on day 1.",
+ "TestInfrastructure_THEPROBLEM_Description": "Establishing a robust testing environment is a time-consuming endeavor. It involves setting up dedicated test projects within your solution, carefully selecting the necessary tools, creating service and database mocks, crafting essential base classes and utility services to minimize redundant code across tests, and addressing various related tasks.",
+ "TestInfrastructure_ABPSOLUTION_Description": "ABP Startup Templates arrive pre-equipped with configured test projects, streamlining the process for you. This means that from day one, you can readily commence writing your initial unit or integration test code without delay.",
"CodingStandards&Training": "Coding Standards & Training",
- "CodingStandards&Training_THEPROBLEM_Description": "Once you create the development-ready solution, you typically need to train the developers to explain the system and develop it with the same conventions in a standard and consistent way. Even if you train the developers, it is hard to prepare and maintain your documentation. Over time, every developer will write the code differently, and coding standards will begin to diverge.",
- "CodingStandards&Training_ABPSOLUTION_Description": "ABP solution is already well-defined and well-documented. Tutorials and best practice guides clearly explain how to make development on an ABP project.",
+ "CodingStandards&Training_THEPROBLEM_Description": "After you've set up the solution for development, you usually have to teach the developers how the system works and how to build it using the same agreed-upon methods. Even if you give them training, keeping the documentation up-to-date can be difficult. As time goes on, each developer might write code in their own way, causing the rules for writing code to become different from each other.",
+ "CodingStandards&Training_ABPSOLUTION_Description": "The ABP solution is already neatly organized and has clear explanations. Step-by-step tutorials and guides show you exactly how to work on an ABP project.",
"KeepingYourSolutionUpToDate": "Keeping Your Solution Up to Date",
"KeepingYourSolutionUpToDate_THEPROBLEM_Description": "After you start your development, you must keep track of the new versions of the libraries you use for upgrades & patches.",
"KeepingYourSolutionUpToDate_ABPSOLUTION_Description": "We regularly update all packages to the latest versions and test them before the stable release. When you update the ABP Framework, all its dependencies are upgraded to edge technology.",
@@ -1073,6 +1073,8 @@
"ABPCommunity_Description2": "It is easy to share code or even re-usable libraries between ABP developers. A code snippet that works for you will also work for others. There are a lot of samples and tutorials that you can directly implement for your application.",
"ABPCommunity_Description3": "When you hire a developer who worked before with the ABP architecture will immediately understand your solution and start development in a very short time.",
"WhyAbpIo_Page_Title": "Why ABP.IO Platform?",
- "AbpStudio_Page_Title": "ABP Studio"
+ "AbpStudio_Page_Title": "ABP Studio",
+ "CampaignInfo": "Buy a new license or renew your existing license and get an additional 2 months at no additional cost! This offer is valid for all license plans. Ensure you take advantage of this limited-time promotion to expand your access to premium features and upgrades.",
+ "HurryUpLastDay": "Hurry Up! Last Day: {0}"
}
}
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json
index e6b3cf46f7..4951ee85b4 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json
@@ -37,6 +37,7 @@
"ThisExtensionIsNotAllowed": "This extension is not allowed.",
"TheFileIsTooLarge": "The file is too large.",
"GoToThePost": "Go to the Post",
+ "GoToTheVideo": "Go to the Video",
"Contribute": "Contribute",
"OverallProgress": "Overall Progress",
"Done": "Done",
@@ -189,6 +190,7 @@
"SeeMoreVideos": "See more videos",
"DiscordPageTitle": "ABP Discord Community",
"ViewVideo": "View Video",
- "AbpCommunityTitleContent": "ABP Community - Open Source ABP Framework"
+ "AbpCommunityTitleContent": "ABP Community - Open Source ABP Framework",
+ "CommunitySlogan": "A unique community platform for ABP Lovers"
}
}
diff --git a/common.props b/common.props
index ea9b36f855..e956b17835 100644
--- a/common.props
+++ b/common.props
@@ -1,7 +1,7 @@
latest
- 7.4.0-rc.3
+ 8.0.0$(NoWarn);CS1591;CS0436https://abp.io/assets/abp_nupkg.pnghttps://abp.io/
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/POST.md b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/POST.md
new file mode 100644
index 0000000000..c7d8411886
--- /dev/null
+++ b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/POST.md
@@ -0,0 +1,287 @@
+# ABP.IO Platform 7.4 RC Has Been Released
+
+Today, we are happy to release the [ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) version **7.4 RC** (Release Candidate). This blog post introduces the new features and important changes in this new version.
+
+Try this version and provide feedback for a more stable version of ABP v7.4! Thanks to all of you.
+
+## Get Started with the 7.4 RC
+
+Follow the steps below to try version 7.4.0 RC today:
+
+1) **Upgrade** the ABP CLI to version `7.4.0-rc.1` using a command line terminal:
+
+````bash
+dotnet tool update Volo.Abp.Cli -g --version 7.4.0-rc.1
+````
+
+**or install** it if you haven't before:
+
+````bash
+dotnet tool install Volo.Abp.Cli -g --version 7.4.0-rc.1
+````
+
+2) Create a **new application** with the `--preview` option:
+
+````bash
+abp new BookStore --preview
+````
+
+See the [ABP CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all the available options.
+
+> You can also use the [Get Started](https://abp.io/get-started) page to generate a CLI command to create a new application.
+
+You can use any IDE that supports .NET 7.x, like [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/).
+
+## Migration Guides
+
+There are a few breaking changes in this version that may affect your application.
+Please see the following migration documents, if you are upgrading from v7.3 or earlier:
+
+* [ABP Framework 7.3 to 7.4 Migration Guide](https://docs.abp.io/en/abp/7.4/Migration-Guides/Abp-7_4)
+
+## What's New with ABP Framework 7.4?
+
+In this section, I will introduce some major features released in this version. Here is a brief list of the titles that will be explained in the next sections:
+
+* Dynamic Setting Store
+* Introducing the `AdditionalAssemblyAttribute`
+* `CorrelationId` Support on Distributed Events
+* Database Migration System for EF Core
+* Other News
+
+### Dynamic Setting Store
+
+Prior to this version, it was hard to define settings in different microservices and centrally manage all setting definitions in a single admin application. To make that possible, we used to add project references for all the microservices' service contract packages from a single microservice, so it can know all the setting definitions and manage them.
+
+In this version, ABP Framework introduces the Dynamic Setting Store, which is an important feature that allows you to collect and get all setting definitions from a single point and overcome the setting management problems on microservices.
+
+> *Note*: If you are upgrading from an earlier version and using the Setting Management module, you need to create a new migration and apply it to your database because a new database table has been added for this feature.
+
+### Introducing the `AdditionalAssemblyAttribute`
+
+In this version, we have introduced the `AdditionalAssemblyAttribute` to define additional assemblies to be part of a module. ABP Framework automatically registers all the services of your module to the [Dependency Injection System](https://docs.abp.io/en/abp/latest/Dependency-Injection). It finds the service types by scanning types in the assembly that define your module class. Typically, every assembly contains a separate module class definition and modules depend on each other using the `DependsOn` attribute.
+
+In some rare cases, your module may consist of multiple assemblies and only one of them defines a module class, and you want to make the other assemblies parts of your module. This is especially useful if you can't define a module class in the target assembly or you don't want to depend on that module's dependencies.
+
+In that case, you can use the `AdditionalAssembly` attribute as shown below:
+
+```csharp
+[DependsOn(...)] // Your module dependencies as you normally would do
+[AdditionalAssembly(typeof(IdentityServiceModule))] // A type in the target assembly (in another assembly)
+public class IdentityServiceTestModule : AbpModule
+{
+ ...
+}
+```
+
+With the `AdditionalAssembly` attribute definition, ABP loads the assembly containing the `IdentityServiceModule` class as a part of the identity service module. Notice that in this case, none of the module dependencies of the `IdentityServiceModule` are loaded. Because we are not depending on the `IdentityServiceModule`, instead we are just adding its assembly as a part of the `IdentityServiceTestModule`.
+
+> You can check the [Module Development Basics](https://docs.abp.io/en/abp/7.4/Module-Development-Basics) documentation to learn more.
+
+### `CorrelationId` Support on Distributed Events
+
+In this version, `CorrelationId` (a unique key that is used in distributed applications to trace requests across multiple services/operations) is attached to the distributed events, so you can relate events with HTTP requests and can trace all the related activities.
+
+ABP Framework generates a `correlationId` for the first time when an operation is started and then attaches the current `correlationId` to distributed events as an additional property. For example, if you are using the [transactional outbox or inbox pattern provided by ABP Framework](https://docs.abp.io/en/abp/latest/Distributed-Event-Bus#outbox-inbox-for-transactional-events), you can see the `correlationId` in the extra properties of the `IncomingEventInfo` or `OutgoingEventInfo` classes with the standard `X-Correlation-Id` key.
+
+> You can check [this issue](https://github.com/abpframework/abp/issues/16773) for more information.
+
+### Database Migration System for EF Core
+
+In this version, ABP Framework provides base classes and events to migrate the database schema and seed the database on application startup. This system works compatibly with multi-tenancy and whenever a new tenant is created or a tenant's database connection string has been updated, it checks and applies database migrations for the new tenant state.
+
+This system is especially useful to migrate databases for microservices. In this way, when you deploy a new version of a microservice, you don't need to manually migrate its database.
+
+You need to take the following actions to use the database migration system:
+
+* Create a class that derives from `EfCoreRuntimeDatabaseMigratorBase` class, override and implement its `SeedAsync` method. And lastly, execute the `CheckAndApplyDatabaseMigrationsAsync` method of your class in the `OnPostApplicationInitializationAsync` method of your module class.
+* Create a class that derives from `DatabaseMigrationEventHandlerBase` class, override and implement its `SeedAsync` method. Then, whenever a new tenant is created or a tenant's connection string is changed then the `SeedAsync` method will be executed.
+
+### Other News
+
+* [OpenIddict](https://github.com/openiddict/openiddict-core/tree/4.7.0) library has been upgraded to **v4.7.0**. See [#17334](https://github.com/abpframework/abp/pull/17334) for more info.
+* ABP v7.4 introduces the `Volo.Abp.Maui.Client` package, which is used by the MAUI mobile application in ABP Commercial. See [#17201](https://github.com/abpframework/abp/pull/17201) for more info.
+* In this version, the `AbpAspNetCoreIntegratedTestBase` class gets a generic type parameter, which expects either a startup class or an ABP module class. This allows us to use configurations from an ABP module or old-style ASP.NET Core Startup class in a test application class and this simplifies the test application project. See [#17039](https://github.com/abpframework/abp/pull/17039) for more info.
+
+## What's New with ABP Commercial 7.4?
+
+We've also worked on [ABP Commercial](https://commercial.abp.io/) to align the features and changes made in the ABP Framework. The following sections introduce new features coming with ABP Commercial 7.4.
+
+### Dynamic Text Template Store
+
+Prior to this version, it was hard to create text templates in different microservices and centrally manage them in a single admin application. For example, if you would define a text template in your ordering microservice, then those text templates could not be seen on the administration microservice because the administration microservice would not have any knowledge about that text template (because it's hard-coded in the ordering microservice).
+
+For this reason, in this version, the Dynamic Text Template Store has been introduced to make the [Text Template Management module](https://docs.abp.io/en/commercial/latest/modules/text-template-management) compatible with microservices and distributed systems. It allows you to store and get all text templates from a single point. Thanks to that, you can centrally manage the text templates in your admin application.
+
+> *Note*: If you are upgrading from an earlier version and are using the Text Template Management module, you need to create a new migration and apply it to your database.
+
+To enable the dynamic template store, you just need to configure the `TextTemplateManagementOptions` and set the `IsDynamicTemplateStoreEnabled` as true in your module class:
+
+```csharp
+Configure(options =>
+{
+ options.IsDynamicTemplateStoreEnabled = true;
+});
+```
+
+Notice this is only needed in the microservice where you centrally manage your text template contents. So, typically you would use the configuration above in your administration microservice. Other microservices automatically save their text template contents to the central database.
+
+### Suite: Custom Code Support
+
+In this version, we have implemented the custom code support in Suite. This allows you to customize the generated code-blocks and preserve your custom code changes in the next CRUD Page Generation in Suite. ABP Suite specifies hook-points to allow adding custom code blocks. Then, the code that you wrote to these hook points will be respected and will not be overridden in the next entity generation.
+
+
+
+To enable custom code support, you should check the *Customizable code* option in the crud page generation page. When you enable the custom code support, you will be seeing some hook-points in your application.
+
+For example, on the C# side, you'll be seeing some abstract classes and classes that derive from them (for entities, application services, interfaces, domain services, and so on...). You can write your custom code in those classes (`*.Extended.cs`) and the next time when you need to re-generate the entity, your custom code will not be overridden (only the base abstract classes will be re-generated and your changes on Suite will be respected):
+
+Folder structure | Book.Extended.cs
+:-------------------------:|:-------------------------:
+ | 
+
+> *Note*: If you want to override the entity and add custom code, please do not touch the code between `...` placeholders, because the constructor of the entity should be always re-generated in case of a new property added.
+
+On the UI side, you can see the *comment placeholders* on the pages for MVC & Blazor applications. These are hook-points provided by ABP Suite and you can write your custom code between these comment sections:
+
+Folder structure | Books/Index.cshtml
+:-------------------------:|:-------------------------:
+ | 
+
+### MAUI & React Native UI Revisions
+
+In this version, we have revised MAUI & React Native mobile applications and added new pages, functionalities and made improvements on the UI side.
+
+
+
+For example, in the MAUI application, we have implemented the following functionalities and changed the UI completely:
+
+* **User Management Page**: Management page for your application users. You can search, add, update, or delete users of your application.
+* **Tenants**: Management page for your tenants.
+* **Settings**: Management page for your application settings. On this page, you can change **the current language**, **the profile picture**, **the current password**, or/and **the current theme**.
+
+Also, we have aligned the features on both of these mobile options (MAUI & React Native) and showed them in the ["ABP Community Talks 2023.5: Exploring the Options for Mobile Development with the ABP Framework"](https://community.abp.io/events/mobile-development-with-the-abp-framework-ogtwaz5l).
+
+> If you have missed the event, you can watch from 👉 [here](https://www.youtube.com/watch?v=-wrdngeKgZw).
+
+### New LeptonX Theme Features
+
+In the new version of LeptonX Theme, which is v2.4.0-rc.1, there are some new features that we want to mention.
+
+#### Mobile Toolbars
+
+The [Toolbar System](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Toolbars) is used to define *toolbars* on the user interface. Modules (or your application) can add items to a toolbar, then the UI themes can render the toolbar on the layout.
+
+LeptonX Theme extends this system even further and introduces mobile toolbars with this version. You can create a component and add it as a mobile toolbar as below:
+
+```csharp
+public class MyToolbarContributor : IToolbarContributor
+{
+ public Task ConfigureToolbarAsync(IToolbarConfigurationContext context)
+ {
+ if (context.Toolbar.Name == LeptonXToolbars.MainMobile)
+ {
+ context.Toolbar.Items.Add(new ToolbarItem(typeof(ShoppingCardToolbarComponent)));
+
+ //other mobile toolbars...
+ }
+
+ return Task.CompletedTask;
+ }
+}
+```
+
+Then, the LeptonX Theme will render these mobile toolbars like in the figure below:
+
+
+
+> **Note**: The Angular UI hasn't been completed yet. We aim to complete it as soon as possible and include it in the next release.
+
+#### New Error Page Designs
+
+In this version, we have implemented new error pages. Encounter a fresh look during error situations with the 'New Error Page Designs,' providing informative and visually appealing error displays that enhance user experience:
+
+
+
+#### Fluid Layout
+
+In this version, LeptonX Theme introduces the fresh-looking **Fluid Layout**, which is a layout that lets you align elements so that they automatically adjust their alignment and proportions for different page sizes and orientations.
+
+
+
+> You can visit [the live demo of LeptonX Theme](https://x.leptontheme.com/side-menu) and try the Fluid Layout now!
+
+### Check & Move Related Entities on Deletion/Demand
+
+In application modules, there are some entities that have complete relationships with each other such as role-user relations. In such cases, it's a typical requirement to check & move related entities that have a relation with the other entity that is about to be deleted.
+
+For example, if you need to delete an edition from your system, you would typically want to move the tenant that is associated with that edition. For this purpose, in this version, ABP Commercial allows you to move related entities on deletion/demand.
+
+
+
+Currently, this feature is implemented for SaaS and Identity Pro modules and for the following relations:
+
+* Edition - Tenant
+* Role - User
+* Organization Unit - User
+
+Also, it's possible to move the related associated-records before deleting the record. For example, you can move all tenants from an edition as shown in the figure below:
+
+"Move all tenants" action | "Move all tenants" modal
+:-------------------------:|:-------------------------:
+ | 
+
+### CMS Kit Pro: Page Feedback
+
+In this version, the **Page Feedback** feature has been added to the [CMS Kit Pro](https://docs.abp.io/en/commercial/latest/modules/cms-kit/index) module. This feature allows you to get feedback from a page in your application.
+
+This is especially useful if you have content that needs feedback from users. For example, if you have documentation or a blog website, it's a common requirement to assess the quality of the articles and get feedback from users. In that case, you can use this feature:
+
+
+
+### Chat Module: Deleting Messages & Conversations
+
+In this version, the [Chat Module](https://docs.abp.io/en/commercial/latest/modules/chat) allows you to delete individual messages or a complete conversation.
+
+You can enable or disable the message/conversation deletion globally on your application:
+
+
+
+> **Note**: The Angular UI hasn't been completed yet. We aim to complete it as soon as possible and include it in the next release.
+
+### Password Complexity Indicators
+
+In this version, ABP Framework introduces an innovative ["Password Complexity Indicator"](https://docs.abp.io/en/commercial/7.4/ui/angular/password-complexity-indicator-component) feature, designed to enhance security and user experience. This feature dynamically evaluates and rates the strength of user-generated passwords, providing real-time feedback to users as they create or update their passwords. By visually indicating the complexity level, users are guided toward crafting stronger passwords that meet modern security standards.
+
+
+
+You can check the [Password Complexity Indicator Angular documentation](https://docs.abp.io/en/commercial/7.4/ui/angular/password-complexity-indicator-component) to learn more.
+
+> **Note**: Currently, this feature is only available for the Angular UI, but we will be implemented for other UIs in the next version.
+
+## Community News
+
+### DevNot Developer Summit 2023
+
+
+
+We are thrilled to announce that the co-founder of [Volosoft](https://volosoft.com/) and Lead Developer of the ABP Framework, Halil Ibrahim Kalkan will give a speech about "Building a Kubernetes Integrated Local Development Environment" in the [Developer Summit 2023 event](https://summit.devnot.com/) on the 7th of October.
+
+### New ABP Community Posts
+
+There are exciting articles contributed by the ABP community as always. I will highlight some of them here:
+
+* [ABP Commercial - GDPR Module Overview](https://community.abp.io/posts/abp-commercial-gdpr-module-overview-kvmsm3ku) by [Engincan Veske](https://twitter.com/EngincanVeske)
+* [Video: ABP Framework Data Transfer Objects](https://community.abp.io/videos/abp-framework-data-transfer-objects-qwebfqz5) by [Hamza Albreem](https://github.com/braim23)
+* [Video: ABP Framework Essentials: MongoDB](https://community.abp.io/videos/abp-framework-essentials-mongodb-gwlblh5x) by [Hamza Albreem](https://github.com/braim23)
+* [ABP Modules and Entity Dependencies](https://community.abp.io/posts/abp-modules-and-entity-dependencies-hn7wr093) by [Jack Fistelmann](https://github.com/nebula2)
+* [How to add dark mode support to the Basic Theme in 3 steps?](https://community.abp.io/posts/how-to-add-dark-mode-support-to-the-basic-theme-in-3-steps-ge9c0f85) by [Enis Necipoğlu](https://twitter.com/EnisNecipoglu)
+* [Deploying docker image to Azure with yml and bicep through Github Actions](https://community.abp.io/posts/deploying-docker-image-to-azure-with-yml-and-bicep-through-github-actions-cjiuh55m) by [Sturla](https://community.abp.io/members/Sturla)
+
+Thanks to the ABP Community for all the content they have published. You can also [post your ABP-related (text or video) content](https://community.abp.io/articles/submit) to the ABP Community.
+
+## Conclusion
+
+This version comes with some new features and a lot of enhancements to the existing features. You can see the [Road Map](https://docs.abp.io/en/abp/7.4/Road-Map) documentation to learn about the release schedule and planned features for the next releases. Please try ABP v7.4 RC and provide feedback to help us release a more stable version.
+
+Thanks for being a part of this community!
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/book-extended-cs.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/book-extended-cs.png
new file mode 100644
index 0000000000..1179118621
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/book-extended-cs.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/book-extended-cshtml.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/book-extended-cshtml.png
new file mode 100644
index 0000000000..0ed90a33de
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/book-extended-cshtml.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/cover-image.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/cover-image.png
new file mode 100644
index 0000000000..06ced79397
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/cover-image.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/developersummit.jpg b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/developersummit.jpg
new file mode 100644
index 0000000000..65bae90315
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/developersummit.jpg differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/editions.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/editions.png
new file mode 100644
index 0000000000..331706daa7
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/editions.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/error-page.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/error-page.png
new file mode 100644
index 0000000000..8ece260ec3
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/error-page.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/fluid-layout.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/fluid-layout.png
new file mode 100644
index 0000000000..6150f3e2bd
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/fluid-layout.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/maui.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/maui.png
new file mode 100644
index 0000000000..4205001d80
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/maui.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/mobile-toolbars.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/mobile-toolbars.png
new file mode 100644
index 0000000000..6dcde5da60
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/mobile-toolbars.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/move-all-tenants.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/move-all-tenants.png
new file mode 100644
index 0000000000..b893360447
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/move-all-tenants.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/move-tenants.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/move-tenants.png
new file mode 100644
index 0000000000..fb6b8364fb
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/move-tenants.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/page-feedback.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/page-feedback.png
new file mode 100644
index 0000000000..dbdd9fe199
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/page-feedback.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/password-complexity.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/password-complexity.png
new file mode 100644
index 0000000000..55bc8a8f43
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/password-complexity.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/settings.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/settings.png
new file mode 100644
index 0000000000..1e835661a0
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/settings.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code-backend.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code-backend.png
new file mode 100644
index 0000000000..cb14dfc0f1
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code-backend.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code-ui.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code-ui.png
new file mode 100644
index 0000000000..132988a873
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code-ui.png differ
diff --git a/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code.png b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code.png
new file mode 100644
index 0000000000..2e510d0768
Binary files /dev/null and b/docs/en/Blog-Posts/2023-08-15 v7_4_Preview/suite-custom-code.png differ
diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/POST.md b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/POST.md
index 6abf984298..ae688d6981 100644
--- a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/POST.md
+++ b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/POST.md
@@ -594,7 +594,7 @@ namespace BookStore.EntityFrameworkCore
/* Configure your own tables/entities inside here */
builder.Entity(b =>
{
- b.ToTable(BookStoreConsts.DbTablePrefix + "Authors" + BookStoreConsts.DbSchema);
+ b.ToTable(BookStoreConsts.DbTablePrefix + "Authors", BookStoreConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name)
@@ -608,7 +608,7 @@ namespace BookStore.EntityFrameworkCore
builder.Entity(b =>
{
- b.ToTable(BookStoreConsts.DbTablePrefix + "Books" + BookStoreConsts.DbSchema);
+ b.ToTable(BookStoreConsts.DbTablePrefix + "Books", BookStoreConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name)
@@ -624,7 +624,7 @@ namespace BookStore.EntityFrameworkCore
builder.Entity(b =>
{
- b.ToTable(BookStoreConsts.DbTablePrefix + "Categories" + BookStoreConsts.DbSchema);
+ b.ToTable(BookStoreConsts.DbTablePrefix + "Categories", BookStoreConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name)
@@ -634,7 +634,7 @@ namespace BookStore.EntityFrameworkCore
builder.Entity(b =>
{
- b.ToTable(BookStoreConsts.DbTablePrefix + "BookCategories" + BookStoreConsts.DbSchema);
+ b.ToTable(BookStoreConsts.DbTablePrefix + "BookCategories", BookStoreConsts.DbSchema);
b.ConfigureByConvention();
//define composite key
diff --git a/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/README.md b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/README.md
new file mode 100644
index 0000000000..2db041436c
--- /dev/null
+++ b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/README.md
@@ -0,0 +1,450 @@
+# Cascading Option Loading with Extensions System in ABP Angular
+
+This article will show how to load cascading options with an extensions system in ABP Angular. For this example, we'll simulate renting a book process. Besides our default form properties, we'll contribute `Name` property to our `Rent Form Modal` in the Books module. This property will be loaded after `Genre` is selected.
+
+> Before starting this article, I suggest you read the [ABP Angular Dynamic Form Extensions](https://docs.abp.io/en/abp/latest/UI/Angular/Dynamic-Form-Extensions)
+
+### Environment
+
+- **ABP Framework Version:** ~7.3.0 (`~` means that use the latest patch version of the specified release)
+- **DB Provider:** MongoDB
+- **Angular Version:** ~16.0.0
+
+### Project structure
+
+The books module is not a library; for this demo, it'll placed in the application itself.
+
+
+
+- **books folder:** Contains default form properties, tokens, models, etc. It's similar to the ABP module structure.
+- Also I've used **standalone** and **signals** feature in this demo.
+- **books-extended folder:** Contains only `Name` property for the contribute `Rent Form Modal` inside the Books module.
+- **For more readability, I've used TS path aliases in this demo. Don't forget to export files in `index.ts` file 🙂**
+
+
+
+### First look at the demo
+
+
+
+### What is the Extension system?
+
+
+
+# Reviewing the code step by step
+
+**1. Create default form properties for `Rent Form` in the `Books` module**
+
+- `getInjected` function is the key point of the cascading loading
+- We can reach and track any value from `Service` or `Component`
+- In that way we can load options according to the selected value
+
+```ts
+// ~/books/defaults/default-books-form.props.ts
+
+import { Validators } from "@angular/forms";
+import { map, of } from "rxjs";
+import { ePropType, FormProp } from "@abp/ng.theme.shared/extensions";
+import { BookDto, AuthorService, BooksService } from "../proxy";
+import { RentBookComponent } from "../components";
+import { DefaultOption } from "../utils";
+
+const { required } = Validators;
+
+export const DEFAULT_RENT_FORM_PROPS = FormProp.createMany([
+ {
+ type: ePropType.String,
+ id: "authorId",
+ name: "authorId",
+ displayName: "BookStore::Author",
+ defaultValue: null,
+ validators: () => [required],
+ options: (data) => {
+ const { authors } = data.getInjected(AuthorService);
+
+ return of([
+ DefaultOption,
+ ...authors().map((author) => ({ value: author.id, key: author.name })),
+ ]);
+ },
+ },
+ {
+ type: ePropType.String,
+ id: "genreId",
+ name: "genreId",
+ displayName: "BookStore::Genre",
+ defaultValue: null,
+ validators: () => [required],
+ options: (data) => {
+ const rentBookComponent = data.getInjected(RentBookComponent);
+ const { genres } = data.getInjected(BooksService);
+
+ const genreOptions = genres().map(({ id, name }) => ({
+ value: id,
+ key: name,
+ }));
+
+ return rentBookComponent.form.controls.authorId.valueChanges.pipe(
+ map((value: string | undefined) =>
+ value ? [DefaultOption, ...genreOptions] : [DefaultOption]
+ )
+ );
+ },
+ },
+ {
+ type: ePropType.Date,
+ id: "returnDate",
+ name: "returnDate",
+ displayName: "BookStore::ReturnDate",
+ defaultValue: null,
+ validators: () => [required],
+ },
+]);
+```
+
+**2. Configure tokens and config options**
+
+The documentation explains these steps; that's why I won't explain it again. If documents or samples are not enough, please let me know in the comments 🙂
+
+**Extensions Token**
+
+```ts
+// ~/books/tokens/extensions.token.ts
+
+import { CreateFormPropContributorCallback } from "@abp/ng.theme.shared/extensions";
+import { InjectionToken } from "@angular/core";
+import { BookDto } from "../proxy";
+import { eBooksComponents } from "../enums";
+import { DEFAULT_RENT_FORM_PROPS } from "../defaults";
+
+export const DEFAULT_BOOK_STORE_CREATE_FORM_PROPS = {
+ [eBooksComponents.RentBook]: DEFAULT_RENT_FORM_PROPS,
+};
+
+export const BOOK_STORE_RENT_FORM_PROP_CONTRIBUTORS =
+ new InjectionToken(
+ "BOOK_STORE_RENT_FORM_PROP_CONTRIBUTORS"
+ );
+
+type CreateFormPropContributors = Partial<{
+ [eBooksComponents.RentBook]: CreateFormPropContributorCallback[];
+ /**
+ * Other creation form prop contributors...
+ */
+ // [eBooksComponents.CreateBook]: CreateFormPropContributorCallback[];
+}>;
+```
+
+**Extensions Config Option**
+
+```ts
+// ~/books/models/config-options.ts
+
+import { CreateFormPropContributorCallback } from "@abp/ng.theme.shared/extensions";
+import { BookDto } from "../proxy";
+import { eBooksComponents } from "../enums";
+
+export type BookStoreRentFormPropContributors = Partial<{
+ [eBooksComponents.RentBook]: CreateFormPropContributorCallback[];
+}>;
+
+export interface BooksConfigOptions {
+ rentFormPropContributors?: BookStoreRentFormPropContributors;
+}
+```
+
+**3. Extensions Guard**
+
+It'll to collect all contributors from [ExtensionsService](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/theme-shared/extensions/src/lib/services/extensions.service.ts)
+
+```ts
+// ~/books/guards/extensions.guard.ts
+
+import { Injectable, inject } from "@angular/core";
+import { Observable, map, tap } from "rxjs";
+import { ConfigStateService, IAbpGuard } from "@abp/ng.core";
+import {
+ ExtensionsService,
+ getObjectExtensionEntitiesFromStore,
+ mapEntitiesToContributors,
+ mergeWithDefaultProps,
+} from "@abp/ng.theme.shared/extensions";
+import {
+ BOOK_STORE_RENT_FORM_PROP_CONTRIBUTORS,
+ DEFAULT_BOOK_STORE_CREATE_FORM_PROPS,
+} from "../tokens";
+
+@Injectable()
+export class BooksExtensionsGuard implements IAbpGuard {
+ protected readonly configState = inject(ConfigStateService);
+ protected readonly extensions = inject(ExtensionsService);
+
+ canActivate(): Observable {
+ const createFormContributors =
+ inject(BOOK_STORE_RENT_FORM_PROP_CONTRIBUTORS, { optional: true }) || {};
+
+ return getObjectExtensionEntitiesFromStore(
+ this.configState,
+ "BookStore"
+ ).pipe(
+ mapEntitiesToContributors(this.configState, "BookStore"),
+ tap((objectExtensionContributors) => {
+ mergeWithDefaultProps(
+ this.extensions.createFormProps,
+ DEFAULT_BOOK_STORE_CREATE_FORM_PROPS,
+ objectExtensionContributors.createForm,
+ createFormContributors
+ );
+ }),
+ map(() => true)
+ );
+ }
+}
+```
+
+Yes, I'm still using class-based guard 🙂 much more flexible...
+
+**4. RentBookComponent**
+
+- Our trackable variable is defined here `(form:FormGroup)`, which means We'll track this variable in `options` property at defaults || contributors files.
+- Providing `AuthorService`, also `EXTENSIONS_IDENTIFIER` for the reach dynamic properties
+
+```ts
+import {
+ ChangeDetectionStrategy,
+ Component,
+ EventEmitter,
+ Injector,
+ Output,
+ inject,
+} from "@angular/core";
+import { FormGroup } from "@angular/forms";
+import { CoreModule, uuid } from "@abp/ng.core";
+import { ThemeSharedModule } from "@abp/ng.theme.shared";
+import {
+ EXTENSIONS_IDENTIFIER,
+ FormPropData,
+ UiExtensionsModule,
+ generateFormFromProps,
+} from "@abp/ng.theme.shared/extensions";
+import { AuthorService, BookDto, BooksService } from "../../proxy";
+import { eBooksComponents } from "../../enums";
+
+@Component({
+ standalone: true,
+ selector: "app-rent-book",
+ templateUrl: "./rent-book.component.html",
+ imports: [CoreModule, UiExtensionsModule, ThemeSharedModule],
+ providers: [
+ {
+ provide: EXTENSIONS_IDENTIFIER,
+ useValue: eBooksComponents.RentBook,
+ },
+ AuthorService,
+ ],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class RentBookComponent {
+ protected readonly injector = inject(Injector);
+ protected readonly authorService = inject(AuthorService);
+ protected readonly booksService = inject(BooksService);
+
+ //#region Just for demo
+ readonly #authors = this.authorService.authors();
+ readonly #genres = this.booksService.genres();
+ readonly #books = this.booksService.books();
+ //#endregion
+
+ protected modalVisible = true;
+ @Output() modalVisibleChange = new EventEmitter();
+
+ selected: BookDto;
+ form: FormGroup;
+ modalBusy = false;
+
+ protected buildForm(): void {
+ const data = new FormPropData(this.injector, this.selected);
+ this.form = generateFormFromProps(data);
+ }
+
+ constructor() {
+ this.buildForm();
+ }
+
+ save(): void {
+ if (this.form.invalid) {
+ return;
+ }
+
+ this.modalBusy = true;
+
+ const { authorId, genreId, bookId, returnDate } = this.form.value;
+
+ //#region Just for demo
+ const authorName = this.#authors.find(({ id }) => id === authorId).name;
+ const genreName = this.#genres.find(({ id }) => id === genreId).name;
+ const bookName = this.#books.find(({ id }) => id === bookId).name;
+ //#endregion
+
+ this.booksService.rentedBooks.update((books) => [
+ {
+ id: uuid(),
+ name: bookName,
+ author: authorName,
+ genre: genreName,
+ returnDate,
+ },
+ ...books,
+ ]);
+
+ this.modalBusy = false;
+ this.modalVisible = false;
+ }
+}
+```
+
+```html
+
+
+
{{ 'BookStore::RentABook' | abpLocalization }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ 'AbpIdentity::Save' | abpLocalization }}
+
+
+
+```
+
+Up to now, we have constructed our module's default form properties.
+
+- As you can see, there are no book names we'll add them via contributors
+
+
+
+## Next, add new property dynamically (book name list as dropdown)
+
+- Created new folder ./src/app/books-extended
+- Create contributors/form-prop.contributors.ts
+
+```ts
+// ~/books-extened/contributors/form-prop.contributors.ts
+
+import { Validators } from "@angular/forms";
+import { map } from "rxjs";
+import {
+ ePropType,
+ FormProp,
+ FormPropList,
+} from "@abp/ng.theme.shared/extensions";
+import {
+ BookDto,
+ BookStoreRentFormPropContributors,
+ BooksService,
+ DefaultOption,
+ RentBookComponent,
+ eBooksComponents,
+} from "@book-store/books";
+
+const { required, maxLength } = Validators;
+
+const bookIdProp = new FormProp({
+ type: ePropType.String,
+ id: "bookId",
+ name: "bookId",
+ displayName: "BookStore::Name",
+ options: (data) => {
+ const rentBook = data.getInjected(RentBookComponent);
+ const { books } = data.getInjected(BooksService);
+ const bookOptions = books().map(({ id, name }) => ({
+ value: id,
+ key: name,
+ }));
+
+ return rentBook.form.controls.genreId.valueChanges.pipe(
+ map((value: string | undefined) =>
+ value ? [DefaultOption, ...bookOptions] : [DefaultOption]
+ )
+ );
+ },
+ validators: () => [required, maxLength(255)],
+});
+
+export function bookIdPropContributor(propList: FormPropList) {
+ propList.addByIndex(bookIdProp, 2);
+}
+
+export const bookStoreRentFormPropContributors: BookStoreRentFormPropContributors =
+ {
+ [eBooksComponents.RentBook]: [bookIdPropContributor],
+ };
+```
+
+- Load new contributions via routing & forLazy method
+
+```ts
+// ~/app-routing.module.ts
+import { bookStoreRentFormPropContributors } from "./books-extended/contributors/form-prop.contributors";
+
+const routes: Routes = [
+ // other routes...
+ {
+ path: "books",
+ loadChildren: () =>
+ import("@book-store/books").then((m) =>
+ m.BooksModule.forLazy({
+ rentFormPropContributors: bookStoreRentFormPropContributors,
+ })
+ ),
+ },
+];
+
+@NgModule({
+ imports: [RouterModule.forRoot(routes, {})],
+ exports: [RouterModule],
+})
+export class AppRoutingModule {}
+```
+
+Finally, we've added a new property to our module, and it'll be loaded after `Genre` is selected.
+
+## Conclusion
+
+
+
+- In ABP Angular, we can create form properties and load dropdown options dynamically via the Extensions System
+- We can reach and track any value from `Service` or `Component`
+- We can create our custom library or module and contribute it to any module in the application
+
+Thanks for reading, I hope it was helpful. If you have any questions, please let me know in the comments section. 👋👋
+
+> You can find the source code of this article on [Github](https://github.com/abpframework/abp-samples/tree/master/AngularCascadingOptionLoading/Volo.BookStore)
diff --git a/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/gif/cascading-loading-demo.gif b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/gif/cascading-loading-demo.gif
new file mode 100644
index 0000000000..ae69070f28
Binary files /dev/null and b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/gif/cascading-loading-demo.gif differ
diff --git a/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/extensions-system-document.png b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/extensions-system-document.png
new file mode 100644
index 0000000000..7f806ec42d
Binary files /dev/null and b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/extensions-system-document.png differ
diff --git a/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/folder-structure.png b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/folder-structure.png
new file mode 100644
index 0000000000..2d3a828773
Binary files /dev/null and b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/folder-structure.png differ
diff --git a/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/rent-form-without-contribution.png b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/rent-form-without-contribution.png
new file mode 100644
index 0000000000..e29d525f7b
Binary files /dev/null and b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/rent-form-without-contribution.png differ
diff --git a/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/ts-config-file.png b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/ts-config-file.png
new file mode 100644
index 0000000000..6b06e8ca90
Binary files /dev/null and b/docs/en/Community-Articles/2023-07-09-Cascading-Option-Loading-With-Extensions/assets/img/ts-config-file.png differ
diff --git a/docs/en/Emailing.md b/docs/en/Emailing.md
index bfb3058862..48635b2565 100644
--- a/docs/en/Emailing.md
+++ b/docs/en/Emailing.md
@@ -58,7 +58,11 @@ namespace MyProject
`SendAsync` method has overloads to supply more parameters like;
* **from**: You can set this as the first argument to set a sender email address. If not provided, the default sender address is used (see the email settings below).
+* **to**: You can set the target email address.
+* **subject**: You can set the email subject.
+* **body**: You can set the email body.
* **isBodyHtml**: Indicates whether the email body may contain HTML tags. **Default: true**.
+* **additionalEmailSendingArgs**: This parameter is used to pass additional arguments to the `IEmailSender` implementation. Include: CC(Carbon copy), a list of `EmailAttachment` and an extra properties.
> `IEmailSender` is the suggested way to send emails, since it makes your code provider independent.
diff --git a/docs/en/Entity-Framework-Core-Migrations.md b/docs/en/Entity-Framework-Core-Migrations.md
index 716038d412..9ac7e76f24 100644
--- a/docs/en/Entity-Framework-Core-Migrations.md
+++ b/docs/en/Entity-Framework-Core-Migrations.md
@@ -173,7 +173,7 @@ First step is to change the connection string section inside all the `appsetting
````json
"ConnectionStrings": {
- "Default": "Server=(LocalDb)\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
+ "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
}
````
@@ -184,7 +184,7 @@ Change it as shown below:
"Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True",
"AbpPermissionManagement": "Server=(LocalDb)\\MSSQLLocalDB;Database=BookStore_SecondDb;Trusted_Connection=True",
"AbpSettingManagement": "Server=(LocalDb)\\MSSQLLocalDB;Database=BookStore_SecondDb;Trusted_Connection=True",
- "AbpAuditLogging": "Server=(LocalDb)\MSSQLLocalDB;Database=BookStore_SecondDb;Trusted_Connection=True"
+ "AbpAuditLogging": "Server=(LocalDb)\\MSSQLLocalDB;Database=BookStore_SecondDb;Trusted_Connection=True"
}
````
diff --git a/docs/en/Entity-Framework-Core.md b/docs/en/Entity-Framework-Core.md
index e2cfd21a05..cb9393b1aa 100644
--- a/docs/en/Entity-Framework-Core.md
+++ b/docs/en/Entity-Framework-Core.md
@@ -594,6 +594,18 @@ Whenever you access to a property/collection, EF Core automatically performs an
See also [lazy loading document](https://docs.microsoft.com/en-us/ef/core/querying/related-data/lazy) of the EF Core.
+## Read-Only Repositories
+
+ABP Framework provides read-only [repository](Repositories.md) interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`) to explicitly indicate that your purpose is to query data, but not change it. If so, you can inject these interfaces into your services.
+
+Entity Framework Core read-only repository implementation uses [EF Core's No-Tracking feature](https://learn.microsoft.com/en-us/ef/core/querying/tracking#no-tracking-queries). That means the entities returned from the repository will not be tracked by the EF Core [change tracker](https://learn.microsoft.com/en-us/ef/core/change-tracking/), because it is expected that you won't update entities queried from a read-only repository. If you need to track the entities, you can still use the [AsTracking()](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.entityframeworkqueryableextensions.astracking) extension method on the LINQ expression, or `EnableTracking()` extension method on the repository object (See *Enabling / Disabling the Change Tracking* section in this document).
+
+> This behavior works only if the repository object is injected with one of the read-only repository interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`). It won't work if you have injected a standard repository (e.g. `IRepository<...>`) then casted it to a read-only repository interface.
+
+## Enabling / Disabling the Change Tracking
+
+In addition to the read-only repositories, ABP allows to manually control the change tracking behavior for querying objects. Please see the *Enabling / Disabling the Change Tracking* section of the [Repositories documentation](Repositories.md) to learn how to use it.
+
## Access to the EF Core API
In most cases, you want to hide EF Core APIs behind a repository (this is the main purpose of the repository pattern). However, if you want to access the `DbContext` instance over the repository, you can use `GetDbContext()` or `GetDbSet()` extension methods. Example:
diff --git a/docs/en/Getting-Started-Running-Solution-Single-Layer.md b/docs/en/Getting-Started-Running-Solution-Single-Layer.md
index cef80c7807..f18f3119f9 100644
--- a/docs/en/Getting-Started-Running-Solution-Single-Layer.md
+++ b/docs/en/Getting-Started-Running-Solution-Single-Layer.md
@@ -20,7 +20,7 @@ Check the **connection string** in the `appsettings.json` file under the `YourPr
````json
"ConnectionStrings": {
- "Default": "Server=(LocalDb)\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
+ "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
}
````
diff --git a/docs/en/Getting-Started-Running-Solution.md b/docs/en/Getting-Started-Running-Solution.md
index 36cd5ffe0a..f3adcac67d 100644
--- a/docs/en/Getting-Started-Running-Solution.md
+++ b/docs/en/Getting-Started-Running-Solution.md
@@ -21,7 +21,7 @@ Check the **connection string** in the `appsettings.json` file under the {{if Ti
````json
"ConnectionStrings": {
- "Default": "Server=(LocalDb)\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
+ "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
}
````
diff --git a/docs/en/Object-To-Object-Mapping.md b/docs/en/Object-To-Object-Mapping.md
index c12b260921..40efdd7ee6 100644
--- a/docs/en/Object-To-Object-Mapping.md
+++ b/docs/en/Object-To-Object-Mapping.md
@@ -320,9 +320,22 @@ public class MyCustomUserMapper : IObjectMapper, ITransientDepend
}
````
-ABP automatically discovers and registers the `MyCustomUserMapper` and it is automatically used whenever you use the `IObjectMapper` to map `User` to `UserDto`.
-
-A single class may implement more than one `IObjectMapper` each for a different object pairs.
+ABP automatically discovers and registers the `MyCustomUserMapper` and it is automatically used whenever you use the `IObjectMapper` to map `User` to `UserDto`. A single class may implement more than one `IObjectMapper` each for a different object pairs.
> This approach is powerful since `MyCustomUserMapper` can inject any other service and use in the `Map` methods.
+Once you implement `IObjectMapper`, ABP can automatically convert a collection of `User` objects to a collection of `UserDto` objects. The following generic collection types are supported:
+
+* `IEnumerable`
+* `ICollection`
+* `Collection`
+* `IList`
+* `List`
+* `T[]` (array)
+
+**Example:**
+
+````csharp
+var users = await _userRepository.GetListAsync(); // returns List
+var dtos = ObjectMapper.Map, List>(users); // creates List
+````
diff --git a/docs/en/Repositories.md b/docs/en/Repositories.md
index 95f908d004..03fb27ab50 100644
--- a/docs/en/Repositories.md
+++ b/docs/en/Repositories.md
@@ -176,6 +176,77 @@ Some features (like soft-delete, multi-tenancy and audit logging) won't work, so
The `EnsureExistsAsync` extension method accepts entity id or entities query expression to ensure entities exist, otherwise, it will throw `EntityNotFoundException`.
+### Enabling / Disabling the Change Tracking
+
+ABP provides repository extension methods and attributes those can be used to control the change tracking behavior for queried entities in the underlying database provider.
+
+Disabling change tracking can gain performance if you query many entities from the database for read-only purposes. Querying single or a few entities won't make much performance difference, but you are free to use it whenever you like.
+
+> If the underlying database provider doesn't support change tracking, then this system won't have any effect. [Entity Framework Core](Entity-Framework-Core.md) supports change tracking, for example, while the [MongoDB](MongoDB.md) provider doesn't support it.
+
+#### Repository Extension Methods for Change Tracking
+
+Change tracking is enabled unless you explicitly disable it.
+
+**Example: Using the `DisableTracking` extension method**
+
+````csharp
+public class MyDemoService : ApplicationService
+{
+ private readonly IRepository _personRepository;
+
+ public MyDemoService(IRepository personRepository)
+ {
+ _personRepository = personRepository;
+ }
+
+ public async Task DoItAsync()
+ {
+ // Change tracking is enabled in that point (by default)
+
+ using (_personRepository.DisableTracking())
+ {
+ // Change tracking is disabled in that point
+ var list = await _personRepository.GetPagedListAsync(0, 100, "Name ASC");
+ }
+
+ // Change tracking is enabled in that point (by default)
+ }
+}
+````
+
+> `DisableTracking` extension method returns a `IDisposable` object, so you can safely **restore** the change tracking behavior to the **previous state** one the `using` block ends. Basically, `DisableTracking` method ensures that the change tracking is disabled inside the `using` block, but doesn't affect outside of the `using` block. That means, if change tracking was already disabled, `DisableTracking` and the disposable return value do nothing.
+
+`EnableTracking()` method works exactly opposite to the `DisableTracking()` method. You typically won't use it (because the change tracking is already enabled by default), but it is there in case of you need that.
+
+#### Attributes for Change Tracking
+
+You typically use the `DisableTracking()` method for the application service methods those only returns data, but doesn't make any change on entities. For such cases, you can use the `DisableEntityChangeTracking` attribute on your method/class as a shortcut to disable the change tracking for whole method body.
+
+**Example: Using the `DisableEntityChangeTracking` attribute on a method**
+
+````csharp
+[DisableEntityChangeTracking]
+public virtual async Task> GetListAsync()
+{
+ /* We disabled the change tracking in this method
+ because we won't change the people objects */
+ var people = await _personRepository.GetListAsync();
+ return ObjectMapper.Map, List(people);
+}
+````
+
+`EnableEntityChangeTracking` can be used for the opposite purpose, and it ensures that the change tracking is enabled for a given method. Since the change tracking is enabled by default, `EnableEntityChangeTracking` may be needed only if you know that your method is called from a context that disables the change tracking.
+
+`DisableEntityChangeTracking` and `EnableEntityChangeTracking` attributes can be used on a **method** or on a **class** (which affects all of the class methods).
+
+ABP uses dynamic proxying to make these attributes working. There are some rules here:
+
+* If you are **not injecting** the service over an interface (like `IPersonAppService`), then the methods of the service must be `virtual`. Otherwise, [dynamic proxy / interception](Dynamic-Proxying-Interceptors.md) system can not work.
+* Only `async` methods (methods returning a `Task` or `Task`) are intercepted.
+
+> Change tracking behavior doesn't affect tracking entity objects returned from `InsertAsync` and `UpdateAsync` methods. The objects returned from these methods are always tracked (if the underlying provider has the change tracking feature) and any change you made to these objects are saved into the database.
+
## Other Generic Repository Types
Standard `IRepository` interface exposes the standard `IQueryable` and you can freely query using the standard LINQ methods. This is fine for most of the applications. However, some ORM providers or database systems may not support standard `IQueryable` interface. If you want to use such providers, you can't rely on the `IQueryable`.
@@ -205,8 +276,6 @@ Methods:
- `WithDetails()` 1 overload
- `WithDetailsAsync()` 1 overload
-
-
Where as the `IReadOnlyBasicRepository` provides the following methods:
- `GetCountAsync()`
@@ -217,6 +286,12 @@ They can all be seen as below:

+#### Read Only Repositories behavior in Entity Framework Core
+
+Entity Framework Core read-only repository implementation uses [EF Core's No-Tracking feature](https://learn.microsoft.com/en-us/ef/core/querying/tracking#no-tracking-queries). That means the entities returned from the repository will not be tracked by the EF Core [change tracker](https://learn.microsoft.com/en-us/ef/core/change-tracking/), because it is expected that you won't update entities queried from a read-only repository. If you need to track the entities, you can still use the [AsTracking()](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.entityframeworkqueryableextensions.astracking) extension method on the LINQ expression, or `EnableTracking()` extension method on the repository object (See *Enabling / Disabling the Change Tracking* section in this document).
+
+> This behavior works only if the repository object is injected with one of the read-only repository interfaces (`IReadOnlyRepository<...>` or `IReadOnlyBasicRepository<...>`). It won't work if you have injected a standard repository (e.g. `IRepository<...>`) then casted it to a read-only repository interface.
+
### Generic Repository without a Primary Key
If your entity does not have an Id primary key (it may have a composite primary key for instance) then you cannot use the `IRepository` (or basic/readonly versions) defined above. In that case, you can inject and use `IRepository` for your entity.
diff --git a/docs/en/UI/AspNetCore/Testing.md b/docs/en/UI/AspNetCore/Testing.md
index 2c880594d3..6efc967cb0 100644
--- a/docs/en/UI/AspNetCore/Testing.md
+++ b/docs/en/UI/AspNetCore/Testing.md
@@ -198,23 +198,10 @@ ABP Framework doesn't provide any infrastructure to test your JavaScript code. Y
> Volo.Abp.AspNetCore.TestBase package is already installed in the `.Web.Tests` project.
-This package provides the `AbpAspNetCoreIntegratedTestBase` as the fundamental base class to derive the test classes from. The `MyProjectWebTestBase` base class used above inherits from the `AbpAspNetCoreIntegratedTestBase`, so we indirectly inherited the `AbpAspNetCoreIntegratedTestBase`.
+This package provides the `AbpWebApplicationFactoryIntegratedTest` as the fundamental base class to derive the test classes from. It's inherited from the [WebApplicationFactory](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests) class provided by the ASP.NET Core.
-### Base Properties
-
-The `AbpAspNetCoreIntegratedTestBase` provides the following base properties those are used in the tests:
-
-* `Server`: A `TestServer` instance that hosts the web application in tests.
-* `Client`: An `HttpClient` instance that is configured to perform requests to the test server.
-* `ServiceProvider`: The service provider that you can resolve services in case of need.
-
-### Base Methods
-
-`AbpAspNetCoreIntegratedTestBase` provides the following methods that you can override if you need to customize the test server:
-
-* `ConfigureServices` can be overridden to register/replace services only for the derived test class.
-* `CreateHostBuilder` can be used to customize building the `IHostBuilder`.
+The `MyProjectWebTestBase` base class used above inherits from the `AbpWebApplicationFactoryIntegratedTest`, so we indirectly inherited the `AbpWebApplicationFactoryIntegratedTest`.
See Also
-
+* [Integration tests in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests)
* [Overall / Server Side Testing](../../Testing.md)
\ No newline at end of file
diff --git a/docs/zh-Hans/Getting-Started-Running-Solution.md b/docs/zh-Hans/Getting-Started-Running-Solution.md
index 8ecd85ec58..f0a4942d64 100644
--- a/docs/zh-Hans/Getting-Started-Running-Solution.md
+++ b/docs/zh-Hans/Getting-Started-Running-Solution.md
@@ -21,7 +21,7 @@
````json
"ConnectionStrings": {
- "Default": "Server=(LocalDb)\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
+ "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True"
}
````
diff --git a/docs/zh-Hans/UI/AspNetCore/Testing.md b/docs/zh-Hans/UI/AspNetCore/Testing.md
index e5b09353fb..1dfdbe367e 100644
--- a/docs/zh-Hans/UI/AspNetCore/Testing.md
+++ b/docs/zh-Hans/UI/AspNetCore/Testing.md
@@ -198,23 +198,10 @@ ABP框架不提供任何基础设施来测试JavaScript代码. 你可以使用
> Volo.Abp.AspNetCore.TestBase 已经安装在 `.Web.Tests` 项目中.
-此包提供的`AbpAspNetCoreIntegratedTestBase`作为派生测试类的基类. 上面使用的`MyProjectWebTestBase`继承自`AbpAspNetCoreIntegratedTestBase`, 因此我们间接继承了`AbpAspNetCoreIntegratedTestBase`.
-
-### 基本属性
-
-`AbpAspNetCoreIntegratedTestBase` 提供了测试中使用的以下基本属性:
-
-* `Server`: 在测试中托管web应用程序的`TestServer`实例.
-* `Client`: 为执行对测试服务器的请求配置`HttpClient`实例.
-* `ServiceProvider`: 可以在你需要时处理服务提供服务.
-
-### 基本方法
-
-`AbpAspNetCoreIntegratedTestBase` 提供了以下方法, 如果需要自定义测试服务器, 可以重写这些方法:
-
-* `ConfigureServices` 仅为派生测试类注册/替换服务时可以重写使用.
-* `CreateHostBuilder` 可用于自定义生成 `IHostBuilder`.
+此包提供的`AbpWebApplicationFactoryIntegratedTest`作为派生测试类的基类. 它继承自ASP.NET Core提供的[WebApplicationFactory](https://learn.microsoft.com/zh-cn/aspnet/core/test/integration-tests)类。
+上面使用的`MyProjectWebTestBase`继承自`AbpWebApplicationFactoryIntegratedTest`, 因此我们间接继承了`AbpWebApplicationFactoryIntegratedTest`.
另请参阅
+* [ASP.NET Core 中的集成测试](https://learn.microsoft.com/zh-cn/aspnet/core/test/integration-tests)
* [总览/服务器端测试](../../Testing.md)
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs
index b5866c5a68..24f68ef9ab 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/DaprAspNetCore/AbpDaprEndpointRouteBuilderExtensions.cs
@@ -30,7 +30,7 @@ namespace Dapr
///
/// An optional delegate used to configure the subscriptions.
///
- public Func, Task> SubscriptionsCallback { get; set; }
+ public Func, Task>? SubscriptionsCallback { get; set; }
}
///
@@ -41,32 +41,32 @@ namespace Dapr
///
/// Gets or sets the topic name.
///
- public string Topic { get; set; }
+ public string Topic { get; set; } = default!;
///
/// Gets or sets the pubsub name
///
- public string PubsubName { get; set; }
+ public string PubsubName { get; set; } = default!;
///
/// Gets or sets the route
///
- public string Route { get; set; }
+ public string? Route { get; set; }
///
/// Gets or sets the routes
///
- public AbpRoutes Routes { get; set; }
+ public AbpRoutes? Routes { get; set; }
///
/// Gets or sets the metadata.
///
- public AbpMetadata Metadata { get; set; }
+ public AbpMetadata? Metadata { get; set; }
///
/// Gets or sets the deadletter topic.
///
- public string DeadLetterTopic { get; set; }
+ public string? DeadLetterTopic { get; set; }
}
///
@@ -99,12 +99,12 @@ namespace Dapr
///
/// Gets or sets the default route
///
- public string Default { get; set; }
+ public string? Default { get; set; }
///
/// Gets or sets the routing rules
///
- public List Rules { get; set; }
+ public List? Rules { get; set; }
}
///
@@ -115,12 +115,12 @@ namespace Dapr
///
/// Gets or sets the CEL expression to match this route.
///
- public string Match { get; set; }
+ public string Match { get; set; } = default!;
///
/// Gets or sets the path of the route.
///
- public string Path { get; set; }
+ public string Path { get; set; } = default!;
}
}
@@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Builder
return CreateSubscribeEndPoint(endpoints, options);
}
- private static IEndpointConventionBuilder CreateSubscribeEndPoint(IEndpointRouteBuilder endpoints, AbpSubscribeOptions options = null)
+ private static IEndpointConventionBuilder CreateSubscribeEndPoint(IEndpointRouteBuilder endpoints, AbpSubscribeOptions? options = null)
{
if (endpoints is null)
{
@@ -175,7 +175,7 @@ namespace Microsoft.AspNetCore.Builder
return endpoints.MapGet("dapr/subscribe", async context =>
{
- var logger = context.RequestServices.GetRequiredService().CreateLogger("DaprTopicSubscription");
+ var logger = context.RequestServices.GetService()?.CreateLogger("DaprTopicSubscription");
var dataSource = context.RequestServices.GetRequiredService();
var subscriptions = dataSource.Endpoints
.OfType()
@@ -185,7 +185,7 @@ namespace Microsoft.AspNetCore.Builder
var topicMetadata = e.Metadata.GetOrderedMetadata();
var originalTopicMetadata = e.Metadata.GetOrderedMetadata();
- var subs = new List<(string PubsubName, string Name, string DeadLetterTopic, bool? EnableRawPayload, string Match, int Priority, Dictionary OriginalTopicMetadata, string MetadataSeparator, RoutePattern RoutePattern)>();
+ var subs = new List<(string PubsubName, string Name, string? DeadLetterTopic, bool? EnableRawPayload, string Match, int Priority, Dictionary OriginalTopicMetadata, string? MetadataSeparator, RoutePattern RoutePattern)>();
for (int i = 0; i < topicMetadata.Count(); i++)
{
@@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Builder
{
var first = e.First();
var rawPayload = e.Any(e => e.EnableRawPayload.GetValueOrDefault());
- var metadataSeparator = e.FirstOrDefault(e => !string.IsNullOrEmpty(e.MetadataSeparator)).MetadataSeparator ?? ",";
+ var metadataSeparator = e.FirstOrDefault(e => !string.IsNullOrEmpty(e.MetadataSeparator)).MetadataSeparator?.ToString() ?? ",";
var rules = e.Where(e => !string.IsNullOrEmpty(e.Match)).ToList();
var defaultRoutes = e.Where(e => string.IsNullOrEmpty(e.Match)).Select(e => RoutePatternToString(e.RoutePattern)).ToList();
var defaultRoute = defaultRoutes.FirstOrDefault();
@@ -276,7 +276,7 @@ namespace Microsoft.AspNetCore.Builder
.OrderBy(e => (e.PubsubName, e.Topic))
.ToList();
- await options?.SubscriptionsCallback(subscriptions);
+ await options?.SubscriptionsCallback!(subscriptions)!;
await context.Response.WriteAsync(JsonSerializer.Serialize(subscriptions,
new JsonSerializerOptions
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj
index f31ded0e06..96b196b67f 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ Nullable
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs
index b1d5bac7fb..946c39f59c 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus/Volo/Abp/AspNetCore/Mvc/Dapr/EventBus/Controllers/AbpAspNetCoreMvcDaprEventsController.cs
@@ -41,8 +41,8 @@ public class AbpAspNetCoreMvcDaprEventsController : AbpController
}
else
{
- var eventData = daprSerializer.Deserialize(data, distributedEventBus.GetEventType(topic));
- await distributedEventBus.TriggerHandlersAsync(distributedEventBus.GetEventType(topic), eventData);
+ var eventData = daprSerializer.Deserialize(data, distributedEventBus.GetEventType(topic!));
+ await distributedEventBus.TriggerHandlersAsync(distributedEventBus.GetEventType(topic!), eventData);
}
return Ok();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj
index 03bb453ba2..1839113d06 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo.Abp.AspNetCore.Mvc.Dapr.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ Nullable
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs
index dd0c6a5300..aa7d17072b 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprAppApiTokenValidator.cs
@@ -50,9 +50,9 @@ public class DaprAppApiTokenValidator : IDaprAppApiTokenValidator, ISingletonDep
return expectedAppApiToken == headerAppApiToken;
}
- public virtual string GetDaprAppApiTokenOrNull()
+ public virtual string? GetDaprAppApiTokenOrNull()
{
- string apiTokenHeader = HttpContext.Request.Headers["dapr-api-token"];
+ string? apiTokenHeader = HttpContext.Request.Headers["dapr-api-token"];
if (string.IsNullOrEmpty(apiTokenHeader) || apiTokenHeader.Length < 1)
{
return null;
@@ -61,7 +61,7 @@ public class DaprAppApiTokenValidator : IDaprAppApiTokenValidator, ISingletonDep
return apiTokenHeader;
}
- protected virtual string GetConfiguredAppApiTokenOrNull()
+ protected virtual string? GetConfiguredAppApiTokenOrNull()
{
return HttpContext
.RequestServices
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs
index aa81765b12..e73eaec4f7 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/DaprHttpContextExtensions.cs
@@ -22,7 +22,7 @@ public static class DaprHttpContextExtensions
.IsValidDaprAppApiToken();
}
- public static string GetDaprAppApiTokenOrNull(HttpContext httpContext)
+ public static string? GetDaprAppApiTokenOrNull(HttpContext httpContext)
{
return httpContext
.RequestServices
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs
index 66fd833b77..f54f0aa8cf 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Dapr/Volo/Abp/AspNetCore/Mvc/Dapr/IDaprAppApiTokenValidator.cs
@@ -6,5 +6,5 @@ public interface IDaprAppApiTokenValidator
bool IsValidDaprAppApiToken();
- string GetDaprAppApiTokenOrNull();
+ string? GetDaprAppApiTokenOrNull();
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
index 9e3b0bfba2..f1d014b76a 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
@@ -145,7 +145,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide
ActionApiDescriptionModel.Create(
uniqueMethodName,
method,
- apiDescription.RelativePath,
+ apiDescription.RelativePath!,
apiDescription.HttpMethod,
GetSupportedVersions(controllerType, method, setting),
allowAnonymous,
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/Metadata/AbpModelMetadataProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/Metadata/AbpModelMetadataProvider.cs
index 8d5f2d4c4a..1301a5e823 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/Metadata/AbpModelMetadataProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/Metadata/AbpModelMetadataProvider.cs
@@ -40,11 +40,11 @@ public class AbpModelMetadataProvider : DefaultModelMetadataProvider
{
foreach (var validationAttribute in detail.ModelAttributes.Attributes.OfType())
{
- NormalizeValidationAttrbute(validationAttribute);
+ NormalizeValidationAttribute(validationAttribute);
}
}
- protected virtual void NormalizeValidationAttrbute(ValidationAttribute validationAttribute)
+ protected virtual void NormalizeValidationAttribute(ValidationAttribute validationAttribute)
{
if (validationAttribute.ErrorMessage == null)
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs
index b912d3905a..d4fd27d889 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs
@@ -32,7 +32,7 @@ public class ServiceProxyGenerationModel
public ProxyScriptingModel CreateOptions()
{
- var options = new ProxyScriptingModel(Type, UseCache);
+ var options = new ProxyScriptingModel(Type!, UseCache);
if (!Modules.IsNullOrEmpty())
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs
index 505c07a3e1..cd87c55ea4 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs
@@ -1,14 +1,15 @@
-using System.ComponentModel.DataAnnotations;
+using System;
+using System.ComponentModel.DataAnnotations;
using System.Reflection;
namespace Volo.Abp.AspNetCore.Mvc.Validation;
public static class ValidationAttributeHelper
{
- private static readonly PropertyInfo ValidationAttributeErrorMessageStringProperty = typeof(ValidationAttribute)
+ private readonly static PropertyInfo ValidationAttributeErrorMessageStringProperty = typeof(ValidationAttribute)
.GetProperty("ErrorMessageString", BindingFlags.Instance | BindingFlags.NonPublic)!;
- private static readonly PropertyInfo ValidationAttributeCustomErrorMessageSetProperty = typeof(ValidationAttribute)
+ private readonly static PropertyInfo ValidationAttributeCustomErrorMessageSetProperty = typeof(ValidationAttribute)
.GetProperty("CustomErrorMessageSet", BindingFlags.Instance | BindingFlags.NonPublic)!;
public static void SetDefaultErrorMessage(ValidationAttribute validationAttribute)
@@ -24,7 +25,14 @@ public static class ValidationAttributeHelper
}
}
- validationAttribute.ErrorMessage =
- ValidationAttributeErrorMessageStringProperty.GetValue(validationAttribute) as string;
+ try
+ {
+ var errorMessageString = ValidationAttributeErrorMessageStringProperty.GetValue(validationAttribute) as string;
+ validationAttribute.ErrorMessage = errorMessageString;
+ }
+ catch (Exception e)
+ {
+ // ignored
+ }
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo.Abp.AspNetCore.TestBase.csproj b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo.Abp.AspNetCore.TestBase.csproj
index a6f6a55f39..5bf1cc54aa 100644
--- a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo.Abp.AspNetCore.TestBase.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo.Abp.AspNetCore.TestBase.csproj
@@ -28,6 +28,7 @@
+
diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreAsyncIntegratedTestBase.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreAsyncIntegratedTestBase.cs
index 8892623364..e6c49d475c 100644
--- a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreAsyncIntegratedTestBase.cs
+++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreAsyncIntegratedTestBase.cs
@@ -13,6 +13,7 @@ using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.TestBase;
+[Obsolete("Use AbpWebApplicationFactoryIntegratedTest instead.")]
public class AbpAspNetCoreAsyncIntegratedTestBase
where TModule : IAbpModule
{
diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs
index c362d5074c..731b21ea03 100644
--- a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs
+++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpAspNetCoreIntegratedTestBase.cs
@@ -14,6 +14,7 @@ namespace Volo.Abp.AspNetCore.TestBase;
///
/// Can be a module type or old-style ASP.NET Core Startup class.
///
+[Obsolete("Use AbpWebApplicationFactoryIntegratedTest instead.")]
public abstract class AbpAspNetCoreIntegratedTestBase : AbpTestBaseWithServiceProvider, IDisposable
where TStartupModule : class
{
@@ -51,7 +52,7 @@ public abstract class AbpAspNetCoreIntegratedTestBase : AbpTestB
{
webBuilder.UseStartup();
}
-
+
webBuilder.UseAbpTestServer();
})
.UseAutofac()
diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs
new file mode 100644
index 0000000000..c7b5f48ebe
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs
@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using Microsoft.AspNetCore.Mvc.Testing;
+using Microsoft.AspNetCore.Routing;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+
+namespace Volo.Abp.AspNetCore.TestBase;
+
+public abstract class AbpWebApplicationFactoryIntegratedTest : WebApplicationFactory
+ where TProgram : class
+{
+ protected HttpClient Client { get; set; }
+
+ protected IServiceProvider ServiceProvider => Services;
+
+ protected AbpWebApplicationFactoryIntegratedTest()
+ {
+ Client = CreateClient(new WebApplicationFactoryClientOptions
+ {
+ AllowAutoRedirect = false
+ });
+ ServiceProvider.GetRequiredService().Server = Server;
+ }
+
+ protected override IHost CreateHost(IHostBuilder builder)
+ {
+ builder.ConfigureServices(ConfigureServices);
+ return base.CreateHost(builder);
+ }
+
+ protected virtual T? GetService()
+ {
+ return Services.GetService();
+ }
+
+ protected virtual T GetRequiredService() where T : notnull
+ {
+ return Services.GetRequiredService();
+ }
+
+ protected virtual void ConfigureServices(IServiceCollection services)
+ {
+
+ }
+
+ #region GetUrl
+
+ ///
+ /// Gets default URL for given controller type.
+ ///
+ /// The type of the controller.
+ protected virtual string GetUrl()
+ {
+ return "/" + typeof(TController).Name.RemovePostFix("Controller", "AppService", "ApplicationService", "IntService", "IntegrationService", "Service");
+ }
+
+ ///
+ /// Gets default URL for given controller type's given action.
+ ///
+ /// The type of the controller.
+ protected virtual string GetUrl(string actionName)
+ {
+ return GetUrl() + "/" + actionName;
+ }
+
+ ///
+ /// Gets default URL for given controller type's given action with query string parameters (as anonymous object).
+ ///
+ /// The type of the controller.
+ protected virtual string GetUrl(string actionName, object queryStringParamsAsAnonymousObject)
+ {
+ var url = GetUrl(actionName);
+
+ var dictionary = new RouteValueDictionary(queryStringParamsAsAnonymousObject);
+ if (dictionary.Any())
+ {
+ url += "?" + dictionary.Select(d => $"{d.Key}={d.Value}").JoinAsString("&");
+ }
+
+ return url;
+ }
+
+ #endregion
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs
new file mode 100644
index 0000000000..403bbac7b1
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Volo.Abp.Modularity;
+
+namespace Volo.Abp.AspNetCore.TestBase;
+
+public static class WebApplicationBuilderExtensions
+{
+ public async static Task RunAbpModuleAsync(this WebApplicationBuilder builder, Action? optionsAction = null)
+ where TModule : IAbpModule
+ {
+ var assemblyName = typeof(TModule).Assembly.GetName()?.Name;
+ if (!assemblyName.IsNullOrWhiteSpace())
+ {
+ // Set the application name as the assembly name of the module will automatically add assembly to the ApplicationParts of MVC application.
+ builder.Environment.ApplicationName = assemblyName!;
+ }
+ builder.Host.UseAutofac();
+ await builder.AddApplicationAsync(optionsAction);
+ var app = builder.Build();
+ await app.InitializeApplicationAsync();
+ await app.RunAsync();
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs
index 83deaef26a..0c797a8dc2 100644
--- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs
+++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs
@@ -98,13 +98,13 @@ public class AbpAuditingMiddleware : IMiddleware, ITransientDependency
{
return false;
}
-
- if (!AuditingOptions.IsEnabledForIntegrationServices &&
+
+ if (!AuditingOptions.IsEnabledForIntegrationServices &&
context.Request.Path.Value.StartsWith($"/{AbpAspNetCoreConsts.DefaultIntegrationServiceApiPrefix}/"))
{
return true;
}
-
+
if (AspNetCoreAuditingOptions.IgnoredUrls.Any(x => context.Request.Path.Value.StartsWith(x)))
{
return true;
@@ -134,7 +134,8 @@ public class AbpAuditingMiddleware : IMiddleware, ITransientDependency
}
if (!AuditingOptions.IsEnabledForGetRequests &&
- string.Equals(httpContext.Request.Method, HttpMethods.Get, StringComparison.OrdinalIgnoreCase))
+ (string.Equals(httpContext.Request.Method, HttpMethods.Get, StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(httpContext.Request.Method, HttpMethods.Head, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditLogScope.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditLogScope.cs
index 8e9f14e976..e3e8f22d0a 100644
--- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditLogScope.cs
+++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditLogScope.cs
@@ -1,9 +1,6 @@
-using JetBrains.Annotations;
-
-namespace Volo.Abp.Auditing;
+namespace Volo.Abp.Auditing;
public interface IAuditLogScope
{
- [NotNull]
AuditLogInfo Log { get; }
}
diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs
index a1091b8600..c496a22340 100644
--- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs
+++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs
@@ -1,6 +1,4 @@
-using JetBrains.Annotations;
-
-namespace Volo.Abp.Auditing;
+namespace Volo.Abp.Auditing;
public interface IAuditingManager
{
diff --git a/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs b/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleObjectExtensions.cs
similarity index 96%
rename from framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs
rename to framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleObjectExtensions.cs
index 58047f575d..ea746500d6 100644
--- a/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs
+++ b/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleObjectExtensions.cs
@@ -1,12 +1,11 @@
using System.Collections.Generic;
-using Volo.Abp;
using Volo.Abp.AutoMapper;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
namespace AutoMapper;
-public static class AbpAutoMapperExtensibleDtoExtensions
+public static class AbpAutoMapperExtensibleObjectExtensions
{
public static IMappingExpression MapExtraProperties(
this IMappingExpression mappingExpression,
diff --git a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/AzureServiceBusMessageConsumerFactory.cs b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/AzureServiceBusMessageConsumerFactory.cs
index 04c7b48c6a..cf92ed7b73 100644
--- a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/AzureServiceBusMessageConsumerFactory.cs
+++ b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/AzureServiceBusMessageConsumerFactory.cs
@@ -14,7 +14,7 @@ public class AzureServiceBusMessageConsumerFactory : IAzureServiceBusMessageCons
ServiceScope = serviceScopeFactory.CreateScope();
}
- public IAzureServiceBusMessageConsumer CreateMessageConsumer(string topicName, string subscriptionName, string connectionName)
+ public IAzureServiceBusMessageConsumer CreateMessageConsumer(string topicName, string subscriptionName, string? connectionName)
{
var processor = ServiceScope.ServiceProvider.GetRequiredService();
processor.Initialize(topicName, subscriptionName, connectionName);
diff --git a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/ConnectionPool.cs b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/ConnectionPool.cs
index d616e1264f..df830cde7a 100644
--- a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/ConnectionPool.cs
+++ b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/ConnectionPool.cs
@@ -28,7 +28,7 @@ public class ConnectionPool : IConnectionPool, ISingletonDependency
Logger = new NullLogger();
}
- public ServiceBusClient GetClient(string connectionName)
+ public ServiceBusClient GetClient(string? connectionName)
{
connectionName ??= AzureServiceBusConnections.DefaultConnectionName;
return _clients.GetOrAdd(
@@ -40,7 +40,7 @@ public class ConnectionPool : IConnectionPool, ISingletonDependency
).Value;
}
- public ServiceBusAdministrationClient GetAdministrationClient(string connectionName)
+ public ServiceBusAdministrationClient GetAdministrationClient(string? connectionName)
{
connectionName ??= AzureServiceBusConnections.DefaultConnectionName;
return _adminClients.GetOrAdd(
diff --git a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IAzureServiceBusMessageConsumerFactory.cs b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IAzureServiceBusMessageConsumerFactory.cs
index bd770e2204..4d93bcf5c3 100644
--- a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IAzureServiceBusMessageConsumerFactory.cs
+++ b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IAzureServiceBusMessageConsumerFactory.cs
@@ -16,5 +16,5 @@ public interface IAzureServiceBusMessageConsumerFactory
IAzureServiceBusMessageConsumer CreateMessageConsumer(
string topicName,
string subscriptionName,
- string connectionName);
+ string? connectionName);
}
diff --git a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IConnectionPool.cs b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IConnectionPool.cs
index a4cdfbc122..825c981a00 100644
--- a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IConnectionPool.cs
+++ b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IConnectionPool.cs
@@ -6,7 +6,7 @@ namespace Volo.Abp.AzureServiceBus;
public interface IConnectionPool : IAsyncDisposable
{
- ServiceBusClient GetClient(string connectionName);
+ ServiceBusClient GetClient(string? connectionName);
- ServiceBusAdministrationClient GetAdministrationClient(string connectionName);
+ ServiceBusAdministrationClient GetAdministrationClient(string? connectionName);
}
diff --git a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IPublisherPool.cs b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IPublisherPool.cs
index 4940d250dd..bb0bf8e827 100644
--- a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IPublisherPool.cs
+++ b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/IPublisherPool.cs
@@ -6,5 +6,5 @@ namespace Volo.Abp.AzureServiceBus;
public interface IPublisherPool : IAsyncDisposable
{
- Task GetAsync(string topicName, string connectionName);
+ Task GetAsync(string topicName, string? connectionName);
}
diff --git a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/PublisherPool.cs b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/PublisherPool.cs
index 45b025cc59..a10c63868d 100644
--- a/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/PublisherPool.cs
+++ b/framework/src/Volo.Abp.AzureServiceBus/Volo/Abp/AzureServiceBus/PublisherPool.cs
@@ -24,7 +24,7 @@ public class PublisherPool : IPublisherPool, ISingletonDependency
Logger = new NullLogger();
}
- public async Task GetAsync(string topicName, string connectionName)
+ public async Task GetAsync(string topicName, string? connectionName)
{
var admin = _connectionPool.GetAdministrationClient(connectionName);
await admin.SetupTopicAsync(topicName);
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
index 676b42081f..a672b0b563 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
@@ -98,6 +98,7 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien
Logger.LogInformation($"'{projectName}' has been successfully created to '{projectArgs.OutputFolder}'");
ConfigureNpmPackagesForTheme(projectArgs);
+ await CreateOpenIddictPfxFilesAsync(projectArgs);
await RunGraphBuildForMicroserviceServiceTemplate(projectArgs);
await CreateInitialMigrationsAsync(projectArgs);
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs
index 3e83cd818d..cf697fd899 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs
@@ -16,6 +16,7 @@ using Volo.Abp.Cli.LIbs;
using Volo.Abp.Cli.ProjectBuilding;
using Volo.Abp.Cli.ProjectBuilding.Building;
using Volo.Abp.Cli.ProjectBuilding.Events;
+using Volo.Abp.Cli.ProjectBuilding.Templates;
using Volo.Abp.Cli.ProjectBuilding.Templates.App;
using Volo.Abp.Cli.ProjectBuilding.Templates.Microservice;
using Volo.Abp.Cli.ProjectBuilding.Templates.Module;
@@ -481,6 +482,36 @@ public abstract class ProjectCreationCommandBase
await InitialMigrationCreator.CreateAsync(Path.GetDirectoryName(efCoreProjectPath), isLayeredTemplate);
}
+ protected Task CreateOpenIddictPfxFilesAsync(ProjectBuildArgs projectArgs)
+ {
+ var module = projectArgs.ExtraProperties[nameof(RandomizeAuthServerPassPhraseStep)];
+ if (string.IsNullOrWhiteSpace(module))
+ {
+ return Task.CompletedTask;
+ }
+
+ var moduleDirectory = projectArgs.OutputFolder + module;
+ if (projectArgs.UiFramework != UiFramework.Angular)
+ {
+ moduleDirectory = moduleDirectory.Replace("/aspnet-core/", "/");
+ }
+
+ moduleDirectory = Path.GetDirectoryName(projectArgs.SolutionName.CompanyName == null
+ ? moduleDirectory.Replace("MyCompanyName.MyProjectName", projectArgs.SolutionName.ProjectName)
+ : moduleDirectory.Replace("MyCompanyName", projectArgs.SolutionName.CompanyName).Replace("MyProjectName", projectArgs.SolutionName.ProjectName));
+
+ if (Directory.Exists(moduleDirectory))
+ {
+ Logger.LogInformation($"Creating openiddict.pfx file on {moduleDirectory}");
+ CmdHelper.RunCmd($"dotnet dev-certs https -ep openiddict.pfx -p {RandomizeAuthServerPassPhraseStep.RandomOpenIddictPassword}", moduleDirectory);
+ }
+ else
+ {
+ Logger.LogWarning($"Couldn't find the module directory to create openiddict.pfx file: {moduleDirectory}");
+ }
+ return Task.CompletedTask;
+ }
+
protected async Task ConfigurePwaSupportForAngular(ProjectBuildArgs projectArgs)
{
var isAngular = projectArgs.UiFramework == UiFramework.Angular;
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/RandomizeAuthServerPassPhraseStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/RandomizeAuthServerPassPhraseStep.cs
index 7d42977c97..a41c870f41 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/RandomizeAuthServerPassPhraseStep.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/RandomizeAuthServerPassPhraseStep.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Linq;
using Volo.Abp.Cli.ProjectBuilding.Building;
@@ -6,16 +7,30 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates;
public class RandomizeAuthServerPassPhraseStep : ProjectBuildPipelineStep
{
- protected const string DefaultPassPhrase = "00000000-0000-0000-0000-000000000000";
+ private const string DefaultPassword = "00000000-0000-0000-0000-000000000000";
+ private const string KestrelCertificatesDefaultPassword = "Kestrel__Certificates__Default__Password=00000000-0000-0000-0000-000000000000";
+ private const string LocalhostPfx = "localhost.pfx -p 00000000-0000-0000-0000-000000000000";
+ private const string DotnetDevCerts = "openiddict.pfx -p 00000000-0000-0000-0000-000000000000";
+ private const string ProductionEncryptionAndSigningCertificate = "AddProductionEncryptionAndSigningCertificate(\"openiddict.pfx\", \"00000000-0000-0000-0000-000000000000\");";
+ private readonly static string RandomPassword = Guid.NewGuid().ToString("D");
+ public readonly static string RandomOpenIddictPassword = Guid.NewGuid().ToString("D");
public override void Execute(ProjectBuildContext context)
{
var files = context.Files
.Where(x => !x.IsDirectory)
- .Where(x => x.Content.IndexOf(DefaultPassPhrase, StringComparison.InvariantCultureIgnoreCase) >= 0)
+ .Where(x => x.Name.EndsWith(".cs") ||
+ x.Name.EndsWith(".json") ||
+ x.Name.EndsWith(".yml") ||
+ x.Name.EndsWith(".yaml") ||
+ x.Name.EndsWith(".md") ||
+ x.Name.EndsWith(".ps1") ||
+ x.Name.EndsWith(".sh") ||
+ x.Name.Contains("Dockerfile"))
+ .Where(x => x.Content.IndexOf(DefaultPassword, StringComparison.InvariantCultureIgnoreCase) >= 0)
.ToList();
- var randomPassPhrase = Guid.NewGuid().ToString("D");
+ string module = null;
foreach (var file in files)
{
file.NormalizeLineEndings();
@@ -23,13 +38,43 @@ public class RandomizeAuthServerPassPhraseStep : ProjectBuildPipelineStep
var lines = file.GetLines();
for (var i = 0; i < lines.Length; i++)
{
- if (lines[i].Contains(DefaultPassPhrase))
+ if (lines[i].Contains(KestrelCertificatesDefaultPassword))
{
- lines[i] = lines[i].Replace(DefaultPassPhrase, randomPassPhrase);
+ lines[i] = lines[i].Replace(KestrelCertificatesDefaultPassword,
+ KestrelCertificatesDefaultPassword.Replace(DefaultPassword,
+ RandomPassword));
+ }
+
+ if (lines[i].Contains(LocalhostPfx))
+ {
+ lines[i] = lines[i].Replace(LocalhostPfx,
+ LocalhostPfx.Replace(DefaultPassword,
+ RandomPassword));
+ }
+
+ if (lines[i].Contains(DotnetDevCerts))
+ {
+ lines[i] = lines[i].Replace(DotnetDevCerts,
+ DotnetDevCerts.Replace(DefaultPassword,
+ RandomOpenIddictPassword));
+ }
+
+ if (lines[i].Contains(ProductionEncryptionAndSigningCertificate))
+ {
+ lines[i] = lines[i].Replace(ProductionEncryptionAndSigningCertificate,
+ ProductionEncryptionAndSigningCertificate.Replace(DefaultPassword,
+ RandomOpenIddictPassword));
+
+ module = file.Name;
}
}
file.SetLines(lines);
}
+
+ if (!module.IsNullOrWhiteSpace())
+ {
+ context.BuildArgs.ExtraProperties[nameof(RandomizeAuthServerPassPhraseStep)] = module;
+ }
}
}
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 535b68ef59..ba85c48aeb 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
@@ -22,6 +22,7 @@ using Volo.Abp.Cli.Utils;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Local;
using Volo.Abp.Json;
+using System.Text.RegularExpressions;
namespace Volo.Abp.Cli.ProjectModification;
@@ -114,12 +115,11 @@ public class SolutionModuleAdder : ITransientDependency
var projectFiles = ProjectFinder.GetProjectFiles(solutionFile);
await AddNugetAndNpmReferences(module, projectFiles, !(newTemplate || newProTemplate));
-
+
var modulesFolderInSolution = Path.Combine(Path.GetDirectoryName(solutionFile), "modules");
if (withSourceCode || newTemplate || newProTemplate)
{
-
await PublishEventAsync(5, $"Downloading source code of {moduleName}");
await DownloadSourceCodesToSolutionFolder(module, modulesFolderInSolution, version, newTemplate, newProTemplate);
@@ -147,6 +147,8 @@ public class SolutionModuleAdder : ITransientDependency
else
{
await AddAngularPackages(solutionFile, module);
+
+ await TryConfigureModuleConfigurationsForAngular(solutionFile, module);
}
await RunBundleForBlazorAsync(projectFiles, module);
@@ -167,10 +169,83 @@ public class SolutionModuleAdder : ITransientDependency
return module;
}
+ private async Task TryConfigureModuleConfigurationsForAngular(string solutionFilePath, ModuleWithMastersInfo module)
+ {
+ var angularPath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(solutionFilePath)), "angular");
+
+ if (!Directory.Exists(angularPath))
+ {
+ return;
+ }
+
+ var angularPackages = module.NpmPackages?
+ .Where(p => p.ApplicationType.HasFlag(NpmApplicationType.Angular))
+ .ToList();
+
+ if (!angularPackages.Any())
+ {
+ return;
+ }
+
+ await PublishEventAsync(6, "Configuring angular projects...");
+
+ var moduleName = module.Name.Split('.').Last();
+
+ ConfigureAngularPackagesForAppModuleFile(angularPath, angularPackages, moduleName);
+
+ ConfigureAngularPackagesForAppRoutingModuleFile(angularPath, angularPackages, moduleName);
+ }
+
+ private void ConfigureAngularPackagesForAppModuleFile(string angularPath, List angularPackages, string moduleName)
+ {
+ var appModulePath = Path.Combine(angularPath, "src", "app", "app.module.ts");
+ if (!File.Exists(appModulePath))
+ {
+ return;
+ }
+
+ var appModuleFileContent = File.ReadAllText(appModulePath);
+
+ foreach (var angularPackage in angularPackages)
+ {
+ var moduleNameAsConfigPath = angularPackage.Name.EnsureStartsWith('@').EnsureEndsWith('/') + "config";
+
+ appModuleFileContent = "import { " + moduleName + "ConfigModule } from '" + moduleNameAsConfigPath + "';" + Environment.NewLine + appModuleFileContent;
+ appModuleFileContent = Regex.Replace(appModuleFileContent, "imports\\s*:\\s*\\[",
+ "imports: [" + Environment.NewLine +
+ " " + moduleName + "ConfigModule.forRoot(),");
+ }
+
+ File.WriteAllText(appModulePath, appModuleFileContent);
+ }
+
+ private void ConfigureAngularPackagesForAppRoutingModuleFile(string angularPath, List angularPackages, string moduleName)
+ {
+ var appRoutingModulePath = Path.Combine(angularPath, "src", "app", "app-routing.module.ts");
+ if (!File.Exists(appRoutingModulePath))
+ {
+ return;
+ }
+
+ var appRoutingModuleFileContent = File.ReadAllText(appRoutingModulePath);
+
+ foreach (var angularPackage in angularPackages)
+ {
+ appRoutingModuleFileContent = Regex.Replace(appRoutingModuleFileContent, "Routes\\s*=\\s*\\[",
+ "Routes = [" + Environment.NewLine +
+ " " + "{" + Environment.NewLine +
+ " " + "path: '" + moduleName.ToLower() + "'," + Environment.NewLine +
+ " " + "loadChildren: () => " + $"import('{angularPackage.Name.EnsureStartsWith('@')}').then(m => m.{moduleName}Module.forLazy())," + Environment.NewLine +
+ " " + "},");
+ }
+
+ File.WriteAllText(appRoutingModulePath, appRoutingModuleFileContent);
+ }
+
private async Task SetLeptonXAbpVersionsAsync(string solutionFile, string combine)
{
var abpVersion = SolutionPackageVersionFinder.FindByCsprojVersion(solutionFile);
-
+
var projects = Directory.GetFiles(Path.GetDirectoryName(solutionFile)!, "*.csproj", SearchOption.AllDirectories);
foreach (var project in projects)
@@ -183,7 +258,8 @@ public class SolutionModuleAdder : ITransientDependency
private async Task PublishEventAsync(int currentStep, string message)
{
- await LocalEventBus.PublishAsync(new ModuleInstallingProgressEvent {
+ await LocalEventBus.PublishAsync(new ModuleInstallingProgressEvent
+ {
CurrentStep = currentStep,
Message = message
}, false);
@@ -562,7 +638,7 @@ public class SolutionModuleAdder : ITransientDependency
if (webPackagesWillBeAddedToBlazorServerProject)
{
- if ( nugetTarget == NuGetPackageTarget.Web)
+ if (nugetTarget == NuGetPackageTarget.Web)
{
nugetTarget = NuGetPackageTarget.BlazorServer;
}
@@ -636,7 +712,7 @@ public class SolutionModuleAdder : ITransientDependency
}
var dbMigrationsProject = projectFiles.FirstOrDefault(p => p.EndsWith(".DbMigrations.csproj"))
- ?? projectFiles.FirstOrDefault(p => p.EndsWith(".EntityFrameworkCore.csproj")) ;
+ ?? projectFiles.FirstOrDefault(p => p.EndsWith(".EntityFrameworkCore.csproj"));
if (dbMigrationsProject == null)
{
diff --git a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
index c7153264ae..3d44fa988a 100644
--- a/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/AbpStringExtensions.cs
@@ -47,7 +47,7 @@ public static class AbpStringExtensions
/// Indicates whether this string is null or an System.String.Empty string.
///
[ContractAnnotation("str:null => true")]
- public static bool IsNullOrEmpty(this string? str)
+ public static bool IsNullOrEmpty([System.Diagnostics.CodeAnalysis.NotNullWhen(false)]this string? str)
{
return string.IsNullOrEmpty(str);
}
@@ -56,7 +56,7 @@ public static class AbpStringExtensions
/// indicates whether this string is null, empty, or consists only of white-space characters.
///
[ContractAnnotation("str:null => true")]
- public static bool IsNullOrWhiteSpace(this string? str)
+ public static bool IsNullOrWhiteSpace([System.Diagnostics.CodeAnalysis.NotNullWhen(false)]this string? str)
{
return string.IsNullOrWhiteSpace(str);
}
diff --git a/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj b/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj
index c250d07eee..9709051409 100644
--- a/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj
+++ b/framework/src/Volo.Abp.Core/Volo.Abp.Core.csproj
@@ -37,4 +37,10 @@
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs
index 8602792701..3791c4202f 100644
--- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs
+++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs
@@ -132,7 +132,7 @@ public abstract class AbstractKeyReadOnlyAppService ((IHasCreationTime)e).CreationTime);
}
- throw new AbpException("No sorting specified but this query requires sorting. Override the ApplyDefaultSorting method for your application service derived from AbstractKeyReadOnlyAppService!");
+ throw new AbpException("No sorting specified but this query requires sorting. Override the ApplySorting or the ApplyDefaultSorting method for your application service derived from AbstractKeyReadOnlyAppService!");
}
///
diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs
index ba82e5bdc2..f0d23fa865 100644
--- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs
+++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs
@@ -1,4 +1,3 @@
-using JetBrains.Annotations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs b/framework/src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs
index c63a5442c7..a877c673f1 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Microsoft/Extensions/DependencyInjection/ServiceCollectionRepositoryExtensions.cs
@@ -1,5 +1,6 @@
using System;
using Microsoft.Extensions.DependencyInjection.Extensions;
+using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
@@ -17,13 +18,13 @@ public static class ServiceCollectionRepositoryExtensions
var readOnlyBasicRepositoryInterface = typeof(IReadOnlyBasicRepository<>).MakeGenericType(entityType);
if (readOnlyBasicRepositoryInterface.IsAssignableFrom(repositoryImplementationType))
{
- RegisterService(services, readOnlyBasicRepositoryInterface, repositoryImplementationType, replaceExisting);
+ RegisterService(services, readOnlyBasicRepositoryInterface, repositoryImplementationType, replaceExisting, true);
//IReadOnlyRepository
var readOnlyRepositoryInterface = typeof(IReadOnlyRepository<>).MakeGenericType(entityType);
if (readOnlyRepositoryInterface.IsAssignableFrom(repositoryImplementationType))
{
- RegisterService(services, readOnlyRepositoryInterface, repositoryImplementationType, replaceExisting);
+ RegisterService(services, readOnlyRepositoryInterface, repositoryImplementationType, replaceExisting, true);
}
//IBasicRepository
@@ -48,13 +49,13 @@ public static class ServiceCollectionRepositoryExtensions
var readOnlyBasicRepositoryInterfaceWithPk = typeof(IReadOnlyBasicRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (readOnlyBasicRepositoryInterfaceWithPk.IsAssignableFrom(repositoryImplementationType))
{
- RegisterService(services, readOnlyBasicRepositoryInterfaceWithPk, repositoryImplementationType, replaceExisting);
+ RegisterService(services, readOnlyBasicRepositoryInterfaceWithPk, repositoryImplementationType, replaceExisting, true);
//IReadOnlyRepository
var readOnlyRepositoryInterfaceWithPk = typeof(IReadOnlyRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (readOnlyRepositoryInterfaceWithPk.IsAssignableFrom(repositoryImplementationType))
{
- RegisterService(services, readOnlyRepositoryInterfaceWithPk, repositoryImplementationType, replaceExisting);
+ RegisterService(services, readOnlyRepositoryInterfaceWithPk, repositoryImplementationType, replaceExisting, true);
}
//IBasicRepository
@@ -80,15 +81,33 @@ public static class ServiceCollectionRepositoryExtensions
IServiceCollection services,
Type serviceType,
Type implementationType,
- bool replaceExisting)
+ bool replaceExisting,
+ bool isReadOnlyRepository = false)
{
+ ServiceDescriptor descriptor;
+
+ if (isReadOnlyRepository)
+ {
+ services.TryAddTransient(implementationType);
+ descriptor = ServiceDescriptor.Transient(serviceType, provider =>
+ {
+ var repository = provider.GetRequiredService(implementationType);
+ ObjectHelper.TrySetProperty(repository.As(), x => x.IsChangeTrackingEnabled, _ => false);
+ return repository;
+ });
+ }
+ else
+ {
+ descriptor = ServiceDescriptor.Transient(serviceType, implementationType);
+ }
+
if (replaceExisting)
{
- services.Replace(ServiceDescriptor.Transient(serviceType, implementationType));
+ services.Replace(descriptor);
}
else
{
- services.TryAddTransient(serviceType, implementationType);
+ services.TryAdd(descriptor);
}
}
}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/AbpDddDomainModule.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/AbpDddDomainModule.cs
index 536e31e51f..de6632704d 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/AbpDddDomainModule.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/AbpDddDomainModule.cs
@@ -2,6 +2,7 @@
using Volo.Abp.Auditing;
using Volo.Abp.Caching;
using Volo.Abp.Data;
+using Volo.Abp.Domain.ChangeTracking;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus;
using Volo.Abp.ExceptionHandling;
@@ -30,5 +31,6 @@ public class AbpDddDomainModule : AbpModule
public override void PreConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddConventionalRegistrar(new AbpRepositoryConventionalRegistrar());
+ context.Services.OnRegistered(ChangeTrackingInterceptorRegistrar.RegisterIfNeeded);
}
}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingHelper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingHelper.cs
new file mode 100644
index 0000000000..d2235afd22
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingHelper.cs
@@ -0,0 +1,53 @@
+using System.Linq;
+using System.Reflection;
+using JetBrains.Annotations;
+using Volo.Abp.Domain.Repositories;
+
+namespace Volo.Abp.Domain.ChangeTracking;
+
+public static class ChangeTrackingHelper
+{
+ public static bool IsEntityChangeTrackingType(TypeInfo implementationType)
+ {
+ return HasEntityChangeTrackingAttribute(implementationType) || AnyMethodHasEntityChangeTrackingAttribute(implementationType);
+ }
+
+ public static bool IsEntityChangeTrackingMethod([NotNull] MethodInfo methodInfo, out EntityChangeTrackingAttribute? entityChangeTrackingAttribute)
+ {
+ Check.NotNull(methodInfo, nameof(methodInfo));
+
+ //Method declaration
+ var attrs = methodInfo.GetCustomAttributes(true).OfType().ToArray();
+ if (attrs.Any())
+ {
+ entityChangeTrackingAttribute = attrs.First();
+ return true;
+ }
+
+ if (methodInfo.DeclaringType != null)
+ {
+ //Class declaration
+ attrs = methodInfo.DeclaringType.GetTypeInfo().GetCustomAttributes(true).OfType().ToArray();
+ if (attrs.Any())
+ {
+ entityChangeTrackingAttribute = attrs.First();
+ return true;
+ }
+ }
+
+ entityChangeTrackingAttribute = null;
+ return false;
+ }
+
+ private static bool AnyMethodHasEntityChangeTrackingAttribute(TypeInfo implementationType)
+ {
+ return implementationType
+ .GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
+ .Any(HasEntityChangeTrackingAttribute);
+ }
+
+ private static bool HasEntityChangeTrackingAttribute(MemberInfo memberInfo)
+ {
+ return memberInfo.IsDefined(typeof(EntityChangeTrackingAttribute), true);
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingInterceptor.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingInterceptor.cs
new file mode 100644
index 0000000000..307e2dee6a
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingInterceptor.cs
@@ -0,0 +1,30 @@
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.DynamicProxy;
+
+namespace Volo.Abp.Domain.ChangeTracking;
+
+public class ChangeTrackingInterceptor : AbpInterceptor, ITransientDependency
+{
+ private readonly IEntityChangeTrackingProvider _entityChangeTrackingProvider;
+
+ public ChangeTrackingInterceptor(IEntityChangeTrackingProvider entityChangeTrackingProvider)
+ {
+ _entityChangeTrackingProvider = entityChangeTrackingProvider;
+ }
+
+ public async override Task InterceptAsync(IAbpMethodInvocation invocation)
+ {
+ if (!ChangeTrackingHelper.IsEntityChangeTrackingMethod(invocation.Method, out var changeTrackingAttribute))
+ {
+ await invocation.ProceedAsync();
+ return;
+ }
+
+ using (_entityChangeTrackingProvider.Change(changeTrackingAttribute?.IsEnabled))
+ {
+ await invocation.ProceedAsync();
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingInterceptorRegistrar.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingInterceptorRegistrar.cs
new file mode 100644
index 0000000000..0249c570dd
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/ChangeTrackingInterceptorRegistrar.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Reflection;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.DynamicProxy;
+
+namespace Volo.Abp.Domain.ChangeTracking;
+
+public class ChangeTrackingInterceptorRegistrar
+{
+ public static void RegisterIfNeeded(IOnServiceRegistredContext context)
+ {
+ if (ShouldIntercept(context.ImplementationType))
+ {
+ context.Interceptors.TryAdd();
+ }
+ }
+
+ private static bool ShouldIntercept(Type type)
+ {
+ return !DynamicProxyIgnoreTypes.Contains(type) && ChangeTrackingHelper.IsEntityChangeTrackingType(type.GetTypeInfo());
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/DisableEntityChangeTrackingAttribute.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/DisableEntityChangeTrackingAttribute.cs
new file mode 100644
index 0000000000..98011bda5f
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/DisableEntityChangeTrackingAttribute.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace Volo.Abp.Domain.ChangeTracking;
+
+///
+/// Ensures that the change tracking in enabled for the given method or class.
+///
+[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
+public class DisableEntityChangeTrackingAttribute : EntityChangeTrackingAttribute
+{
+ public DisableEntityChangeTrackingAttribute()
+ : base(false)
+ {
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/EnableEntityChangeTrackingAttribute.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/EnableEntityChangeTrackingAttribute.cs
new file mode 100644
index 0000000000..542b60cd74
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/EnableEntityChangeTrackingAttribute.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace Volo.Abp.Domain.ChangeTracking;
+
+///
+/// Ensures that the change tracking in enabled for the given method or class.
+///
+[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
+public class EnableEntityChangeTrackingAttribute : EntityChangeTrackingAttribute
+{
+ public EnableEntityChangeTrackingAttribute()
+ : base(true)
+ {
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/EntityChangeTrackingAttribute.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/EntityChangeTrackingAttribute.cs
new file mode 100644
index 0000000000..3446a49354
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/ChangeTracking/EntityChangeTrackingAttribute.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace Volo.Abp.Domain.ChangeTracking;
+
+[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
+public abstract class EntityChangeTrackingAttribute : Attribute
+{
+ public virtual bool IsEnabled { get; set; }
+
+ public EntityChangeTrackingAttribute(bool isEnabled)
+ {
+ IsEnabled = isEnabled;
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs
index 0d86045eea..cd85acce50 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/BasicRepositoryBase.cs
@@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
@@ -34,6 +36,14 @@ public abstract class BasicRepositoryBase :
public ICancellationTokenProvider CancellationTokenProvider => LazyServiceProvider.LazyGetService(NullCancellationTokenProvider.Instance);
+ public ILoggerFactory? LoggerFactory => LazyServiceProvider.LazyGetService();
+
+ public ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance);
+
+ public IEntityChangeTrackingProvider EntityChangeTrackingProvider => LazyServiceProvider.LazyGetRequiredService();
+
+ public bool? IsChangeTrackingEnabled { get; protected set; }
+
protected BasicRepositoryBase()
{
@@ -106,6 +116,24 @@ public abstract class BasicRepositoryBase :
{
return CancellationTokenProvider.FallbackToProvider(preferredValue);
}
+
+ protected virtual bool ShouldTrackingEntityChange()
+ {
+ // If IsChangeTrackingEnabled is set, it has the highest priority. This generally means the repository is read-only.
+ if (IsChangeTrackingEnabled.HasValue)
+ {
+ return IsChangeTrackingEnabled.Value;
+ }
+
+ // If Interface/Class/Method has Enable/DisableEntityChangeTrackingAttribute, it has the second highest priority.
+ if (EntityChangeTrackingProvider.Enabled.HasValue)
+ {
+ return EntityChangeTrackingProvider.Enabled.Value;
+ }
+
+ // Default behavior is tracking entity change.
+ return true;
+ }
}
public abstract class BasicRepositoryBase : BasicRepositoryBase, IBasicRepository
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/EntityChangeTrackingProvider.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/EntityChangeTrackingProvider.cs
new file mode 100644
index 0000000000..19c10e9a3f
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/EntityChangeTrackingProvider.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Threading;
+using Volo.Abp.DependencyInjection;
+
+namespace Volo.Abp.Domain.Repositories;
+
+public class EntityChangeTrackingProvider : IEntityChangeTrackingProvider, ISingletonDependency
+{
+ public bool? Enabled => _current.Value;
+
+ private readonly AsyncLocal _current = new AsyncLocal();
+
+ public IDisposable Change(bool? enabled)
+ {
+ var previousValue = Enabled;
+ _current.Value = enabled;
+ return new DisposeAction(() => _current.Value = previousValue);
+ }
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IEntityChangeTrackingProvider.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IEntityChangeTrackingProvider.cs
new file mode 100644
index 0000000000..f1db1584fa
--- /dev/null
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IEntityChangeTrackingProvider.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Volo.Abp.Domain.Repositories;
+
+public interface IEntityChangeTrackingProvider
+{
+ bool? Enabled { get; }
+
+ IDisposable Change(bool? enabled);
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs
index 3c7ae81875..dc39255b25 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs
@@ -12,7 +12,7 @@ namespace Volo.Abp.Domain.Repositories;
///
public interface IRepository
{
-
+ bool? IsChangeTrackingEnabled { get; }
}
public interface IRepository : IReadOnlyRepository, IBasicRepository
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/ISupportsExplicitLoading.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/ISupportsExplicitLoading.cs
index 1c51954f57..08c1f2556f 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/ISupportsExplicitLoading.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/ISupportsExplicitLoading.cs
@@ -7,8 +7,8 @@ using Volo.Abp.Domain.Entities;
namespace Volo.Abp.Domain.Repositories;
-public interface ISupportsExplicitLoading
- where TEntity : class, IEntity
+public interface ISupportsExplicitLoading
+ where TEntity : class, IEntity
{
Task EnsureCollectionLoadedAsync(
TEntity entity,
@@ -18,7 +18,7 @@ public interface ISupportsExplicitLoading
Task EnsurePropertyLoadedAsync(
TEntity entity,
- Expression> propertyExpression,
+ Expression> propertyExpression,
CancellationToken cancellationToken)
where TProperty : class;
}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs
index cbebf62196..3c43798c38 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs
@@ -15,16 +15,16 @@ namespace Volo.Abp.Domain.Repositories;
public static class RepositoryExtensions
{
- public async static Task EnsureCollectionLoadedAsync(
- this IBasicRepository repository,
+ public async static Task EnsureCollectionLoadedAsync(
+ this IBasicRepository repository,
TEntity entity,
Expression>> propertyExpression,
CancellationToken cancellationToken = default
)
- where TEntity : class, IEntity
+ where TEntity : class, IEntity
where TProperty : class
{
- var repo = ProxyHelper.UnProxy(repository) as ISupportsExplicitLoading;
+ var repo = ProxyHelper.UnProxy(repository) as ISupportsExplicitLoading;
if (repo != null)
{
await repo.EnsureCollectionLoadedAsync(entity, propertyExpression, cancellationToken);
@@ -34,13 +34,13 @@ public static class RepositoryExtensions
public async static Task EnsurePropertyLoadedAsync(
this IBasicRepository repository,
TEntity entity,
- Expression> propertyExpression,
+ Expression> propertyExpression,
CancellationToken cancellationToken = default
)
where TEntity : class, IEntity
where TProperty : class
{
- var repo = ProxyHelper.UnProxy(repository) as ISupportsExplicitLoading;
+ var repo = ProxyHelper.UnProxy(repository) as ISupportsExplicitLoading;
if (repo != null)
{
await repo.EnsurePropertyLoadedAsync(entity, propertyExpression, cancellationToken);
@@ -60,12 +60,12 @@ public static class RepositoryExtensions
}
}
- public async static Task EnsureExistsAsync(
- this IRepository repository,
+ public async static Task EnsureExistsAsync(
+ this IRepository repository,
Expression> expression,
CancellationToken cancellationToken = default
)
- where TEntity : class, IEntity
+ where TEntity : class, IEntity
{
if (!await repository.AnyAsync(expression, cancellationToken))
{
@@ -145,6 +145,40 @@ public static class RepositoryExtensions
}
}
+ ///
+ /// Disables change tracking mechanism for the given repository.
+ ///
+ /// A repository object
+ ///
+ /// A disposable object. Dispose it to restore change tracking mechanism back to its previous state.
+ ///
+ public static IDisposable DisableTracking(this IRepository repository)
+ {
+ return Tracking(repository, false);
+ }
+
+ ///
+ /// Enables change tracking mechanism for the given repository.
+ ///
+ /// A repository object
+ ///
+ /// A disposable object. Dispose it to restore change tracking mechanism back to its previous state.
+ ///
+ public static IDisposable EnableTracking(this IRepository repository)
+ {
+ return Tracking(repository, true);
+ }
+
+ private static IDisposable Tracking(this IRepository repository, bool enabled)
+ {
+ var previous = repository.IsChangeTrackingEnabled;
+ ObjectHelper.TrySetProperty(ProxyHelper.UnProxy(repository).As(), x => x.IsChangeTrackingEnabled, _ => enabled);
+ return new DisposeAction(_ =>
+ {
+ ObjectHelper.TrySetProperty(ProxyHelper.UnProxy(repository).As(), x => x.IsChangeTrackingEnabled, _ => previous);
+ }, repository);
+ }
+
private static IUnitOfWorkManager GetUnitOfWorkManager(
this IBasicRepository repository,
[CallerMemberName] string callingMethodName = nameof(GetUnitOfWorkManager)
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/AdditionalEmailSendingArgs.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/AdditionalEmailSendingArgs.cs
new file mode 100644
index 0000000000..4de1eb6105
--- /dev/null
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/AdditionalEmailSendingArgs.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using Volo.Abp.Data;
+
+namespace Volo.Abp.Emailing;
+
+[Serializable]
+public class AdditionalEmailSendingArgs
+{
+ public List? CC { get; set; }
+
+ public List? Attachments { get; set; }
+
+ public ExtraPropertyDictionary? ExtraProperties { get; set; }
+}
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJob.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJob.cs
index 07b4ca9bcd..ac12ddcead 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJob.cs
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJob.cs
@@ -15,15 +15,15 @@ public class BackgroundEmailSendingJob : AsyncBackgroundJob
public bool IsBodyHtml { get; set; } = true;
- //TODO: Add other properties and attachments
+ public AdditionalEmailSendingArgs? AdditionalEmailSendingArgs { get; set; }
}
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailAttachment.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailAttachment.cs
new file mode 100644
index 0000000000..e2fe3a3a6b
--- /dev/null
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailAttachment.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace Volo.Abp.Emailing;
+
+[Serializable]
+public class EmailAttachment
+{
+ public string? Name { get; set; }
+
+ public byte[]? File { get; set; }
+}
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs
index d8a46ca4b9..5f342b2f40 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs
@@ -1,4 +1,6 @@
using System;
+using System.IO;
+using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
@@ -24,20 +26,44 @@ public abstract class EmailSenderBase : IEmailSender
BackgroundJobManager = backgroundJobManager;
}
- public virtual async Task SendAsync(string to, string? subject, string? body, bool isBodyHtml = true)
+ public virtual async Task SendAsync(string to, string? subject, string? body, bool isBodyHtml = true, AdditionalEmailSendingArgs? additionalEmailSendingArgs = null)
{
- await SendAsync(new MailMessage
- {
- To = { to },
- Subject = subject,
- Body = body,
- IsBodyHtml = isBodyHtml
- });
+ await SendAsync(BuildMailMessage(null, to, subject, body, isBodyHtml, additionalEmailSendingArgs));
+ }
+
+ public virtual async Task SendAsync(string from, string to, string? subject, string? body, bool isBodyHtml = true, AdditionalEmailSendingArgs? additionalEmailSendingArgs = null)
+ {
+ await SendAsync(BuildMailMessage(from, to, subject, body, isBodyHtml, additionalEmailSendingArgs));
}
- public virtual async Task SendAsync(string from, string to, string? subject, string? body, bool isBodyHtml = true)
+ protected virtual MailMessage BuildMailMessage(string? from, string to, string? subject, string? body, bool isBodyHtml = true, AdditionalEmailSendingArgs? additionalEmailSendingArgs = null)
{
- await SendAsync(new MailMessage(from, to, subject, body) { IsBodyHtml = isBodyHtml });
+ var message = from == null
+ ? new MailMessage { To = { to }, Subject = subject, Body = body, IsBodyHtml = isBodyHtml }
+ : new MailMessage(from, to, subject, body) { IsBodyHtml = isBodyHtml };
+
+ if (additionalEmailSendingArgs != null)
+ {
+ if (additionalEmailSendingArgs.Attachments != null)
+ {
+ foreach (var attachment in additionalEmailSendingArgs.Attachments.Where(x => x.File != null))
+ {
+ var fileStream = new MemoryStream(attachment.File!);
+ fileStream.Seek(0, SeekOrigin.Begin);
+ message.Attachments.Add(new Attachment(fileStream, attachment.Name));
+ }
+ }
+
+ if (additionalEmailSendingArgs.CC != null)
+ {
+ foreach (var cc in additionalEmailSendingArgs.CC)
+ {
+ message.CC.Add(cc);
+ }
+ }
+ }
+
+ return message;
}
public virtual async Task SendAsync(MailMessage mail, bool normalize = true)
@@ -50,11 +76,11 @@ public abstract class EmailSenderBase : IEmailSender
await SendEmailAsync(mail);
}
- public virtual async Task QueueAsync(string to, string subject, string body, bool isBodyHtml = true)
+ public virtual async Task QueueAsync(string to, string subject, string body, bool isBodyHtml = true, AdditionalEmailSendingArgs? additionalEmailSendingArgs = null)
{
if (!BackgroundJobManager.IsAvailable())
{
- await SendAsync(to, subject, body, isBodyHtml);
+ await SendAsync(to, subject, body, isBodyHtml, additionalEmailSendingArgs);
return;
}
@@ -64,16 +90,17 @@ public abstract class EmailSenderBase : IEmailSender
To = to,
Subject = subject,
Body = body,
- IsBodyHtml = isBodyHtml
+ IsBodyHtml = isBodyHtml,
+ AdditionalEmailSendingArgs = additionalEmailSendingArgs
}
);
}
- public virtual async Task QueueAsync(string from, string to, string subject, string body, bool isBodyHtml = true)
+ public virtual async Task QueueAsync(string from, string to, string subject, string body, bool isBodyHtml = true, AdditionalEmailSendingArgs? additionalEmailSendingArgs = null)
{
if (!BackgroundJobManager.IsAvailable())
{
- await SendAsync(from, to, subject, body, isBodyHtml);
+ await SendAsync(from, to, subject, body, isBodyHtml, additionalEmailSendingArgs);
return;
}
@@ -84,7 +111,8 @@ public abstract class EmailSenderBase : IEmailSender
To = to,
Subject = subject,
Body = body,
- IsBodyHtml = isBodyHtml
+ IsBodyHtml = isBodyHtml,
+ AdditionalEmailSendingArgs = additionalEmailSendingArgs
}
);
}
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs
index 55456783c4..64658b0519 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs
@@ -15,7 +15,8 @@ public interface IEmailSender
string to,
string? subject,
string? body,
- bool isBodyHtml = true
+ bool isBodyHtml = true,
+ AdditionalEmailSendingArgs? additionalEmailSendingArgs = null
);
///
@@ -26,7 +27,8 @@ public interface IEmailSender
string to,
string? subject,
string? body,
- bool isBodyHtml = true
+ bool isBodyHtml = true,
+ AdditionalEmailSendingArgs? additionalEmailSendingArgs = null
);
///
@@ -49,7 +51,8 @@ public interface IEmailSender
string to,
string subject,
string body,
- bool isBodyHtml = true
+ bool isBodyHtml = true,
+ AdditionalEmailSendingArgs? additionalEmailSendingArgs = null
);
///
@@ -60,8 +63,7 @@ public interface IEmailSender
string to,
string subject,
string body,
- bool isBodyHtml = true
+ bool isBodyHtml = true,
+ AdditionalEmailSendingArgs? additionalEmailSendingArgs = null
);
-
- //TODO: Add other Queue methods too. Problem: MailMessage is not serializable so can not be used in background jobs.
}
diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs
index 99a8f2e1e7..4bf7e18158 100644
--- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs
+++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSender.cs
@@ -67,7 +67,7 @@ public class SmtpEmailSender : EmailSenderBase, ISmtpEmailSender, ITransientDepe
}
}
- protected override async Task SendEmailAsync(MailMessage mail)
+ protected async override Task SendEmailAsync(MailMessage mail)
{
using (var smtpClient = await BuildClientAsync())
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo.Abp.EntityFrameworkCore.MySQL.csproj b/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo.Abp.EntityFrameworkCore.MySQL.csproj
index b19feda6c3..d470ed692e 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo.Abp.EntityFrameworkCore.MySQL.csproj
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo.Abp.EntityFrameworkCore.MySQL.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ NullableVolo.Abp.EntityFrameworkCore.MySQLVolo.Abp.EntityFrameworkCore.MySQL$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextMySQLExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextMySQLExtensions.cs
index 596062d533..07381983ca 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextMySQLExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextMySQLExtensions.cs
@@ -10,7 +10,7 @@ public static class AbpDbContextConfigurationContextMySQLExtensions
{
public static DbContextOptionsBuilder UseMySQL(
[NotNull] this AbpDbContextConfigurationContext context,
- [CanBeNull] Action mySQLOptionsAction = null)
+ Action? mySQLOptionsAction = null)
{
if (context.ExistingConnection != null)
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsMySQLExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsMySQLExtensions.cs
index 247e96cee7..baf8c53a14 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsMySQLExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.MySQL/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsMySQLExtensions.cs
@@ -8,7 +8,7 @@ public static class AbpDbContextOptionsMySQLExtensions
{
public static void UseMySQL(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action mySQLOptionsAction = null)
+ Action? mySQLOptionsAction = null)
{
options.Configure(context =>
{
@@ -18,7 +18,7 @@ public static class AbpDbContextOptionsMySQLExtensions
public static void UseMySQL(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action mySQLOptionsAction = null)
+ Action? mySQLOptionsAction = null)
where TDbContext : AbpDbContext
{
options.Configure(context =>
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo.Abp.EntityFrameworkCore.Oracle.Devart.csproj b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo.Abp.EntityFrameworkCore.Oracle.Devart.csproj
index 2ead0da1f3..dcd5fb1788 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo.Abp.EntityFrameworkCore.Oracle.Devart.csproj
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo.Abp.EntityFrameworkCore.Oracle.Devart.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ NullableVolo.Abp.EntityFrameworkCore.Oracle.DevartVolo.Abp.EntityFrameworkCore.Oracle.Devart$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleDevartExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleDevartExtensions.cs
index a672a280ee..e2138dd7d1 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleDevartExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleDevartExtensions.cs
@@ -10,7 +10,7 @@ public static class AbpDbContextConfigurationContextOracleDevartExtensions
{
public static DbContextOptionsBuilder UseOracle(
[NotNull] this AbpDbContextConfigurationContext context,
- [CanBeNull] Action oracleOptionsAction = null,
+ Action? oracleOptionsAction = null,
bool useExistingConnectionIfAvailable = false)
{
if (useExistingConnectionIfAvailable && context.ExistingConnection != null)
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleDevartExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleDevartExtensions.cs
index 12f5bc0437..650d222663 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleDevartExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleDevartExtensions.cs
@@ -8,7 +8,7 @@ public static class AbpDbContextOptionsOracleDevartExtensions
{
public static void UseOracle(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action oracleOptionsAction = null,
+ Action? oracleOptionsAction = null,
bool useExistingConnectionIfAvailable = false)
{
options.Configure(context =>
@@ -19,7 +19,7 @@ public static class AbpDbContextOptionsOracleDevartExtensions
public static void UseOracle(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action oracleOptionsAction = null,
+ Action? oracleOptionsAction = null,
bool useExistingConnectionIfAvailable = false)
where TDbContext : AbpDbContext
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo.Abp.EntityFrameworkCore.Oracle.csproj b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo.Abp.EntityFrameworkCore.Oracle.csproj
index 187c6a1d9f..3ce2f5ff25 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo.Abp.EntityFrameworkCore.Oracle.csproj
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo.Abp.EntityFrameworkCore.Oracle.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ NullableVolo.Abp.EntityFrameworkCore.OracleVolo.Abp.EntityFrameworkCore.Oracle$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleExtensions.cs
index 9b9d3b2916..39f3a5b86f 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleExtensions.cs
@@ -10,7 +10,7 @@ public static class AbpDbContextConfigurationContextOracleExtensions
{
public static DbContextOptionsBuilder UseOracle(
[NotNull] this AbpDbContextConfigurationContext context,
- [CanBeNull] Action oracleOptionsAction = null)
+ Action? oracleOptionsAction = null)
{
if (context.ExistingConnection != null)
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleExtensions.cs
index cc0dc28699..8458dd6d4e 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleExtensions.cs
@@ -8,7 +8,7 @@ public static class AbpDbContextOptionsOracleExtensions
{
public static void UseOracle(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action oracleOptionsAction = null)
+ Action? oracleOptionsAction = null)
{
options.Configure(context =>
{
@@ -18,7 +18,7 @@ public static class AbpDbContextOptionsOracleExtensions
public static void UseOracle(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action oracleOptionsAction = null)
+ Action? oracleOptionsAction = null)
where TDbContext : AbpDbContext
{
options.Configure(context =>
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo.Abp.EntityFrameworkCore.PostgreSql.csproj b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo.Abp.EntityFrameworkCore.PostgreSql.csproj
index 67f55beeb4..04da1dd18a 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo.Abp.EntityFrameworkCore.PostgreSql.csproj
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo.Abp.EntityFrameworkCore.PostgreSql.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ NullableVolo.Abp.EntityFrameworkCore.PostgreSqlVolo.Abp.EntityFrameworkCore.PostgreSql$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextPostgreSqlExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextPostgreSqlExtensions.cs
index 7e13fb01a2..918c0629c1 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextPostgreSqlExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextPostgreSqlExtensions.cs
@@ -11,14 +11,14 @@ public static class AbpDbContextConfigurationContextPostgreSqlExtensions
[Obsolete("Use 'UseNpgsql(...)' method instead. This will be removed in future versions.")]
public static DbContextOptionsBuilder UsePostgreSql(
[NotNull] this AbpDbContextConfigurationContext context,
- [CanBeNull] Action postgreSqlOptionsAction = null)
+ Action? postgreSqlOptionsAction = null)
{
return context.UseNpgsql(postgreSqlOptionsAction);
}
public static DbContextOptionsBuilder UseNpgsql(
[NotNull] this AbpDbContextConfigurationContext context,
- [CanBeNull] Action postgreSqlOptionsAction = null)
+ Action? postgreSqlOptionsAction = null)
{
if (context.ExistingConnection != null)
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsPostgreSqlExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsPostgreSqlExtensions.cs
index bdea54efab..2a52c5de56 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsPostgreSqlExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsPostgreSqlExtensions.cs
@@ -9,7 +9,7 @@ public static class AbpDbContextOptionsPostgreSqlExtensions
[Obsolete("Use 'UseNpgsql(...)' method instead. This will be removed in future versions.")]
public static void UsePostgreSql(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action postgreSqlOptionsAction = null)
+ Action? postgreSqlOptionsAction = null)
{
options.Configure(context =>
{
@@ -20,7 +20,7 @@ public static class AbpDbContextOptionsPostgreSqlExtensions
[Obsolete("Use 'UseNpgsql(...)' method instead. This will be removed in future versions.")]
public static void UsePostgreSql(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action postgreSqlOptionsAction = null)
+ Action? postgreSqlOptionsAction = null)
where TDbContext : AbpDbContext
{
options.Configure(context =>
@@ -31,7 +31,7 @@ public static class AbpDbContextOptionsPostgreSqlExtensions
public static void UseNpgsql(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action postgreSqlOptionsAction = null)
+ Action? postgreSqlOptionsAction = null)
{
options.Configure(context =>
{
@@ -41,7 +41,7 @@ public static class AbpDbContextOptionsPostgreSqlExtensions
public static void UseNpgsql(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action postgreSqlOptionsAction = null)
+ Action? postgreSqlOptionsAction = null)
where TDbContext : AbpDbContext
{
options.Configure(context =>
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/ConnectionStrings/NpgsqlConnectionStringChecker.cs b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/ConnectionStrings/NpgsqlConnectionStringChecker.cs
index f3ab83eb55..56e47aa2d4 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/ConnectionStrings/NpgsqlConnectionStringChecker.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo/Abp/EntityFrameworkCore/ConnectionStrings/NpgsqlConnectionStringChecker.cs
@@ -25,7 +25,7 @@ public class NpgsqlConnectionStringChecker : IConnectionStringChecker, ITransien
await using var conn = new NpgsqlConnection(connString.ConnectionString);
await conn.OpenAsync();
result.Connected = true;
- await conn.ChangeDatabaseAsync(oldDatabaseName);
+ await conn.ChangeDatabaseAsync(oldDatabaseName!);
result.DatabaseExists = true;
await conn.CloseAsync();
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo.Abp.EntityFrameworkCore.SqlServer.csproj b/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo.Abp.EntityFrameworkCore.SqlServer.csproj
index f655b66814..0fb7ee0c61 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo.Abp.EntityFrameworkCore.SqlServer.csproj
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo.Abp.EntityFrameworkCore.SqlServer.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ NullableVolo.Abp.EntityFrameworkCore.SqlServerVolo.Abp.EntityFrameworkCore.SqlServer$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextSqlServerExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextSqlServerExtensions.cs
index 76476423bb..95ea2ebd8b 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextSqlServerExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextSqlServerExtensions.cs
@@ -10,7 +10,7 @@ public static class AbpDbContextConfigurationContextSqlServerExtensions
{
public static DbContextOptionsBuilder UseSqlServer(
[NotNull] this AbpDbContextConfigurationContext context,
- [CanBeNull] Action sqlServerOptionsAction = null)
+ Action? sqlServerOptionsAction = null)
{
if (context.ExistingConnection != null)
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsSqlServerExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsSqlServerExtensions.cs
index 30bf419d5e..8981d8f0c4 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsSqlServerExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.SqlServer/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsSqlServerExtensions.cs
@@ -8,7 +8,7 @@ public static class AbpDbContextOptionsSqlServerExtensions
{
public static void UseSqlServer(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action sqlServerOptionsAction = null)
+ Action? sqlServerOptionsAction = null)
{
options.Configure(context =>
{
@@ -18,7 +18,7 @@ public static class AbpDbContextOptionsSqlServerExtensions
public static void UseSqlServer(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action sqlServerOptionsAction = null)
+ Action? sqlServerOptionsAction = null)
where TDbContext : AbpDbContext
{
options.Configure(context =>
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo.Abp.EntityFrameworkCore.Sqlite.csproj b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo.Abp.EntityFrameworkCore.Sqlite.csproj
index 002b876343..e57c897169 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo.Abp.EntityFrameworkCore.Sqlite.csproj
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo.Abp.EntityFrameworkCore.Sqlite.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ NullableVolo.Abp.EntityFrameworkCore.SqliteVolo.Abp.EntityFrameworkCore.Sqlite$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextSqliteExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextSqliteExtensions.cs
index 6dea2a336b..a4e3b60ec9 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextSqliteExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextSqliteExtensions.cs
@@ -11,7 +11,7 @@ public static class AbpDbContextConfigurationContextSqliteExtensions
{
public static DbContextOptionsBuilder UseSqlite(
[NotNull] this AbpDbContextConfigurationContext context,
- [CanBeNull] Action sqliteOptionsAction = null)
+ Action? sqliteOptionsAction = null)
{
if (context.ExistingConnection != null)
{
@@ -34,7 +34,7 @@ public static class AbpDbContextConfigurationContextSqliteExtensions
public static DbContextOptionsBuilder UseSqlite(
[NotNull] this AbpDbContextConfigurationContext context,
DbConnection connection,
- [CanBeNull] Action sqliteOptionsAction = null)
+ Action? sqliteOptionsAction = null)
{
if (context.ExistingConnection != null)
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsSqliteExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsSqliteExtensions.cs
index aaf39cbde5..c3f24a318c 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsSqliteExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsSqliteExtensions.cs
@@ -8,7 +8,7 @@ public static class AbpDbContextOptionsSqliteExtensions
{
public static void UseSqlite(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action sqliteOptionsAction = null)
+ Action? sqliteOptionsAction = null)
{
options.Configure(context =>
{
@@ -18,7 +18,7 @@ public static class AbpDbContextOptionsSqliteExtensions
public static void UseSqlite(
[NotNull] this AbpDbContextOptions options,
- [CanBeNull] Action sqliteOptionsAction = null)
+ Action? sqliteOptionsAction = null)
where TDbContext : AbpDbContext
{
options.Configure(context =>
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/Extensions/DependencyInjection/AbpEfCoreServiceCollectionExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/Extensions/DependencyInjection/AbpEfCoreServiceCollectionExtensions.cs
index f51df050ef..55e88b72e7 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/Extensions/DependencyInjection/AbpEfCoreServiceCollectionExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/Extensions/DependencyInjection/AbpEfCoreServiceCollectionExtensions.cs
@@ -13,7 +13,7 @@ public static class AbpEfCoreServiceCollectionExtensions
{
public static IServiceCollection AddAbpDbContext(
this IServiceCollection services,
- Action optionsBuilder = null)
+ Action? optionsBuilder = null)
where TDbContext : AbpDbContext
{
services.AddMemoryCache();
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj b/framework/src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj
index c547299bae..af2be88afa 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo.Abp.EntityFrameworkCore.csproj
@@ -5,6 +5,8 @@
net7.0
+ enable
+ NullableVolo.Abp.EntityFrameworkCoreVolo.Abp.EntityFrameworkCore$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EfCoreRepositoryExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EfCoreRepositoryExtensions.cs
index 94dba628d7..614ba135ff 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EfCoreRepositoryExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EfCoreRepositoryExtensions.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Entities;
@@ -44,4 +45,10 @@ public static class EfCoreRepositoryExtensions
throw new ArgumentException("Given repository does not implement " + typeof(IEfCoreRepository).AssemblyQualifiedName, nameof(repository));
}
+
+ public static IQueryable AsNoTrackingIf(this IQueryable queryable, bool condition)
+ where TEntity : class, IEntity
+ {
+ return condition ? queryable.AsNoTracking() : queryable;
+ }
}
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
index 03af8d1fb4..3274360ba2 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
@@ -1,4 +1,3 @@
-using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
@@ -6,16 +5,16 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
-using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Storage;
+using Microsoft.Extensions.Logging;
+using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
using Volo.Abp.Guids;
-using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore;
@@ -27,11 +26,11 @@ public class EfCoreRepository : RepositoryBase, IE
protected virtual TDbContext DbContext => GetDbContext();
[Obsolete("Use GetDbContextAsync() method.")]
- DbContext IEfCoreRepository.DbContext => GetDbContext() as DbContext;
+ DbContext IEfCoreRepository.DbContext => (GetDbContext() as DbContext)!;
async Task IEfCoreRepository.GetDbContextAsync()
{
- return await GetDbContextAsync() as DbContext;
+ return (await GetDbContextAsync() as DbContext)!;
}
[Obsolete("Use GetDbContextAsync() method.")]
@@ -75,13 +74,13 @@ public class EfCoreRepository : RepositoryBase, IE
{
return (await GetDbContextAsync()).Set();
}
-
+
protected async Task GetDbConnectionAsync()
{
return (await GetDbContextAsync()).Database.GetDbConnection();
}
- protected async Task GetDbTransactionAsync()
+ protected async Task GetDbTransactionAsync()
{
return (await GetDbContextAsync()).Database.CurrentTransaction?.GetDbTransaction();
}
@@ -93,7 +92,7 @@ public class EfCoreRepository : RepositoryBase, IE
public virtual IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance);
- public IEfCoreBulkOperationProvider BulkOperationProvider => LazyServiceProvider.LazyGetService();
+ public IEfCoreBulkOperationProvider? BulkOperationProvider => LazyServiceProvider.LazyGetService();
public EfCoreRepository(IDbContextProvider dbContextProvider)
{
@@ -254,19 +253,19 @@ public class EfCoreRepository : RepositoryBase, IE
{
return includeDetails
? await (await WithDetailsAsync()).ToListAsync(GetCancellationToken(cancellationToken))
- : await (await GetDbSetAsync()).ToListAsync(GetCancellationToken(cancellationToken));
+ : await (await GetQueryableAsync()).ToListAsync(GetCancellationToken(cancellationToken));
}
public async override Task> GetListAsync(Expression> predicate, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return includeDetails
? await (await WithDetailsAsync()).Where(predicate).ToListAsync(GetCancellationToken(cancellationToken))
- : await (await GetDbSetAsync()).Where(predicate).ToListAsync(GetCancellationToken(cancellationToken));
+ : await (await GetQueryableAsync()).Where(predicate).ToListAsync(GetCancellationToken(cancellationToken));
}
public async override Task GetCountAsync(CancellationToken cancellationToken = default)
{
- return await (await GetDbSetAsync()).LongCountAsync(GetCancellationToken(cancellationToken));
+ return await (await GetQueryableAsync()).LongCountAsync(GetCancellationToken(cancellationToken));
}
public async override Task> GetPagedListAsync(
@@ -278,7 +277,7 @@ public class EfCoreRepository : RepositoryBase, IE
{
var queryable = includeDetails
? await WithDetailsAsync()
- : await GetDbSetAsync();
+ : await GetQueryableAsync();
return await queryable
.OrderByIf>(!sorting.IsNullOrWhiteSpace(), sorting)
@@ -289,12 +288,12 @@ public class EfCoreRepository : RepositoryBase, IE
[Obsolete("Use GetQueryableAsync method.")]
protected override IQueryable GetQueryable()
{
- return DbSet.AsQueryable();
+ return DbSet.AsQueryable().AsNoTrackingIf(!ShouldTrackingEntityChange());
}
public async override Task> GetQueryableAsync()
{
- return (await GetDbSetAsync()).AsQueryable();
+ return (await GetDbSetAsync()).AsQueryable().AsNoTrackingIf(!ShouldTrackingEntityChange());
}
protected async override Task SaveChangesAsync(CancellationToken cancellationToken)
@@ -302,7 +301,7 @@ public class EfCoreRepository : RepositoryBase, IE
await (await GetDbContextAsync()).SaveChangesAsync(cancellationToken);
}
- public async override Task FindAsync(
+ public async override Task FindAsync(
Expression> predicate,
bool includeDetails = true,
CancellationToken cancellationToken = default)
@@ -311,7 +310,7 @@ public class EfCoreRepository : RepositoryBase, IE
? await (await WithDetailsAsync())
.Where(predicate)
.SingleOrDefaultAsync(GetCancellationToken(cancellationToken))
- : await (await GetDbSetAsync())
+ : await (await GetQueryableAsync())
.Where(predicate)
.SingleOrDefaultAsync(GetCancellationToken(cancellationToken));
}
@@ -333,7 +332,7 @@ public class EfCoreRepository : RepositoryBase, IE
}
}
- public override async Task DeleteDirectAsync(Expression> predicate, CancellationToken cancellationToken = default)
+ public async override Task DeleteDirectAsync(Expression> predicate, CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
var dbSet = dbContext.Set();
@@ -354,7 +353,7 @@ public class EfCoreRepository : RepositoryBase, IE
public virtual async Task EnsurePropertyLoadedAsync(
TEntity entity,
- Expression> propertyExpression,
+ Expression> propertyExpression,
CancellationToken cancellationToken = default)
where TProperty : class
{
@@ -442,7 +441,7 @@ public class EfCoreRepository : RepositoryBase, IE
public class EfCoreRepository : EfCoreRepository,
IEfCoreRepository,
- ISupportsExplicitLoading
+ ISupportsExplicitLoading
where TDbContext : IEfCoreDbContext
where TEntity : class, IEntity
@@ -465,11 +464,13 @@ public class EfCoreRepository : EfCoreRepository FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
+ public virtual async Task FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return includeDetails
- ? await (await WithDetailsAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id.Equals(id), GetCancellationToken(cancellationToken))
- : await (await GetDbSetAsync()).FindAsync(new object[] { id }, GetCancellationToken(cancellationToken));
+ ? await (await WithDetailsAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id!.Equals(id), GetCancellationToken(cancellationToken))
+ : !ShouldTrackingEntityChange()
+ ? await (await GetQueryableAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id!.Equals(id), GetCancellationToken(cancellationToken))
+ : await (await GetDbSetAsync()).FindAsync(new object[] {id!}, GetCancellationToken(cancellationToken));
}
public virtual async Task DeleteAsync(TKey id, bool autoSave = false, CancellationToken cancellationToken = default)
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
index bc93ca97b8..05dd4527fc 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
@@ -37,7 +37,7 @@ namespace Volo.Abp.EntityFrameworkCore;
public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext, ITransientDependency
where TDbContext : DbContext
{
- public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
+ public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
protected virtual Guid? CurrentTenantId => CurrentTenant?.Id;
@@ -74,21 +74,21 @@ public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext,
.GetMethod(
nameof(ConfigureBaseProperties),
BindingFlags.Instance | BindingFlags.NonPublic
- );
+ )!;
private static readonly MethodInfo ConfigureValueConverterMethodInfo
= typeof(AbpDbContext)
.GetMethod(
nameof(ConfigureValueConverter),
BindingFlags.Instance | BindingFlags.NonPublic
- );
+ )!;
private static readonly MethodInfo ConfigureValueGeneratedMethodInfo
= typeof(AbpDbContext)
.GetMethod(
nameof(ConfigureValueGenerated),
BindingFlags.Instance | BindingFlags.NonPublic
- );
+ )!;
protected AbpDbContext(DbContextOptions options)
: base(options)
@@ -157,7 +157,7 @@ public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext,
try
{
var auditLog = AuditingManager?.Current?.Log;
- List entityChangeList = null;
+ List? entityChangeList = null;
if (auditLog != null)
{
entityChangeList = EntityHistoryHelper.CreateChangeList(ChangeTracker.Entries().ToList());
@@ -174,7 +174,7 @@ public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext,
if (entityChangeList != null)
{
EntityHistoryHelper.UpdateChangeList(entityChangeList);
- auditLog.EntityChanges.AddRange(entityChangeList);
+ auditLog!.EntityChanges.AddRange(entityChangeList);
Logger.LogDebug($"Added {entityChangeList.Count} entity changes to the current audit log");
}
@@ -249,13 +249,13 @@ public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext,
}
}
- protected virtual void ChangeTracker_Tracked(object sender, EntityTrackedEventArgs e)
+ protected virtual void ChangeTracker_Tracked(object? sender, EntityTrackedEventArgs e)
{
FillExtraPropertiesForTrackedEntities(e);
PublishEventsForTrackedEntity(e.Entry);
}
- protected virtual void ChangeTracker_StateChanged(object sender, EntityStateChangedEventArgs e)
+ protected virtual void ChangeTracker_StateChanged(object? sender, EntityStateChangedEventArgs e)
{
PublishEventsForTrackedEntity(e.Entry);
}
@@ -453,11 +453,11 @@ public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext,
if (conversionType == typeof(Guid))
{
- entryProperty.CurrentValue = TypeDescriptor.GetConverter(conversionType).ConvertFromInvariantString(entityProperty.ToString());
+ entryProperty.CurrentValue = TypeDescriptor.GetConverter(conversionType).ConvertFromInvariantString(entityProperty.ToString()!);
}
else if (conversionType.IsEnum)
{
- entryProperty.CurrentValue = Enum.Parse(conversionType, entityProperty.ToString(), ignoreCase: true);
+ entryProperty.CurrentValue = Enum.Parse(conversionType, entityProperty.ToString()!, ignoreCase: true);
}
else
{
@@ -560,7 +560,7 @@ public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext,
return;
}
- var idProperty = entry.Property("Id").Metadata.PropertyInfo;
+ var idProperty = entry.Property("Id").Metadata.PropertyInfo!;
//Check for DatabaseGeneratedAttribute
var dbGeneratedAttr = ReflectionHelper
@@ -669,7 +669,7 @@ public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext,
}
var idPropertyBuilder = modelBuilder.Entity().Property(x => ((IEntity)x).Id);
- if (idPropertyBuilder.Metadata.PropertyInfo.IsDefined(typeof(DatabaseGeneratedAttribute), true))
+ if (idPropertyBuilder.Metadata.PropertyInfo!.IsDefined(typeof(DatabaseGeneratedAttribute), true))
{
return;
}
@@ -692,10 +692,10 @@ public abstract class AbpDbContext : DbContext, IAbpEfCoreDbContext,
return false;
}
- protected virtual Expression> CreateFilterExpression()
+ protected virtual Expression>? CreateFilterExpression()
where TEntity : class
{
- Expression> expression = null;
+ Expression>? expression = null;
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)))
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs
index 43803b4004..cb5b258192 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs
@@ -12,7 +12,7 @@ public class AbpDbContextOptions
{
internal List> DefaultPreConfigureActions { get; }
- internal Action DefaultConfigureAction { get; set; }
+ internal Action? DefaultConfigureAction { get; set; }
internal Dictionary> PreConfigureActions { get; }
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs
index 8d60d6d3c9..34a7dd008d 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpDbContextConfigurationContext.cs
@@ -14,17 +14,17 @@ public class AbpDbContextConfigurationContext : IServiceProviderAccessor
public string ConnectionString { get; }
- public string ConnectionStringName { get; }
+ public string? ConnectionStringName { get; }
- public DbConnection ExistingConnection { get; }
+ public DbConnection? ExistingConnection { get; }
public DbContextOptionsBuilder DbContextOptions { get; protected set; }
public AbpDbContextConfigurationContext(
[NotNull] string connectionString,
[NotNull] IServiceProvider serviceProvider,
- [CanBeNull] string connectionStringName,
- [CanBeNull] DbConnection existingConnection)
+ string? connectionStringName,
+ DbConnection? existingConnection)
{
ConnectionString = connectionString;
ServiceProvider = serviceProvider;
@@ -45,8 +45,8 @@ public class AbpDbContextConfigurationContext : AbpDbContextConfigur
public AbpDbContextConfigurationContext(
string connectionString,
[NotNull] IServiceProvider serviceProvider,
- [CanBeNull] string connectionStringName,
- [CanBeNull] DbConnection existingConnection)
+ string? connectionStringName,
+ DbConnection? existingConnection)
: base(
connectionString,
serviceProvider,
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpEntityOptions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpEntityOptions.cs
index a2c75fe5c3..ecd98356c3 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpEntityOptions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/AbpEntityOptions.cs
@@ -11,7 +11,7 @@ public class AbpEntityOptions
{
public static AbpEntityOptions Empty { get; } = new AbpEntityOptions();
- public Func, IQueryable> DefaultWithDetailsFunc { get; set; }
+ public Func, IQueryable>? DefaultWithDetailsFunc { get; set; }
}
public class AbpEntityOptions
@@ -23,7 +23,7 @@ public class AbpEntityOptions
_options = new Dictionary();
}
- public AbpEntityOptions GetOrNull()
+ public AbpEntityOptions? GetOrNull()
where TEntity : IEntity
{
return _options.GetOrDefault(typeof(TEntity)) as AbpEntityOptions;
@@ -35,10 +35,10 @@ public class AbpEntityOptions
Check.NotNull(optionsAction, nameof(optionsAction));
optionsAction(
- _options.GetOrAdd(
+ (_options.GetOrAdd(
typeof(TEntity),
() => new AbpEntityOptions()
- ) as AbpEntityOptions