{"id":460896,"date":"2025-05-24T21:06:22","date_gmt":"2025-05-24T21:06:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=460896"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=460896","title":{"rendered":"<span>\u041f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c CQRS<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u0438\u043c\u043b\u0438\u0434 \u0438\u043b\u0438\u00a0\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440, \u0438 \u0432\u00a0\u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0432\u0441\u0451 \u0447\u0430\u0449\u0435 \u0437\u0432\u0443\u0447\u0438\u0442 \u00ab\u0434\u0430\u0432\u0430\u0439 \u0441\u0434\u0435\u043b\u0430\u0435\u043c CQRS\u00bb\u00a0\u2014 \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f. \u042d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043c\u043e\u0449\u043d\u044b\u0439, \u043d\u043e\u00a0\u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435\u00a0\u0431\u0435\u0441\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0439. <\/p>\n<h4>\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043e CQRS, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c Entity Framework \u0438 SaveChanges()?<\/h4>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u00a0\u2014 \u0432\u00a0\u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435. \u041b\u044e\u0431\u043e\u0439 \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u043a\u043e\u0433\u0434\u0430\u2011\u043d\u0438\u0431\u0443\u0434\u044c \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432\u00a0\u0434\u0438\u0441\u043a\/CPU\/\u043a\u043e\u043c\u0430\u043d\u0434\u0443 DevOps. CQRS \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e. \u0412\u00a0\u0442\u0435\u043e\u0440\u0438\u0438 \u2500 \u0432\u0440\u043e\u0434\u0435 \u043e\u043a:<\/p>\n<ul>\n<li>\n<p><strong>Write\u2011\u043c\u043e\u0434\u0435\u043b\u044c<\/strong> \u0437\u0430\u0442\u043e\u0447\u0435\u043d\u0430 \u043f\u043e\u0434\u00a0\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c, \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c through\u2011put.<\/p>\n<\/li>\n<li>\n<p><strong>Read\u2011\u043c\u043e\u0434\u0435\u043b\u044c<\/strong> \u043b\u043e\u043c\u0438\u0442\u0441\u044f \u043e\u0442\u00a0\u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0434\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>Microsoft \u0440\u0438\u0441\u0443\u0435\u0442 \u044d\u0442\u043e \u043d\u0430\u00a0\u0441\u0432\u043e\u0438\u0445 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430\u0445 \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442. \u041d\u043e\u00a0\u0446\u0435\u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u00a0\u2014 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c. <\/p>\n<h3>\u041b\u0438\u0448\u043d\u0438\u0439 \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u0434\u043b\u044f \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e CRUD<\/h3>\n<p>\u0423\u00a0\u043d\u0430\u0441 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 <code>Customers<\/code>, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c <code>DbSet&lt;Customer&gt;<\/code>? \u0412\u00a0CQRS \u043d\u0430\u00a0\u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439 <code>Customer<\/code> \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"151\" width=\"151\">\n<p align=\"left\">\u0421\u043b\u043e\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e\u00a0\u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>\u041a\u043e\u043c\u0430\u043d\u0434\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>CreateCustomerCommand<\/code>, <code>UpdateCustomerCommand<\/code>, \u2026<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>CreateCustomerHandler<\/code>, <code>UpdateCustomerHandler<\/code>, \u2026<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>DTO<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>CustomerDto<\/code>, <code>CustomerDetailsVm<\/code>, \u2026<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>\u041c\u0430\u043f\u043f\u0438\u043d\u0433<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">AutoMapper\u2011\u043f\u0440\u043e\u0444\u0438\u043b\u0438 \u0442\u0443\u0434\u0430\u2011\u0441\u044e\u0434\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>\u0422\u0435\u0441\u0442\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u00d72: \u043d\u0430\u00a0write \u0438 \u043d\u0430\u00a0read<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u042d\u0442\u043e \u0448\u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e <em>\u043e\u0434\u043d\u043e\u0439<\/em> \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0418 \u043f\u043e\u043a\u0430 \u0432\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430\u00a0pull\u2011request, \u0431\u0438\u0437\u043d\u0435\u0441 \u0436\u0434\u0451\u0442 \u0444\u0438\u0447\u0443. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u00a0StackOverflow <a href=\"https:\/\/softwareengineering.stackexchange.com\/questions\/442092\/cqrs-in-a-data-heavy-application-involving-a-lot-of-crud\">\u043f\u043b\u0430\u043a\u0430\u043b\u0438<\/a>, \u0447\u0442\u043e\u00a0CQRS \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u0435\u043d \u0432\u00a0data\u2011heavy \u0444\u043e\u0440\u043c\u0430\u0445<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440:<\/h4>\n<p>\u0411\u0435\u0437\u00a0CQRS<\/p>\n<pre><code class=\"cs\">public async Task&lt;IActionResult&gt; Post(CustomerDto dto) {     var entity = _mapper.Map&lt;Customer&gt;(dto);     _db.Customers.Add(entity);     await _db.SaveChangesAsync();     return Ok(); }<\/code><\/pre>\n<p>\u0421\u00a0CQRS + MediatR<\/p>\n<pre><code class=\"cs\">\/\/ 1. Command public record CreateCustomerCommand(string Name, string Email) : IRequest&lt;Guid&gt;;  \/\/ 2. Handler public class CreateCustomerHandler : IRequestHandler&lt;CreateCustomerCommand, Guid&gt; {     private readonly AppDbContext _db;     public async Task&lt;Guid&gt; Handle(CreateCustomerCommand cmd, CancellationToken ct)     {         var entity = new Customer { Name = cmd.Name, Email = cmd.Email };         _db.Customers.Add(entity);         await _db.SaveChangesAsync(ct);         return entity.Id;     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u00a0\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 read\u2011\u043c\u043e\u0434\u0435\u043b\u0438, \u0438 \u0431\u043e\u043d\u0443\u0441\u043e\u043c\u00a0\u2014 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430, \u043e\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u00a0\u0432\u0430\u0441 \u043d\u0435\u0442 <em>\u044f\u0432\u043d\u043e\u0439<\/em> \u043f\u0440\u0438\u0447\u0438\u043d\u044b (\u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430\u00a0\u0447\u0442\u0435\u043d\u0438\u0435 &gt; \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430\u00a0\u0437\u0430\u043f\u0438\u0441\u044c, \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441 \u0436\u0438\u0432\u0451\u0442 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e, \u043d\u0443\u0436\u043d\u0430 \u0434\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f), \u043d\u0435\u00a0\u0442\u0440\u043e\u0433\u0430\u0439\u0442\u0435 CQRS.<\/p>\n<h3>\u041a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c <\/h3>\n<p>\u0415\u0441\u0442\u044c \u043a\u0435\u0439\u0441 \u0432\u00a0Amazon, \u043a\u043e\u0433\u0434\u0430 \u0442\u043e\u0432\u0430\u0440 \u043f\u043e\u043b\u043e\u0436\u0438\u043b\u0438 \u0432\u00a0\u043a\u043e\u0440\u0437\u0438\u043d\u0443, \u0430\u00a0\u043f\u0440\u0438\u00a0\u043e\u043f\u043b\u0430\u0442\u0435 \u043a\u043e\u0440\u0437\u0438\u043d\u0430 \u043f\u0443\u0441\u0442\u0430. <\/p>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430: write\u2011\u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u0441\u0442\u0440\u0435\u043b\u044f\u043b\u0430\u0441\u044c (\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430), \u0430\u00a0read\u2011\u043c\u043e\u0434\u0435\u043b\u044c \u0435\u0449\u0451 \u043d\u0435\u00a0\u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. <\/p>\n<h4>\u041a\u0430\u043a \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0431\u0430\u0433 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e<\/h4>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>AddToCart<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>CartReadModel<\/code> \u0441\u043b\u0443\u0448\u0430\u0435\u043c <code>ProductAdded<\/code> \u0438 \u0430\u043f\u0434\u0435\u0439\u0442\u0438\u043c denormalized view.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u0435\u043b\u044f\u0435\u043c 1000\u00a0\u043a\u043e\u043c\u0430\u043d\u0434.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0436\u0434\u0443 <code>AddToCart<\/code> \u0438 GET <code>\/cart<\/code>\u00a0\u2014 100\u00a0\u043c\u0441. \u0427\u0430\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u0435\u0440\u043d\u0451\u0442 \u043f\u0443\u0441\u0442\u0443\u044e \u043a\u043e\u0440\u0437\u0438\u043d\u0443.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">\/\/ \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434 Parallel.For(0, 1000, _ =&gt; {     _bus.Send(new AddToCart(userId, productId));     var cart = _api.GetCart(userId); \/\/ \u0448\u0430\u043d\u0441 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0448\u043b\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e });<\/code><\/pre>\n<h4>\u0421\u043c\u044f\u0433\u0447\u0430\u0435\u043c \u0431\u043e\u043b\u044c<\/h4>\n<ul>\n<li>\n<p><strong>Read\u2011your\u2011write<\/strong>: \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u00a0write\u2011storage (Postgres \u2192 <code>RETURNING<\/code>)<\/p>\n<\/li>\n<li>\n<p><strong>Versioning\/ETag<\/strong>: \u0444\u0440\u043e\u043d\u0442 \u0436\u0434\u0451\u0442, \u043f\u043e\u043a\u0430 <code>cart.version<\/code> \u2265 <code>commandVersion<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>Outbox Pattern<\/strong>: \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043c\u0438\u0442\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438; \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e\u00a0read\u2011\u043f\u0440\u043e\u0435\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0432\u0441\u0435 \u0438\u0432\u0435\u043d\u0442\u044b \u0432\u00a0\u043d\u0443\u0436\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0441\u0441\u0438\u043c\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u0439 UX<\/strong>: disable \u043a\u043d\u043e\u043f\u043a\u0430 \u00abPay\u00bb \u0434\u043e\u00a0\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e RPC.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0430\u0441\u0442\u043d\u044b\u0435 vs \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>\u0414\u0435\u043b\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 <strong>private draft<\/strong> \u0438 <strong>public published<\/strong>. \u0412\u00a0\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c \u044d\u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e (\u00ab\u0427\u0435\u0440\u043d\u043e\u0432\u0438\u043a\u00bb \u0438 \u00ab\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u00bb), \u043d\u043e\u00a0\u0434\u043b\u044f\u00a0\u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u2011\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0437\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e: \u00ab\u041a\u043e\u0440\u0437\u0438\u043d\u0430\u00a0\u2014 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u0430\u044f, \u0417\u0430\u043a\u0430\u0437\u00a0\u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439\u00bb.<\/p>\n<p>\u041f\u043e\u043a\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0436\u0438\u0432\u0451\u0442 \u0432\u00a0\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0439 \u0437\u043e\u043d\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f \u0441\u00a0eventual consistency, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u00a0\u0432\u0438\u0434\u0438\u0442 \u0435\u0433\u043e \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. \u041a\u043e\u0433\u0434\u0430\u00a0\u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c (\u0442\u043e\u0432\u0430\u0440 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0432 \u00ab\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f\u0445\u00bb), \u043b\u0430\u0433 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432\u00a0\u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u043d\u0438\u043a\u043e\u0432 \u0443\u00a0\u0440\u0430\u0437\u043d\u044b\u0445 \u044e\u0437\u0435\u0440\u043e\u0432.<\/p>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e:<\/p>\n<pre><code class=\"cs\">\u041f\u043b\u043e\u0445\u043e\u0439 API POST \/products    \/\/ \u0441\u0440\u0430\u0437\u0443 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e  \u0425\u043e\u0440\u043e\u0448\u0438\u0439 API POST \/products\/drafts POST \/products\/{id}\/publish   \/\/ \u044f\u0432\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0441\u043f\u043b\u044b\u0442\u0438\u044f \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441\u0443 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0442\u0435\u0440\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f.<\/p>\n<h3>\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435: \u043a\u043e\u0433\u0434\u0430 read-\u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u0437\u0430 write-\u043c\u043e\u0434\u0435\u043b\u044c\u044e<\/h3>\n<p>\u041f\u0440\u0438\u00a0\u043f\u0438\u043a\u043e\u0432\u044b\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u0445 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043e\u0431\u0433\u043e\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0440. Read\u2011\u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u0441\u0442\u0430\u0451\u0442 \u043d\u0430\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u043c\u0438\u043d\u0443\u0442\u044b, \u0447\u0430\u0441\u044b. \u041d\u0430\u00a0InfoQ \u043e\u0431\u00a0\u044d\u0442\u043e\u043c \u043f\u0438\u0441\u0430\u043b\u0438\u00a0\u2014 \u00ab<a href=\"https:\/\/www.infoq.com\/news\/2019\/09\/cqrs-event-sourcing-production\/\">Day Two Problems<\/a>\u00bb.<\/p>\n<h4>\u0412\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0440\u0435\u0437 \u043f\u0440\u043e\u0442\u0438\u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432<\/h4>\n<p>\u0421\u0442\u0440\u043e\u0438\u043c \u0444\u0438\u0447\u0443 \u043a\u0430\u043a\u00a0\u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0440\u0435\u0437\u00a0\u2014 \u043e\u0442\u00a0\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0434\u043e\u00a0\u0411\u0414\u00a0\u2014 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0435\u0451 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e.<\/p>\n<p>\u041d\u0430\u00a0\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0440\u0435\u0437 + CQRS \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">\/Features   \/Orders     Create.cs     CreateValidator.cs     CreateHandler.cs     OrderReadModel.cs<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043f\u0430\u043f\u043a\u0430\u00a0\u2014 \u043c\u0438\u043d\u0438\u2011\u0440\u0435\u0437\u0435\u0440\u0442. \u0425\u043e\u0442\u0438\u0442\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c? \u0414\u0435\u043f\u043b\u043e\u0439\u0442\u0435 <code>\/Orders<\/code> \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0430 <code>Users<\/code>\u00a0\u2014 \u0432\u00a0\u0434\u0440\u0443\u0433\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435. Read\u2011\u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438, \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442\u00a0\u0431\u044b\u0442\u044c \u0435\u0434\u0438\u043d\u043e\u0439 \u00ab\u0442\u043e\u0447\u043a\u043e\u0439 \u043f\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u00bb.<\/p>\n<h3>\u041a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445: \u00ab\u0433\u0440\u044f\u0437\u043d\u044b\u0435\u00bb \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u0421\u043e\u0431\u044b\u0442\u0438\u044f\u00a0\u2014 \u044d\u0442\u043e <em>\u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u0430\u0432\u0434\u0430<\/em>. \u041d\u043e\u00a0\u0435\u0441\u043b\u0438 \u0438\u0445 \u0441\u0445\u0435\u043c\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0435 \u0434\u0432\u0435 \u043d\u0435\u0434\u0435\u043b\u0438, \u043b\u044e\u0431\u0430\u044f read\u2011\u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u044b\u043f\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u0432\u044b \u0434\u043e\u0433\u043e\u043d\u044f\u0435\u0442\u0435 \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f. <\/p>\n<p>\u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0435\u043c:<\/p>\n<ol>\n<li>\n<p><strong>Immutable events<\/strong>: \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f\u00a0\u2014 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0441\u043e\u0431\u044b\u0442\u0438\u044f (<code>ProductPriceChangedV2<\/code>).<\/p>\n<\/li>\n<li>\n<p><strong>Upcasters<\/strong>: \u043f\u0440\u0438\u00a0\u0447\u0442\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u0440\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a\u00a0\u043d\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>Golden tests<\/strong>: \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f payload\u2011\u043e\u0432 \u0432\u00a0\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 (snapshot\u2011\u0442\u0435\u0441\u0442\u044b), \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043d\u0435\u00a0\u0441\u043b\u043e\u043c\u0430\u0442\u044c back\u2011compat.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u043e\u0433\u0434\u0430 CQRS \u0441\u0442\u043e\u0438\u0442 \u0442\u043e\u0433\u043e<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u0421\u0438\u043c\u043f\u0442\u043e\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">CQRS \u0441\u043f\u0430\u0441\u0430\u0435\u0442?<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">90% \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\u00a0\u2014 \u0447\u0442\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0414\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u041d\u0443\u0436\u043d\u043e\u00a0\u043b\u0438\u043d\u0435\u0439\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0414\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u041f\u0440\u043e\u0441\u0442\u043e\u0439 CRUD \u0431\u0435\u0437\u00a0\u043e\u0442\u0447\u0451\u0442\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u041d\u0435\u0442<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 5\u00a0\u0442\u0430\u0431\u043b\u0438\u0446<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0421\u043a\u043e\u0440\u0435\u0435 \u043d\u0435\u0442<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u0414\u043e\u043c\u0435\u043d\u0430 \u0441\u043b\u043e\u0436\u043d\u0430\u044f, \u0431\u0438\u0437\u043d\u0435\u0441\u2011\u0438\u043dvariants \u0442\u044f\u0436\u0451\u043b\u044b\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0427\u0430\u0441\u0442\u043e \u0434\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0439\u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043e\u0442\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u043e\u0442\u00a0\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e, \u043d\u0435\u00a0\u0431\u043e\u0439\u0442\u0435\u0441\u044c \u0432\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u00a0\u2014 \u0438 \u0432\u044b \u0438\u0437\u0431\u0435\u0436\u0438\u0442\u0435 \u0442\u0435\u0445 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439.<\/p>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u043e \u0435\u0449\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/architecture\/patterns\/cqrs\">\u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<hr\/>\n<p>\u041a\u0430\u043a \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440 \u0438\u043b\u0438 \u0442\u0438\u043c\u043b\u0438\u0434, \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443. OTUS \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043a\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 \u0432 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 IT-\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u2014 \u043e\u0442 DevOps \u0434\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. \u042d\u0442\u043e \u0433\u0438\u0431\u043a\u0438\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441 \u0430\u043a\u0446\u0435\u043d\u0442\u043e\u043c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0433\u043a\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. <a href=\"https:\/\/otus.pw\/vkn9\/\">\u0423\u0437\u043d\u0430\u0439\u0442\u0435, \u043a\u0430\u043a OTUS \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/a> \u0438 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c IT-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/911318\/\"> https:\/\/habr.com\/ru\/articles\/911318\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u0438\u043c\u043b\u0438\u0434 \u0438\u043b\u0438\u00a0\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440, \u0438 \u0432\u00a0\u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0432\u0441\u0451 \u0447\u0430\u0449\u0435 \u0437\u0432\u0443\u0447\u0438\u0442 \u00ab\u0434\u0430\u0432\u0430\u0439 \u0441\u0434\u0435\u043b\u0430\u0435\u043c CQRS\u00bb\u00a0\u2014 \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f. \u042d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043c\u043e\u0449\u043d\u044b\u0439, \u043d\u043e\u00a0\u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435\u00a0\u0431\u0435\u0441\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0439. <\/p>\n<h4>\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043e CQRS, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c Entity Framework \u0438 SaveChanges()?<\/h4>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u00a0\u2014 \u0432\u00a0\u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435. \u041b\u044e\u0431\u043e\u0439 \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u043a\u043e\u0433\u0434\u0430\u2011\u043d\u0438\u0431\u0443\u0434\u044c \u0443\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432\u00a0\u0434\u0438\u0441\u043a\/CPU\/\u043a\u043e\u043c\u0430\u043d\u0434\u0443 DevOps. CQRS \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e. \u0412\u00a0\u0442\u0435\u043e\u0440\u0438\u0438 \u2500 \u0432\u0440\u043e\u0434\u0435 \u043e\u043a:<\/p>\n<ul>\n<li>\n<p><strong>Write\u2011\u043c\u043e\u0434\u0435\u043b\u044c<\/strong> \u0437\u0430\u0442\u043e\u0447\u0435\u043d\u0430 \u043f\u043e\u0434\u00a0\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c, \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c through\u2011put.<\/p>\n<\/li>\n<li>\n<p><strong>Read\u2011\u043c\u043e\u0434\u0435\u043b\u044c<\/strong> \u043b\u043e\u043c\u0438\u0442\u0441\u044f \u043e\u0442\u00a0\u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0434\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>Microsoft \u0440\u0438\u0441\u0443\u0435\u0442 \u044d\u0442\u043e \u043d\u0430\u00a0\u0441\u0432\u043e\u0438\u0445 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0445 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430\u0445 \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442. \u041d\u043e\u00a0\u0446\u0435\u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u00a0\u2014 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c. <\/p>\n<h3>\u041b\u0438\u0448\u043d\u0438\u0439 \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u0434\u043b\u044f \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e CRUD<\/h3>\n<p>\u0423\u00a0\u043d\u0430\u0441 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430 <code>Customers<\/code>, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c <code>DbSet&lt;Customer&gt;<\/code>? \u0412\u00a0CQRS \u043d\u0430\u00a0\u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439 <code>Customer<\/code> \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"151\" width=\"151\">\n<p align=\"left\">\u0421\u043b\u043e\u0439<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0427\u0442\u043e\u00a0\u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>\u041a\u043e\u043c\u0430\u043d\u0434\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>CreateCustomerCommand<\/code>, <code>UpdateCustomerCommand<\/code>, \u2026<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>CreateCustomerHandler<\/code>, <code>UpdateCustomerHandler<\/code>, \u2026<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>DTO<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><code>CustomerDto<\/code>, <code>CustomerDetailsVm<\/code>, \u2026<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>\u041c\u0430\u043f\u043f\u0438\u043d\u0433<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">AutoMapper\u2011\u043f\u0440\u043e\u0444\u0438\u043b\u0438 \u0442\u0443\u0434\u0430\u2011\u0441\u044e\u0434\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"151\" width=\"151\">\n<p align=\"left\"><strong>\u0422\u0435\u0441\u0442\u044b<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u00d72: \u043d\u0430\u00a0write \u0438 \u043d\u0430\u00a0read<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u042d\u0442\u043e \u0448\u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e <em>\u043e\u0434\u043d\u043e\u0439<\/em> \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0418 \u043f\u043e\u043a\u0430 \u0432\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430\u00a0pull\u2011request, \u0431\u0438\u0437\u043d\u0435\u0441 \u0436\u0434\u0451\u0442 \u0444\u0438\u0447\u0443. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u00a0StackOverflow <a href=\"https:\/\/softwareengineering.stackexchange.com\/questions\/442092\/cqrs-in-a-data-heavy-application-involving-a-lot-of-crud\">\u043f\u043b\u0430\u043a\u0430\u043b\u0438<\/a>, \u0447\u0442\u043e\u00a0CQRS \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u0435\u043d \u0432\u00a0data\u2011heavy \u0444\u043e\u0440\u043c\u0430\u0445<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440:<\/h4>\n<p>\u0411\u0435\u0437\u00a0CQRS<\/p>\n<pre><code class=\"cs\">public async Task&lt;IActionResult&gt; Post(CustomerDto dto) {     var entity = _mapper.Map&lt;Customer&gt;(dto);     _db.Customers.Add(entity);     await _db.SaveChangesAsync();     return Ok(); }<\/code><\/pre>\n<p>\u0421\u00a0CQRS + MediatR<\/p>\n<pre><code class=\"cs\">\/\/ 1. Command public record CreateCustomerCommand(string Name, string Email) : IRequest&lt;Guid&gt;;  \/\/ 2. Handler public class CreateCustomerHandler : IRequestHandler&lt;CreateCustomerCommand, Guid&gt; {     private readonly AppDbContext _db;     public async Task&lt;Guid&gt; Handle(CreateCustomerCommand cmd, CancellationToken ct)     {         var entity = new Customer { Name = cmd.Name, Email = cmd.Email };         _db.Customers.Add(entity);         await _db.SaveChangesAsync(ct);         return entity.Id;     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u00a0\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 read\u2011\u043c\u043e\u0434\u0435\u043b\u0438, \u0438 \u0431\u043e\u043d\u0443\u0441\u043e\u043c\u00a0\u2014 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430, \u043e\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u00a0\u0432\u0430\u0441 \u043d\u0435\u0442 <em>\u044f\u0432\u043d\u043e\u0439<\/em> \u043f\u0440\u0438\u0447\u0438\u043d\u044b (\u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430\u00a0\u0447\u0442\u0435\u043d\u0438\u0435 &gt; \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430\u00a0\u0437\u0430\u043f\u0438\u0441\u044c, \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441 \u0436\u0438\u0432\u0451\u0442 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e, \u043d\u0443\u0436\u043d\u0430 \u0434\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f), \u043d\u0435\u00a0\u0442\u0440\u043e\u0433\u0430\u0439\u0442\u0435 CQRS.<\/p>\n<h3>\u041a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c <\/h3>\n<p>\u0415\u0441\u0442\u044c \u043a\u0435\u0439\u0441 \u0432\u00a0Amazon, \u043a\u043e\u0433\u0434\u0430 \u0442\u043e\u0432\u0430\u0440 \u043f\u043e\u043b\u043e\u0436\u0438\u043b\u0438 \u0432\u00a0\u043a\u043e\u0440\u0437\u0438\u043d\u0443, \u0430\u00a0\u043f\u0440\u0438\u00a0\u043e\u043f\u043b\u0430\u0442\u0435 \u043a\u043e\u0440\u0437\u0438\u043d\u0430 \u043f\u0443\u0441\u0442\u0430. <\/p>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430: write\u2011\u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u0441\u0442\u0440\u0435\u043b\u044f\u043b\u0430\u0441\u044c (\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430), \u0430\u00a0read\u2011\u043c\u043e\u0434\u0435\u043b\u044c \u0435\u0449\u0451 \u043d\u0435\u00a0\u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. <\/p>\n<h4>\u041a\u0430\u043a \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0431\u0430\u0433 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e<\/h4>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>AddToCart<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>CartReadModel<\/code> \u0441\u043b\u0443\u0448\u0430\u0435\u043c <code>ProductAdded<\/code> \u0438 \u0430\u043f\u0434\u0435\u0439\u0442\u0438\u043c denormalized view.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u0435\u043b\u044f\u0435\u043c 1000\u00a0\u043a\u043e\u043c\u0430\u043d\u0434.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0436\u0434\u0443 <code>AddToCart<\/code> \u0438 GET <code>\/cart<\/code>\u00a0\u2014 100\u00a0\u043c\u0441. \u0427\u0430\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u0435\u0440\u043d\u0451\u0442 \u043f\u0443\u0441\u0442\u0443\u044e \u043a\u043e\u0440\u0437\u0438\u043d\u0443.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">\/\/ \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434 Parallel.For(0, 1000, _ =&gt; {     _bus.Send(new AddToCart(userId, productId));     var cart = _api.GetCart(userId); \/\/ \u0448\u0430\u043d\u0441 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0448\u043b\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e });<\/code><\/pre>\n<h4>\u0421\u043c\u044f\u0433\u0447\u0430\u0435\u043c \u0431\u043e\u043b\u044c<\/h4>\n<ul>\n<li>\n<p><strong>Read\u2011your\u2011write<\/strong>: \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u00a0write\u2011storage (Postgres \u2192 <code>RETURNING<\/code>)<\/p>\n<\/li>\n<li>\n<p><strong>Versioning\/ETag<\/strong>: \u0444\u0440\u043e\u043d\u0442 \u0436\u0434\u0451\u0442, \u043f\u043e\u043a\u0430 <code>cart.version<\/code> \u2265 <code>commandVersion<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>Outbox Pattern<\/strong>: \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043c\u0438\u0442\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438; \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e\u00a0read\u2011\u043f\u0440\u043e\u0435\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0432\u0441\u0435 \u0438\u0432\u0435\u043d\u0442\u044b \u0432\u00a0\u043d\u0443\u0436\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0441\u0441\u0438\u043c\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u0439 UX<\/strong>: disable \u043a\u043d\u043e\u043f\u043a\u0430 \u00abPay\u00bb \u0434\u043e\u00a0\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e RPC.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0430\u0441\u0442\u043d\u044b\u0435 vs \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>\u0414\u0435\u043b\u0438\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 <strong>private draft<\/strong> \u0438 <strong>public published<\/strong>. \u0412\u00a0\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c \u044d\u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e (\u00ab\u0427\u0435\u0440\u043d\u043e\u0432\u0438\u043a\u00bb \u0438 \u00ab\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u00bb), \u043d\u043e\u00a0\u0434\u043b\u044f\u00a0\u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u2011\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0437\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e: \u00ab\u041a\u043e\u0440\u0437\u0438\u043d\u0430\u00a0\u2014 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u0430\u044f, \u0417\u0430\u043a\u0430\u0437\u00a0\u2014 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439\u00bb.<\/p>\n<p>\u041f\u043e\u043a\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0436\u0438\u0432\u0451\u0442 \u0432\u00a0\u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0439 \u0437\u043e\u043d\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f \u0441\u00a0eventual consistency, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u00a0\u0432\u0438\u0434\u0438\u0442 \u0435\u0433\u043e \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. \u041a\u043e\u0433\u0434\u0430\u00a0\u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c (\u0442\u043e\u0432\u0430\u0440 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0432 \u00ab\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f\u0445\u00bb), \u043b\u0430\u0433 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432\u00a0\u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u043d\u0438\u043a\u043e\u0432 \u0443\u00a0\u0440\u0430\u0437\u043d\u044b\u0445 \u044e\u0437\u0435\u0440\u043e\u0432.<\/p>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e:<\/p>\n<pre><code class=\"cs\">\u041f\u043b\u043e\u0445\u043e\u0439 API POST \/products    \/\/ \u0441\u0440\u0430\u0437\u0443 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e  \u0425\u043e\u0440\u043e\u0448\u0438\u0439 API POST \/products\/drafts POST \/products\/{id}\/publish   \/\/ \u044f\u0432\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0441\u043f\u043b\u044b\u0442\u0438\u044f \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441\u0443 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0442\u0435\u0440\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f.<\/p>\n<h3>\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435: \u043a\u043e\u0433\u0434\u0430 read-\u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u0437\u0430 write-\u043c\u043e\u0434\u0435\u043b\u044c\u044e<\/h3>\n<p>\u041f\u0440\u0438\u00a0\u043f\u0438\u043a\u043e\u0432\u044b\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u0445 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043e\u0431\u0433\u043e\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0440. Read\u2011\u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u0441\u0442\u0430\u0451\u0442 \u043d\u0430\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u043c\u0438\u043d\u0443\u0442\u044b, \u0447\u0430\u0441\u044b. \u041d\u0430\u00a0InfoQ \u043e\u0431\u00a0\u044d\u0442\u043e\u043c \u043f\u0438\u0441\u0430\u043b\u0438\u00a0\u2014 \u00ab<a href=\"https:\/\/www.infoq.com\/news\/2019\/09\/cqrs-event-sourcing-production\/\">Day Two Problems<\/a>\u00bb.<\/p>\n<h4>\u0412\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0440\u0435\u0437 \u043f\u0440\u043e\u0442\u0438\u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432<\/h4>\n<p>\u0421\u0442\u0440\u043e\u0438\u043c \u0444\u0438\u0447\u0443 \u043a\u0430\u043a\u00a0\u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0440\u0435\u0437\u00a0\u2014 \u043e\u0442\u00a0\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0434\u043e\u00a0\u0411\u0414\u00a0\u2014 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0435\u0451 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e.<\/p>\n<p>\u041d\u0430\u00a0\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0440\u0435\u0437 + CQRS \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">\/Features   \/Orders     Create.cs     CreateValidator.cs     CreateHandler.cs     OrderReadModel.cs<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043f\u0430\u043f\u043a\u0430\u00a0\u2014 \u043c\u0438\u043d\u0438\u2011\u0440\u0435\u0437\u0435\u0440\u0442. \u0425\u043e\u0442\u0438\u0442\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c? \u0414\u0435\u043f\u043b\u043e\u0439\u0442\u0435 <code>\/Orders<\/code> \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0430 <code>Users<\/code>\u00a0\u2014 \u0432\u00a0\u0434\u0440\u0443\u0433\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435. Read\u2011\u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438, \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442\u00a0\u0431\u044b\u0442\u044c \u0435\u0434\u0438\u043d\u043e\u0439 \u00ab\u0442\u043e\u0447\u043a\u043e\u0439 \u043f\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u00bb.<\/p>\n<h3>\u041a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445: \u00ab\u0433\u0440\u044f\u0437\u043d\u044b\u0435\u00bb \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u0421\u043e\u0431\u044b\u0442\u0438\u044f\u00a0\u2014 \u044d\u0442\u043e <em>\u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u0430\u0432\u0434\u0430<\/em>. \u041d\u043e\u00a0\u0435\u0441\u043b\u0438 \u0438\u0445 \u0441\u0445\u0435\u043c\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0435 \u0434\u0432\u0435 \u043d\u0435\u0434\u0435\u043b\u0438, \u043b\u044e\u0431\u0430\u044f read\u2011\u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u044b\u043f\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u0432\u044b \u0434\u043e\u0433\u043e\u043d\u044f\u0435\u0442\u0435 \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f. <\/p>\n<p>\u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0435\u043c:<\/p>\n<ol>\n<li>\n<p><strong>Immutable events<\/strong>: \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f\u00a0\u2014 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0441\u043e\u0431\u044b\u0442\u0438\u044f (<code>ProductPriceChangedV2<\/code>).<\/p>\n<\/li>\n<li>\n<p><strong>Upcasters<\/strong>: \u043f\u0440\u0438\u00a0\u0447\u0442\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u0440\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a\u00a0\u043d\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>Golden tests<\/strong>: \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f payload\u2011\u043e\u0432 \u0432\u00a0\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 (snapshot\u2011\u0442\u0435\u0441\u0442\u044b), \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043d\u0435\u00a0\u0441\u043b\u043e\u043c\u0430\u0442\u044c back\u2011compat.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u043e\u0433\u0434\u0430 CQRS \u0441\u0442\u043e\u0438\u0442 \u0442\u043e\u0433\u043e<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u0421\u0438\u043c\u043f\u0442\u043e\u043c<\/p>\n<\/th>\n<th>\n<p align=\"left\">CQRS \u0441\u043f\u0430\u0441\u0430\u0435\u0442?<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">90% \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\u00a0\u2014 \u0447\u0442\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0414\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u041d\u0443\u0436\u043d\u043e\u00a0\u043b\u0438\u043d\u0435\u0439\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0414\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u041f\u0440\u043e\u0441\u0442\u043e\u0439 CRUD \u0431\u0435\u0437\u00a0\u043e\u0442\u0447\u0451\u0442\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u041d\u0435\u0442<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 5\u00a0\u0442\u0430\u0431\u043b\u0438\u0446<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0421\u043a\u043e\u0440\u0435\u0435 \u043d\u0435\u0442<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"528\" width=\"528\">\n<p align=\"left\">\u0414\u043e\u043c\u0435\u043d\u0430 \u0441\u043b\u043e\u0436\u043d\u0430\u044f, \u0431\u0438\u0437\u043d\u0435\u0441\u2011\u0438\u043dvariants \u0442\u044f\u0436\u0451\u043b\u044b\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0427\u0430\u0441\u0442\u043e \u0434\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0439\u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043e\u0442\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u043e\u0442\u00a0\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e, \u043d\u0435\u00a0\u0431\u043e\u0439\u0442\u0435\u0441\u044c \u0432\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u00a0\u2014 \u0438 \u0432\u044b \u0438\u0437\u0431\u0435\u0436\u0438\u0442\u0435 \u0442\u0435\u0445 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439.<\/p>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u043e \u0435\u0449\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/architecture\/patterns\/cqrs\">\u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<hr\/>\n<p>\u041a\u0430\u043a \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440 \u0438\u043b\u0438 \u0442\u0438\u043c\u043b\u0438\u0434, \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443. OTUS \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043a\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 \u0432 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 IT-\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u2014 \u043e\u0442 DevOps \u0434\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. \u042d\u0442\u043e \u0433\u0438\u0431\u043a\u0438\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441 \u0430\u043a\u0446\u0435\u043d\u0442\u043e\u043c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0433\u043a\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. <a href=\"https:\/\/otus.pw\/vkn9\/\">\u0423\u0437\u043d\u0430\u0439\u0442\u0435, \u043a\u0430\u043a OTUS \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/a> \u0438 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c IT-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/911318\/\"> https:\/\/habr.com\/ru\/articles\/911318\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-460896","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/460896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=460896"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/460896\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=460896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=460896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=460896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}