|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 174 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 51 KiB |
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,27 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
<WarningsAsErrors>Nullable</WarningsAsErrors> |
|||
<AssemblyName>Volo.Abp.EntityFrameworkCore.MySQL.Pomelo</AssemblyName> |
|||
<PackageId>Volo.Abp.EntityFrameworkCore.MySQL.Pomelo</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.EntityFrameworkCore\Volo.Abp.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,33 @@ |
|||
using JetBrains.Annotations; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using Volo.Abp.EntityFrameworkCore.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore; |
|||
|
|||
public static class AbpDbContextConfigurationContextMySQLExtensions |
|||
{ |
|||
public static DbContextOptionsBuilder UseMySQL( |
|||
[NotNull] this AbpDbContextConfigurationContext context, |
|||
Action<Microsoft.EntityFrameworkCore.Infrastructure.MySqlDbContextOptionsBuilder>? mySQLOptionsAction = null) |
|||
{ |
|||
if (context.ExistingConnection != null) |
|||
{ |
|||
return context.DbContextOptions.UseMySql(context.ExistingConnection, |
|||
ServerVersion.AutoDetect(context.ConnectionString), optionsBuilder => |
|||
{ |
|||
optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); |
|||
mySQLOptionsAction?.Invoke(optionsBuilder); |
|||
}); |
|||
} |
|||
else |
|||
{ |
|||
return context.DbContextOptions.UseMySql(context.ConnectionString, |
|||
ServerVersion.AutoDetect(context.ConnectionString), optionsBuilder => |
|||
{ |
|||
optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); |
|||
mySQLOptionsAction?.Invoke(optionsBuilder); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using JetBrains.Annotations; |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore; |
|||
|
|||
public static class AbpDbContextOptionsMySQLExtensions |
|||
{ |
|||
public static void UseMySQL( |
|||
[NotNull] this AbpDbContextOptions options, |
|||
Action<MySqlDbContextOptionsBuilder>? mySQLOptionsAction = null) |
|||
{ |
|||
options.Configure(context => |
|||
{ |
|||
context.UseMySQL(mySQLOptionsAction); |
|||
}); |
|||
} |
|||
|
|||
public static void UseMySQL<TDbContext>( |
|||
[NotNull] this AbpDbContextOptions options, |
|||
Action<MySqlDbContextOptionsBuilder>? mySQLOptionsAction = null) |
|||
where TDbContext : AbpDbContext<TDbContext> |
|||
{ |
|||
options.Configure<TDbContext>(context => |
|||
{ |
|||
context.UseMySQL(mySQLOptionsAction); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using MySqlConnector; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.ConnectionStrings; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
public class PomeloMySQLConnectionStringChecker : IConnectionStringChecker, ITransientDependency |
|||
{ |
|||
public virtual async Task<AbpConnectionStringCheckResult> CheckAsync(string connectionString) |
|||
{ |
|||
var result = new AbpConnectionStringCheckResult(); |
|||
try |
|||
{ |
|||
var connString = new MySqlConnectionStringBuilder(connectionString) |
|||
{ |
|||
ConnectionLifeTime = 1 |
|||
}; |
|||
|
|||
var oldDatabaseName = connString.Database; |
|||
connString.Database = "mysql"; |
|||
|
|||
await using var conn = new MySqlConnection(connString.ConnectionString); |
|||
await conn.OpenAsync(); |
|||
result.Connected = true; |
|||
await conn.ChangeDatabaseAsync(oldDatabaseName); |
|||
result.DatabaseExists = true; |
|||
|
|||
await conn.CloseAsync(); |
|||
|
|||
return result; |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using Volo.Abp.EntityFrameworkCore.GlobalFilters; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.MySQL; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpEntityFrameworkCoreModule) |
|||
)] |
|||
public class AbpEntityFrameworkCoreMySQLPomeloModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpSequentialGuidGeneratorOptions>(options => |
|||
{ |
|||
if (options.DefaultSequentialGuidType == null) |
|||
{ |
|||
options.DefaultSequentialGuidType = SequentialGuidType.SequentialAsString; |
|||
} |
|||
}); |
|||
|
|||
Configure<AbpEfCoreGlobalFilterOptions>(options => |
|||
{ |
|||
options.UseDbFunction = true; |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace Microsoft.EntityFrameworkCore; |
|||
|
|||
public static class AbpMySQLModelBuilderExtensions |
|||
{ |
|||
public static void UseMySQL( |
|||
this ModelBuilder modelBuilder) |
|||
{ |
|||
modelBuilder.SetDatabaseProvider(EfCoreDatabaseProvider.MySql); |
|||
} |
|||
} |
|||
@ -1,13 +1,13 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using MySqlConnector; |
|||
using MySql.Data.MySqlClient; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.ConnectionStrings; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
public class MySqlConnectionStringChecker : IConnectionStringChecker, ITransientDependency |
|||
public class MySQLConnectionStringChecker : IConnectionStringChecker, ITransientDependency |
|||
{ |
|||
public virtual async Task<AbpConnectionStringCheckResult> CheckAsync(string connectionString) |
|||
{ |
|||
@ -0,0 +1,92 @@ |
|||
using System; |
|||
using System.Diagnostics; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.TestApp.Domain; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore; |
|||
|
|||
public class AbpEfCoreNavigationHelper_Tests : EntityFrameworkCoreTestBase |
|||
{ |
|||
private readonly IRepository<Blog, Guid> _blogRepository; |
|||
|
|||
public AbpEfCoreNavigationHelper_Tests() |
|||
{ |
|||
_blogRepository = GetRequiredService<IRepository<Blog, Guid>>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Performance_Test() |
|||
{ |
|||
//These time taken varies on different machines.
|
|||
//I used relatively large values, but it can also check for performance problem.
|
|||
var batchUpdateTime = TimeSpan.FromSeconds(30); |
|||
var queryTime = TimeSpan.FromSeconds(10); |
|||
|
|||
if (!Environment.GetEnvironmentVariable("GITHUB_ACTIONS").IsNullOrWhiteSpace()) |
|||
{ |
|||
batchUpdateTime = batchUpdateTime * 6; |
|||
queryTime = queryTime * 6; |
|||
} |
|||
|
|||
|
|||
var stopWatch = Stopwatch.StartNew(); |
|||
await WithUnitOfWorkAsync(async () => |
|||
{ |
|||
for (var i = 0; i < 5 * 1000; i++) |
|||
{ |
|||
await _blogRepository.InsertAsync( |
|||
new Blog(Guid.NewGuid()) |
|||
{ |
|||
Name = "Blog" + i, |
|||
BlogPosts = |
|||
[ |
|||
new BlogPost(Guid.NewGuid()) |
|||
{ |
|||
Title = "Post" + i |
|||
} |
|||
] |
|||
}); |
|||
} |
|||
}); |
|||
stopWatch.Stop(); |
|||
stopWatch.Elapsed.ShouldBeLessThan(batchUpdateTime); |
|||
|
|||
|
|||
stopWatch.Restart(); |
|||
var blogs = await _blogRepository.GetListAsync(includeDetails: true); |
|||
blogs.Count.ShouldBe(5 * 1000); |
|||
blogs.SelectMany(x => x.BlogPosts).Count().ShouldBe(5 * 1000); |
|||
stopWatch.Stop(); |
|||
stopWatch.Elapsed.ShouldBeLessThan(queryTime); |
|||
|
|||
|
|||
var blogId = blogs.First().Id; |
|||
stopWatch.Restart(); |
|||
await WithUnitOfWorkAsync(async () => |
|||
{ |
|||
var blog = await _blogRepository.GetAsync(blogId); |
|||
blog.ShouldNotBeNull(); |
|||
for (var i = 0; i < 5 * 1000; i++) |
|||
{ |
|||
blog.BlogPosts.Add( |
|||
new BlogPost(Guid.NewGuid()) |
|||
{ |
|||
Title = "NewPost" + i |
|||
}); |
|||
} |
|||
await _blogRepository.UpdateAsync(blog); |
|||
}); |
|||
stopWatch.Stop(); |
|||
stopWatch.Elapsed.ShouldBeLessThan(batchUpdateTime); |
|||
|
|||
stopWatch.Restart(); |
|||
var blog = await _blogRepository.GetAsync(blogId); |
|||
blog.BlogPosts.Count.ShouldBe(5 * 1000 + 1); |
|||
stopWatch.Stop(); |
|||
stopWatch.Elapsed.ShouldBeLessThan(queryTime); |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
|
|||
namespace Volo.Abp.TestApp.Domain; |
|||
|
|||
public class Blog : FullAuditedAggregateRoot<Guid> |
|||
{ |
|||
public Blog(Guid id) |
|||
: base(id) |
|||
{ |
|||
} |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public List<BlogPost> BlogPosts { get; set; } |
|||
} |
|||
|
|||
public class BlogPost : Entity<Guid> |
|||
{ |
|||
public BlogPost(Guid id) |
|||
: base(id) |
|||
{ |
|||
} |
|||
|
|||
public Guid BlogId { get; set; } |
|||
public Blog Blog { get; set; } |
|||
|
|||
public string Title { get; set; } |
|||
} |
|||
@ -1,12 +1,17 @@ |
|||
document.addEventListener("DOMContentLoaded", function (event) { |
|||
setTimeout(function () { |
|||
var redirectButton = document.getElementById("redirectButton"); |
|||
|
|||
if(!redirectButton){ |
|||
if (!redirectButton) { |
|||
return; |
|||
} |
|||
|
|||
redirectButton.getAttribute("cname"); |
|||
redirectButton.getAttribute("href"); |
|||
}, 3000) |
|||
var clientName = redirectButton.getAttribute("cname"); |
|||
if (clientName) { |
|||
window.clientName = clientName; |
|||
} |
|||
var href = redirectButton.getAttribute("href"); |
|||
if (!href) { |
|||
return; |
|||
} |
|||
window.location = href; |
|||
}, 3000); |
|||
}); |
|||
|
|||