From f2784eb233476814c7e7c03750bac8d8d29f4c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 22 Dec 2020 12:20:43 +0300 Subject: [PATCH 1/6] Created empty solution: AbpPerfTest.sln --- .../AbpPerfTest.WithoutAbp.csproj | 7 ++++ .../AbpPerfTest.WithoutAbp/Program.cs | 23 ++++++++++++ .../Properties/launchSettings.json | 28 ++++++++++++++ .../AbpPerfTest.WithoutAbp/Startup.cs | 37 +++++++++++++++++++ .../appsettings.Development.json | 9 +++++ .../AbpPerfTest.WithoutAbp/appsettings.json | 10 +++++ test/AbpPerfTest/AbpPerfTest.sln | 16 ++++++++ 7 files changed, 130 insertions(+) create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Program.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Properties/launchSettings.json create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Startup.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.Development.json create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.json create mode 100644 test/AbpPerfTest/AbpPerfTest.sln diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj new file mode 100644 index 0000000000..f6851843e7 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj @@ -0,0 +1,7 @@ + + + + net5.0 + + + diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Program.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Program.cs new file mode 100644 index 0000000000..6d42a4aa5e --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace AbpPerfTest.WithoutAbp +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); + } +} \ No newline at end of file diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Properties/launchSettings.json b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Properties/launchSettings.json new file mode 100644 index 0000000000..07aa90a5da --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:16268", + "sslPort": 44323 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "AbpPerfTest.WithoutAbp": { + "commandName": "Project", + "dotnetRunMessages": "true", + "launchBrowser": true, + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Startup.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Startup.cs new file mode 100644 index 0000000000..971d2625b8 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Startup.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace AbpPerfTest.WithoutAbp +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); + }); + } + } +} \ No newline at end of file diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.Development.json b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.Development.json new file mode 100644 index 0000000000..8983e0fc1c --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.json b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.json new file mode 100644 index 0000000000..d9d9a9bff6 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/test/AbpPerfTest/AbpPerfTest.sln b/test/AbpPerfTest/AbpPerfTest.sln new file mode 100644 index 0000000000..56f079c284 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbpPerfTest.WithoutAbp", "AbpPerfTest.WithoutAbp\AbpPerfTest.WithoutAbp.csproj", "{E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal From 5c8cca4142a5a5014ad222d1ea6456fa5d712d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 22 Dec 2020 16:30:13 +0300 Subject: [PATCH 2/6] Initial AbpPerfTest.WithoutAbp --- .../AbpPerfTest.WithoutAbp.csproj | 8 ++++ .../Controllers/BookController.cs | 37 +++++++++++++++ .../AbpPerfTest.WithoutAbp/Dtos/BookDto.cs | 15 ++++++ .../AbpPerfTest.WithoutAbp/Entities/Book.cs | 15 ++++++ .../EntityFramework/BookDbContext.cs | 27 +++++++++++ .../EntityFramework/BookDbContextFactory.cs | 29 ++++++++++++ .../20201222132615_Added_Books.Designer.cs | 47 +++++++++++++++++++ .../Migrations/20201222132615_Added_Books.cs | 31 ++++++++++++ .../Migrations/BookDbContextModelSnapshot.cs | 45 ++++++++++++++++++ .../AbpPerfTest.WithoutAbp/Program.cs | 8 +--- .../AbpPerfTest.WithoutAbp/Startup.cs | 28 +++++++---- .../AbpPerfTest.WithoutAbp/appsettings.json | 5 +- 12 files changed, 277 insertions(+), 18 deletions(-) create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Dtos/BookDto.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Entities/Book.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/EntityFramework/BookDbContext.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/EntityFramework/BookDbContextFactory.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/20201222132615_Added_Books.Designer.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/20201222132615_Added_Books.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/BookDbContextModelSnapshot.cs diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj index f6851843e7..edf2ed6d58 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj @@ -4,4 +4,12 @@ net5.0 + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs new file mode 100644 index 0000000000..2cb5d69164 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AbpPerfTest.WithoutAbp.Dtos; +using AbpPerfTest.WithoutAbp.EntityFramework; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace AbpPerfTest.WithoutAbp.Controllers +{ + [Route("api/books")] + public class BookController : Controller + { + private readonly BookDbContext _bookDbContext; + + public BookController(BookDbContext bookDbContext) + { + _bookDbContext = bookDbContext; + } + + [HttpGet] + public async Task> GetListAsync() + { + var books = await _bookDbContext.Books.ToListAsync(); + + return books + .Select(b => new BookDto + { + Id = b.Id, + Name = b.Name, + Price = b.Price, + IsAvailable = b.IsAvailable + }) + .ToList(); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Dtos/BookDto.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Dtos/BookDto.cs new file mode 100644 index 0000000000..46ab9599dc --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Dtos/BookDto.cs @@ -0,0 +1,15 @@ +using System; + +namespace AbpPerfTest.WithoutAbp.Dtos +{ + public class BookDto + { + public Guid Id { get; set; } + + public string Name { get; set; } + + public float Price { get; set; } + + public bool IsAvailable { get; set; } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Entities/Book.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Entities/Book.cs new file mode 100644 index 0000000000..7a52830cf3 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Entities/Book.cs @@ -0,0 +1,15 @@ +using System; + +namespace AbpPerfTest.WithoutAbp.Entities +{ + public class Book + { + public Guid Id { get; set; } + + public string Name { get; set; } + + public float Price { get; set; } + + public bool IsAvailable { get; set; } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/EntityFramework/BookDbContext.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/EntityFramework/BookDbContext.cs new file mode 100644 index 0000000000..92c5dc1cc1 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/EntityFramework/BookDbContext.cs @@ -0,0 +1,27 @@ +using AbpPerfTest.WithoutAbp.Entities; +using Microsoft.EntityFrameworkCore; + +namespace AbpPerfTest.WithoutAbp.EntityFramework +{ + public class BookDbContext : DbContext + { + public DbSet Books { get; set; } + + public BookDbContext(DbContextOptions builderOptions) + : base(builderOptions) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity(b => + { + b.ToTable("Books"); + b.Property(x => x.Name).HasMaxLength(128); + }); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/EntityFramework/BookDbContextFactory.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/EntityFramework/BookDbContextFactory.cs new file mode 100644 index 0000000000..d92948fcbc --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/EntityFramework/BookDbContextFactory.cs @@ -0,0 +1,29 @@ +using System.IO; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace AbpPerfTest.WithoutAbp.EntityFramework +{ + public class BookDbContextFactory : IDesignTimeDbContextFactory + { + public BookDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); + + return new BookDbContext(builder.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); + + return builder.Build(); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/20201222132615_Added_Books.Designer.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/20201222132615_Added_Books.Designer.cs new file mode 100644 index 0000000000..0fc7fef909 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/20201222132615_Added_Books.Designer.cs @@ -0,0 +1,47 @@ +// +using System; +using AbpPerfTest.WithoutAbp.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace AbpPerfTest.WithoutAbp.Migrations +{ + [DbContext(typeof(BookDbContext))] + [Migration("20201222132615_Added_Books")] + partial class Added_Books + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseIdentityColumns() + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("AbpPerfTest.WithoutAbp.Entities.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("IsAvailable") + .HasColumnType("bit"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Price") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/20201222132615_Added_Books.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/20201222132615_Added_Books.cs new file mode 100644 index 0000000000..cb5103c93c --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/20201222132615_Added_Books.cs @@ -0,0 +1,31 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace AbpPerfTest.WithoutAbp.Migrations +{ + public partial class Added_Books : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Books", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Price = table.Column(type: "real", nullable: false), + IsAvailable = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Books", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Books"); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/BookDbContextModelSnapshot.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/BookDbContextModelSnapshot.cs new file mode 100644 index 0000000000..9d494bb518 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Migrations/BookDbContextModelSnapshot.cs @@ -0,0 +1,45 @@ +// +using System; +using AbpPerfTest.WithoutAbp.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace AbpPerfTest.WithoutAbp.Migrations +{ + [DbContext(typeof(BookDbContext))] + partial class BookDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseIdentityColumns() + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("AbpPerfTest.WithoutAbp.Entities.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("IsAvailable") + .HasColumnType("bit"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Price") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Program.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Program.cs index 6d42a4aa5e..b657f16862 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Program.cs +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Program.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; namespace AbpPerfTest.WithoutAbp { @@ -20,4 +14,4 @@ namespace AbpPerfTest.WithoutAbp Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); } -} \ No newline at end of file +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Startup.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Startup.cs index 971d2625b8..cf2a61df14 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Startup.cs +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Startup.cs @@ -1,10 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using AbpPerfTest.WithoutAbp.EntityFramework; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -12,13 +10,23 @@ namespace AbpPerfTest.WithoutAbp { public class Startup { - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + private readonly IConfiguration _configuration; + + public Startup(IConfiguration configuration) + { + _configuration = configuration; + } + public void ConfigureServices(IServiceCollection services) { + services.AddMvc(); + + services.AddDbContext(options => + { + options.UseSqlServer(_configuration.GetConnectionString("Default")); + }); } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) @@ -30,8 +38,8 @@ namespace AbpPerfTest.WithoutAbp app.UseEndpoints(endpoints => { - endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Hello World!"); }); + endpoints.MapControllers(); }); } } -} \ No newline at end of file +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.json b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.json index d9d9a9bff6..7f6ca466b2 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.json +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/appsettings.json @@ -6,5 +6,8 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=AbpPerfTest_WithoutAbp;Trusted_Connection=True;MultipleActiveResultSets=true" + } } From 95cacc99e121019f5f6eb28cfba98dd9b04d8adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 22 Dec 2020 16:41:21 +0300 Subject: [PATCH 3/6] Implemented CRUD ops. --- .../Controllers/BookController.cs | 59 ++++++++++++++++++- .../Dtos/CreateUpdateBookDto.cs | 11 ++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/AbpPerfTest/AbpPerfTest.WithoutAbp/Dtos/CreateUpdateBookDto.cs diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs index 2cb5d69164..96cb30eedd 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs @@ -1,7 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using AbpPerfTest.WithoutAbp.Dtos; +using AbpPerfTest.WithoutAbp.Entities; using AbpPerfTest.WithoutAbp.EntityFramework; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -33,5 +35,60 @@ namespace AbpPerfTest.WithoutAbp.Controllers }) .ToList(); } + + [HttpGet] + [Route("{id}")] + public async Task GetAsync(Guid id) + { + var book = await _bookDbContext.Books.SingleAsync(b => b.Id == id); + + return new BookDto + { + Id = book.Id, + Name = book.Name, + Price = book.Price, + IsAvailable = book.IsAvailable + }; + } + + [HttpPost] + public async Task CreateAsync(CreateUpdateBookDto input) + { + var book = new Book + { + Id = Guid.NewGuid(), + Name = input.Name, + Price = input.Price, + IsAvailable = input.IsAvailable + }; + + await _bookDbContext.Books.AddAsync(book); + await _bookDbContext.SaveChangesAsync(); + + return book.Id; + } + + [HttpPut] + [Route("{id}")] + public async Task UpdateAsync(Guid id, CreateUpdateBookDto input) + { + var book = await _bookDbContext.Books.SingleAsync(b => b.Id == id); + + book.Name = input.Name; + book.Price = input.Price; + book.IsAvailable = input.IsAvailable; + + await _bookDbContext.SaveChangesAsync(); + } + + [HttpDelete] + [Route("{id}")] + public async Task DeleteAsync(Guid id) + { + var book = await _bookDbContext.Books.SingleAsync(b => b.Id == id); + + _bookDbContext.Books.Remove(book); + await _bookDbContext.SaveChangesAsync(); + } } } diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Dtos/CreateUpdateBookDto.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Dtos/CreateUpdateBookDto.cs new file mode 100644 index 0000000000..f5af124a65 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Dtos/CreateUpdateBookDto.cs @@ -0,0 +1,11 @@ +namespace AbpPerfTest.WithoutAbp.Dtos +{ + public class CreateUpdateBookDto + { + public string Name { get; set; } + + public float Price { get; set; } + + public bool IsAvailable { get; set; } + } +} From 333540e5e848e711f4d347d8971d53074d465e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 22 Dec 2020 16:50:19 +0300 Subject: [PATCH 4/6] Added initial AbpPerfTest.WithAbp application. --- .../AbpPerfTest.WithAbp.csproj | 13 ++++++++ .../AbpPerfTest.WithAbp/AppModule.cs | 33 +++++++++++++++++++ .../AbpPerfTest.WithAbp/Program.cs | 21 ++++++++++++ .../Properties/launchSettings.json | 28 ++++++++++++++++ .../AbpPerfTest.WithAbp/Startup.cs | 18 ++++++++++ .../appsettings.Development.json | 9 +++++ .../AbpPerfTest.WithAbp/appsettings.json | 10 ++++++ test/AbpPerfTest/AbpPerfTest.sln | 6 ++++ 8 files changed, 138 insertions(+) create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/AbpPerfTest.WithAbp.csproj create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Program.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Properties/launchSettings.json create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Startup.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.Development.json create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.json diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/AbpPerfTest.WithAbp.csproj b/test/AbpPerfTest/AbpPerfTest.WithAbp/AbpPerfTest.WithAbp.csproj new file mode 100644 index 0000000000..41f8686caf --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/AbpPerfTest.WithAbp.csproj @@ -0,0 +1,13 @@ + + + + net5.0 + + + + + + + + + diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs new file mode 100644 index 0000000000..9c3de2cecf --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Hosting; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore.SqlServer; +using Volo.Abp.Modularity; + +namespace AbpPerfTest.WithAbp +{ + [DependsOn( + typeof(AbpAspNetCoreMvcModule), + typeof(AbpAutofacModule), + typeof(AbpEntityFrameworkCoreSqlServerModule) + )] + public class AppModule : AbpModule + { + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseConfiguredEndpoints(); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Program.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Program.cs new file mode 100644 index 0000000000..37b8418e62 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Program.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace AbpPerfTest.WithAbp +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac(); + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Properties/launchSettings.json b/test/AbpPerfTest/AbpPerfTest.WithAbp/Properties/launchSettings.json new file mode 100644 index 0000000000..a5d1af3797 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50732", + "sslPort": 44312 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "AbpPerfTest.WithAbp": { + "commandName": "Project", + "dotnetRunMessages": "true", + "launchBrowser": true, + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Startup.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Startup.cs new file mode 100644 index 0000000000..55d22b7dca --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; + +namespace AbpPerfTest.WithAbp +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app) + { + app.InitializeApplication(); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.Development.json b/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.Development.json new file mode 100644 index 0000000000..8983e0fc1c --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.json b/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.json new file mode 100644 index 0000000000..d9d9a9bff6 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/test/AbpPerfTest/AbpPerfTest.sln b/test/AbpPerfTest/AbpPerfTest.sln index 56f079c284..b8baba19de 100644 --- a/test/AbpPerfTest/AbpPerfTest.sln +++ b/test/AbpPerfTest/AbpPerfTest.sln @@ -2,6 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbpPerfTest.WithoutAbp", "AbpPerfTest.WithoutAbp\AbpPerfTest.WithoutAbp.csproj", "{E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbpPerfTest.WithAbp", "AbpPerfTest.WithAbp\AbpPerfTest.WithAbp.csproj", "{13021286-B5D8-4A3E-8F36-5256D32638A7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -12,5 +14,9 @@ Global {E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3406CA0-9B0C-45FC-A3C0-8179A9C4A3E5}.Release|Any CPU.Build.0 = Release|Any CPU + {13021286-B5D8-4A3E-8F36-5256D32638A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13021286-B5D8-4A3E-8F36-5256D32638A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13021286-B5D8-4A3E-8F36-5256D32638A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13021286-B5D8-4A3E-8F36-5256D32638A7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal From 085cf3e6c080421fb738c5a29fcfc52f0c21781c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 22 Dec 2020 17:04:18 +0300 Subject: [PATCH 5/6] Implemented test app with the ABP Framework. --- .../AbpPerfTest.WithAbp.csproj | 10 ++- .../AbpPerfTest.WithAbp/AppModule.cs | 18 +++- .../Controllers/BookController.cs | 86 +++++++++++++++++++ .../AbpPerfTest.WithAbp/Dtos/BookDto.cs | 15 ++++ .../Dtos/CreateUpdateBookDto.cs | 11 +++ .../AbpPerfTest.WithAbp/Entities/Book.cs | 19 ++++ .../EntityFramework/BookDbContext.cs | 28 ++++++ .../EntityFramework/BookDbContextFactory.cs | 29 +++++++ .../20201222135738_Added_Books.Designer.cs | 48 +++++++++++ .../Migrations/20201222135738_Added_Books.cs | 31 +++++++ .../Migrations/BookDbContextModelSnapshot.cs | 46 ++++++++++ .../AbpPerfTest.WithAbp/appsettings.json | 5 +- .../AbpPerfTest.WithoutAbp.csproj | 10 +-- .../Controllers/BookController.cs | 1 - .../AbpPerfTest.WithoutAbp/Entities/Book.cs | 5 ++ 15 files changed, 351 insertions(+), 11 deletions(-) create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Controllers/BookController.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Dtos/BookDto.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Dtos/CreateUpdateBookDto.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Entities/Book.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/EntityFramework/BookDbContext.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/EntityFramework/BookDbContextFactory.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/20201222135738_Added_Books.Designer.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/20201222135738_Added_Books.cs create mode 100644 test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/BookDbContextModelSnapshot.cs diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/AbpPerfTest.WithAbp.csproj b/test/AbpPerfTest/AbpPerfTest.WithAbp/AbpPerfTest.WithAbp.csproj index 41f8686caf..69e9c3802f 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithAbp/AbpPerfTest.WithAbp.csproj +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/AbpPerfTest.WithAbp.csproj @@ -5,9 +5,13 @@ - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs index 9c3de2cecf..a1accb54d9 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs @@ -1,8 +1,11 @@ -using Microsoft.AspNetCore.Builder; +using AbpPerfTest.WithAbp.EntityFramework; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.SqlServer; using Volo.Abp.Modularity; @@ -15,6 +18,19 @@ namespace AbpPerfTest.WithAbp )] public class AppModule : AbpModule { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => + { + options.AddDefaultRepositories(); + }); + + Configure(options => + { + options.UseSqlServer(); + }); + } + public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Controllers/BookController.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Controllers/BookController.cs new file mode 100644 index 0000000000..ed7bdb6a4d --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Controllers/BookController.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AbpPerfTest.WithAbp.Dtos; +using AbpPerfTest.WithAbp.Entities; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Domain.Repositories; + +namespace AbpPerfTest.WithAbp.Controllers +{ + [Route("api/books")] + public class BookController : Controller + { + private readonly IRepository _bookRepository; + + public BookController(IRepository bookRepository) + { + _bookRepository = bookRepository; + } + + [HttpGet] + public async Task> GetListAsync() + { + var books = await _bookRepository.GetListAsync(); + + return books + .Select(b => new BookDto + { + Id = b.Id, + Name = b.Name, + Price = b.Price, + IsAvailable = b.IsAvailable + }) + .ToList(); + } + + [HttpGet] + [Route("{id}")] + public async Task GetAsync(Guid id) + { + var book = await _bookRepository.GetAsync(id); + + return new BookDto + { + Id = book.Id, + Name = book.Name, + Price = book.Price, + IsAvailable = book.IsAvailable + }; + } + + [HttpPost] + public async Task CreateAsync(CreateUpdateBookDto input) + { + var book = new Book + { + Name = input.Name, + Price = input.Price, + IsAvailable = input.IsAvailable + }; + + await _bookRepository.InsertAsync(book); + + return book.Id; + } + + [HttpPut] + [Route("{id}")] + public async Task UpdateAsync(Guid id, CreateUpdateBookDto input) + { + var book = await _bookRepository.GetAsync(id); + + book.Name = input.Name; + book.Price = input.Price; + book.IsAvailable = input.IsAvailable; + } + + [HttpDelete] + [Route("{id}")] + public async Task DeleteAsync(Guid id) + { + await _bookRepository.DeleteAsync(id); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Dtos/BookDto.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Dtos/BookDto.cs new file mode 100644 index 0000000000..158fc86b52 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Dtos/BookDto.cs @@ -0,0 +1,15 @@ +using System; + +namespace AbpPerfTest.WithAbp.Dtos +{ + public class BookDto + { + public Guid Id { get; set; } + + public string Name { get; set; } + + public float Price { get; set; } + + public bool IsAvailable { get; set; } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Dtos/CreateUpdateBookDto.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Dtos/CreateUpdateBookDto.cs new file mode 100644 index 0000000000..fa3aa996f6 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Dtos/CreateUpdateBookDto.cs @@ -0,0 +1,11 @@ +namespace AbpPerfTest.WithAbp.Dtos +{ + public class CreateUpdateBookDto + { + public string Name { get; set; } + + public float Price { get; set; } + + public bool IsAvailable { get; set; } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Entities/Book.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Entities/Book.cs new file mode 100644 index 0000000000..75a94d7271 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Entities/Book.cs @@ -0,0 +1,19 @@ +using System; +using Volo.Abp.Domain.Entities; + +namespace AbpPerfTest.WithAbp.Entities +{ + public class Book : BasicAggregateRoot + { + public string Name { get; set; } + + public float Price { get; set; } + + public bool IsAvailable { get; set; } + + public Book() + { + Id = Guid.NewGuid(); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/EntityFramework/BookDbContext.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/EntityFramework/BookDbContext.cs new file mode 100644 index 0000000000..02e5f788cf --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/EntityFramework/BookDbContext.cs @@ -0,0 +1,28 @@ +using AbpPerfTest.WithAbp.Entities; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace AbpPerfTest.WithAbp.EntityFramework +{ + public class BookDbContext : AbpDbContext + { + public DbSet Books { get; set; } + + public BookDbContext(DbContextOptions builderOptions) + : base(builderOptions) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity(b => + { + b.ToTable("Books"); + b.Property(x => x.Name).HasMaxLength(128); + }); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/EntityFramework/BookDbContextFactory.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/EntityFramework/BookDbContextFactory.cs new file mode 100644 index 0000000000..b50975b8c2 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/EntityFramework/BookDbContextFactory.cs @@ -0,0 +1,29 @@ +using System.IO; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace AbpPerfTest.WithAbp.EntityFramework +{ + public class BookDbContextFactory : IDesignTimeDbContextFactory + { + public BookDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); + + return new BookDbContext(builder.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); + + return builder.Build(); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/20201222135738_Added_Books.Designer.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/20201222135738_Added_Books.Designer.cs new file mode 100644 index 0000000000..f8b3db4d21 --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/20201222135738_Added_Books.Designer.cs @@ -0,0 +1,48 @@ +// +using System; +using AbpPerfTest.WithAbp.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +namespace AbpPerfTest.WithAbp.Migrations +{ + [DbContext(typeof(BookDbContext))] + [Migration("20201222135738_Added_Books")] + partial class Added_Books + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseIdentityColumns() + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("AbpPerfTest.WithAbp.Entities.Book", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAvailable") + .HasColumnType("bit"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Price") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/20201222135738_Added_Books.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/20201222135738_Added_Books.cs new file mode 100644 index 0000000000..f61374b9dc --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/20201222135738_Added_Books.cs @@ -0,0 +1,31 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace AbpPerfTest.WithAbp.Migrations +{ + public partial class Added_Books : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Books", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Price = table.Column(type: "real", nullable: false), + IsAvailable = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Books", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Books"); + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/BookDbContextModelSnapshot.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/BookDbContextModelSnapshot.cs new file mode 100644 index 0000000000..8987a178df --- /dev/null +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/Migrations/BookDbContextModelSnapshot.cs @@ -0,0 +1,46 @@ +// +using System; +using AbpPerfTest.WithAbp.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +namespace AbpPerfTest.WithAbp.Migrations +{ + [DbContext(typeof(BookDbContext))] + partial class BookDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseIdentityColumns() + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("AbpPerfTest.WithAbp.Entities.Book", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAvailable") + .HasColumnType("bit"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Price") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.json b/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.json index d9d9a9bff6..9cd22c72c3 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.json +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/appsettings.json @@ -6,5 +6,8 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=AbpPerfTest_WithAbp;Trusted_Connection=True;MultipleActiveResultSets=true" + } } diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj index edf2ed6d58..fd061fe040 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/AbpPerfTest.WithoutAbp.csproj @@ -5,11 +5,11 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs index 96cb30eedd..c7b5746bc7 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Controllers/BookController.cs @@ -56,7 +56,6 @@ namespace AbpPerfTest.WithoutAbp.Controllers { var book = new Book { - Id = Guid.NewGuid(), Name = input.Name, Price = input.Price, IsAvailable = input.IsAvailable diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Entities/Book.cs b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Entities/Book.cs index 7a52830cf3..d33b5c309c 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Entities/Book.cs +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Entities/Book.cs @@ -11,5 +11,10 @@ namespace AbpPerfTest.WithoutAbp.Entities public float Price { get; set; } public bool IsAvailable { get; set; } + + public Book() + { + Id = Guid.NewGuid(); + } } } From b1a47de1b00bffd74ae664448b8c84687c7d4b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 22 Dec 2020 17:07:29 +0300 Subject: [PATCH 6/6] Disable transaction for the test project --- test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs | 6 ++++++ .../AbpPerfTest.WithoutAbp/Properties/launchSettings.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs b/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs index a1accb54d9..1cd88989e6 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs +++ b/test/AbpPerfTest/AbpPerfTest.WithAbp/AppModule.cs @@ -8,6 +8,7 @@ using Volo.Abp.Autofac; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.SqlServer; using Volo.Abp.Modularity; +using Volo.Abp.Uow; namespace AbpPerfTest.WithAbp { @@ -29,6 +30,11 @@ namespace AbpPerfTest.WithAbp { options.UseSqlServer(); }); + + Configure(options => + { + options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; + }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Properties/launchSettings.json b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Properties/launchSettings.json index 07aa90a5da..74f1d25f0e 100644 --- a/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Properties/launchSettings.json +++ b/test/AbpPerfTest/AbpPerfTest.WithoutAbp/Properties/launchSettings.json @@ -19,7 +19,7 @@ "commandName": "Project", "dotnetRunMessages": "true", "launchBrowser": true, - "applicationUrl": "https://localhost:5001;http://localhost:5000", + "applicationUrl": "https://localhost:5003;http://localhost:5002", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }