Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddAllQueries给IQuery注入将AddTransient改为AddScoped #100

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AspNetCore/ServiceCollectionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
foreach (var assembly in Assemblies)
{
//从assembly中获取所有实现IQuery接口的类
var queryTypes = assembly.GetTypes().Where(p => p.IsClass && !p.IsAbstract && p.GetInterfaces().Any(i => i == typeof(IQuery)));

Check warning on line 45 in src/AspNetCore/ServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / build

Collection-specific "Exists" method should be used instead of the "Any" extension. (https://rules.sonarsource.com/csharp/RSPEC-6605)

Check warning on line 45 in src/AspNetCore/ServiceCollectionExtension.cs

View workflow job for this annotation

GitHub Actions / build

Collection-specific "Exists" method should be used instead of the "Any" extension. (https://rules.sonarsource.com/csharp/RSPEC-6605)
foreach (var queryType in queryTypes)
{
//×¢²áΪ×Ô¼º
services.AddTransient(queryType, queryType);
services.AddScoped(queryType, queryType);
}
}
return services;
Expand Down
Loading