{"id":361873,"date":"2024-05-21T01:22:51","date_gmt":"2024-05-21T01:22:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=361873"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T01:22:51","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=361873","title":{"rendered":"<span>\u041d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u00bb \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u00ab\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439\u00bb<\/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<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a90\/071\/5de\/a900715decfcbc0be4c57108e4257e3b.png\" width=\"332\" height=\"480\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a90\/071\/5de\/a900715decfcbc0be4c57108e4257e3b.png\"\/><\/figure>\n<blockquote>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0442\u043a\u0440\u044b\u043b\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0438\u0440 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/blockquote>\n<h2>\u041c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u0430 \u043c\u043d\u043e\u0433\u043e\u043b\u0435\u0442\u043d\u0438\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043f\u043e\u0431\u044b\u0432\u0430\u0432 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f\u0445, \u0441\u043c\u0435\u043d\u0438\u0432 \u043a\u0443\u0447\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u044f \u041d\u0415 \u0412\u0421\u0422\u0420\u0415\u0427\u0410\u041b \u043f\u0430\u0442\u0442\u0435\u0440\u043d &#171;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&#187; \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c &#171;\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439&#187;.<\/p>\n<p><strong>\u041f\u043b\u044e\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u2013 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u0447\u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0434\u043d\u043e\u0439 \u00a0\u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u2014 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438\u00a0And, Or, Not \u0438 \u0442. \u0434.  <\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u041c\u0438\u043d\u0443\u0441\u044b<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423\u0432\u0435\u0440\u0435\u043d, \u0440\u0435\u0431\u044f\u0442\u0430 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043d\u0430\u0439\u0434\u0443\u0442 \u043c\u0438\u043d\u0443\u0441\u044b \u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430.<br \/>\u0425\u043e\u0442\u044f \u043e\u0442 \u0441\u0435\u0431\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044e, \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0411\u0414, \u043a\u043e\u0434 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c (\u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 <code>.Include(_ => _.AnotherEntity)<\/code>)<\/p>\n<\/div>\n<\/details>\n<hr\/>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/h3>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0420\u0438\u0441\u0443\u043d\u043a\u0435 1 \u043d\u0438\u0436\u0435. \u0414\u043b\u044f \u043c\u043e\u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u043e\u043d\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0438 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0441\u0435 \u043a\u0435\u0439\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0425\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043d\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 <code>And()<\/code> <code>Or()<\/code> <code>Not()<\/code>. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f  \u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f <a href=\"https:\/\/makedev.org\/principles\/solid\/isp.html\" rel=\"noopener noreferrer nofollow\"><em>Interface Segregation Principle<\/em><\/a><em>.<\/em><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dad\/b9c\/65e\/dadb9c65e5e6df1a2500d467ae384810.png\" alt=\"\u0420\u0438\u0441 1. UML \u0441\u0445\u0435\u043c\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 &quot;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&quot;\" title=\"\u0420\u0438\u0441 1. UML \u0441\u0445\u0435\u043c\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 &quot;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&quot;\" width=\"3150\" height=\"1815\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dad\/b9c\/65e\/dadb9c65e5e6df1a2500d467ae384810.png\"\/><\/p>\n<div><figcaption>\u0420\u0438\u0441 1. UML \u0441\u0445\u0435\u043c\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 &#171;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&#187;<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0441\u0435\u0433\u043e 4 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043f\u0430\u0440\u0430 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u041e\u0413\u0420\u041e\u041c\u041d\u041e\u0419 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0432 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u044e\u0431\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>Expression&lt;Func>.<\/code><\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 ISpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \/\/\/ &lt;\/summary> public interface ISpecification&lt;TEntity> : ICloneable     where TEntity : class {     \/\/\/ &lt;summary>     \/\/\/     \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c     \/\/\/ &lt;\/summary>     int Skip { get; }      \/\/\/ &lt;summary>     \/\/\/     \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432\u0437\u044f\u0442\u044c     \/\/\/ &lt;\/summary>     int Take { get; }      \/\/\/ &lt;summary>     \/\/\/     \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f     \/\/\/ &lt;\/summary>     Expression&lt;Func&lt;TEntity, object>>[] GetIncludes();      \/\/\/ &lt;summary>     \/\/\/     \u0423\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c     \/\/\/ &lt;\/summary>     Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy();      \/\/\/ &lt;summary>     \/\/\/     \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432     \/\/\/ &lt;\/summary>     OrderModel&lt;TEntity>[] GetOrderModels(); } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041c\u0435\u0442\u043e\u0434  <code>Expression&lt;Func&lt;TEntity, object>>[] GetIncludes()<\/code>\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434  <code>Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy()<\/code> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c \u0432 <code>Func&lt;TEntity, bool><\/code>.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434  <code>OrderModel[] GetOrderModels()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 DTO, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 OrderModel&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u041c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \/\/\/ &lt;\/summary> public class OrderModel&lt;TEntity>     where TEntity : class {     #region .ctor      \/\/\/ &lt;inheritdoc cref=\"OrderModel{TEntity}\" \/>     public OrderModel(Expression&lt;Func&lt;TEntity, object>> orderExpression, bool needOrderByDescending)     {         OrderExpression = orderExpression;         NeedOrderByDescending = needOrderByDescending;     }      #endregion      #region Properties      \/\/\/ &lt;summary>     \/\/\/     \u0421\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435     \/\/\/ &lt;\/summary>     public Expression&lt;Func&lt;TEntity, object>> OrderExpression { get; }      \/\/\/ &lt;summary>     \/\/\/     \u041d\u0443\u0436\u043d\u0430 \u043b\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e     \/\/\/ &lt;\/summary>     public bool NeedOrderByDescending { get; }      #endregion }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>BaseSpecification&lt;TEntity><\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <code>Skip<\/code> \u0438 <code>Take<\/code> , \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0418 (<code>&amp;<\/code>) \u0438 \u0418\u041b\u0418 (<code>|<\/code>). \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0447\u0435\u043c\u0443 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>And()<\/code> \u0438 <code>Or()<\/code> \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 BaseSpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \/\/\/ &lt;\/summary> public abstract class SpecificationBase&lt;TEntity> : ISpecification&lt;TEntity>     where TEntity : class {     #region Implementation of ISpecification      \/\/\/ &lt;inheritdoc \/>     public int Skip { get; set; } = 0;      \/\/\/ &lt;inheritdoc \/>     public int Take { get; set; } = int.MaxValue;      \/\/\/ &lt;inheritdoc \/>     public abstract Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy();      \/\/\/ &lt;inheritdoc \/>     public abstract Expression&lt;Func&lt;TEntity, object>>[] GetIncludes();      \/\/\/ &lt;inheritdoc \/>     public abstract OrderModel&lt;TEntity>[] GetOrderModels();      \/\/\/ &lt;inheritdoc \/>     public abstract object Clone();      #endregion      \/\/\/ &lt;summary>     \/\/\/     \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0418     \/\/\/ &lt;\/summary>     public static SpecificationBase&lt;TEntity> operator &amp;(         SpecificationBase&lt;TEntity> left,         SpecificationBase&lt;TEntity> right)     {         return new AndSpecification&lt;TEntity>(left, right);     }      \/\/\/ &lt;summary>     \/\/\/     \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0418\u041b\u0418     \/\/\/ &lt;\/summary>     public static SpecificationBase&lt;TEntity> operator |(         SpecificationBase&lt;TEntity> left,         SpecificationBase&lt;TEntity> right)     {         return new OrSpecification&lt;TEntity>(left, right);     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>DirectSpecification&lt;TEntity><\/code>. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 DirectSpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u041f\u0440\u044f\u043c\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \/\/\/ &lt;\/summary> public class DirectSpecification&lt;TEntity> : SpecificationBase&lt;TEntity>     where TEntity : class {     #region Fields      private readonly List&lt;Expression&lt;Func&lt;TEntity, object>>> _includes = new();     private readonly Expression&lt;Func&lt;TEntity, bool>>? _matchingCriteria;     private OrderModel&lt;TEntity>? _orderModel;      #endregion      #region .ctor      \/\/\/ &lt;inheritdoc cref=\"DirectSpecification{TEntity}\" \/>     public DirectSpecification(Expression&lt;Func&lt;TEntity, bool>> matchingCriteria)     {         _matchingCriteria = matchingCriteria;     }      \/\/\/ &lt;inheritdoc cref=\"DirectSpecification{TEntity}\" \/>     public DirectSpecification()     { }      \/\/\/ &lt;inheritdoc cref=\"DirectSpecification{TEntity}\" \/>     protected DirectSpecification(         List&lt;Expression&lt;Func&lt;TEntity, object>>> includes,         Expression&lt;Func&lt;TEntity, bool>>? matchingCriteria,         OrderModel&lt;TEntity>? orderModel)     {         _includes = includes;         _matchingCriteria = matchingCriteria;         _orderModel = orderModel;     }      #endregion      #region Implementation of SpecificationBase      \/\/\/ &lt;inheritdoc \/>     public override object Clone()     {         \/\/ NOTE: \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f\u0432\u043d\u043e,         \/\/ \u0442\u043e \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b         \/\/ \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0430 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u0430\u044f         return new DirectSpecification&lt;TEntity>(_includes, _matchingCriteria, _orderModel);     }      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy()         => _matchingCriteria;      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, object>>[] GetIncludes()         => _includes.ToArray();      \/\/\/ &lt;inheritdoc \/>     public override OrderModel&lt;TEntity>[] GetOrderModels()     {         return _orderModel is null ? Array.Empty&lt;OrderModel&lt;TEntity>>() : new[] { _orderModel };     }      #endregion      #region Public methods      \/\/\/ &lt;summary>     \/\/\/     \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     \/\/\/ &lt;\/summary>     public DirectSpecification&lt;TEntity> AddInclude(Expression&lt;Func&lt;TEntity, object>> includeExpression)     {         _includes.Add(includeExpression);          return this;     }      \/\/\/ &lt;summary>     \/\/\/     \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438     \/\/\/ &lt;\/summary>     public DirectSpecification&lt;TEntity> SetOrder(OrderModel&lt;TEntity> orderModel)     {         _orderModel = orderModel;          return this;     }      #endregion }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>&#171;\u0418&#187; \u0438 &#171;\u0418\u041b\u0418&#187; \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438, \u0438\u0445 \u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0438\u0436\u0435. \u0418\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0445 \u0434\u0432\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 <code>ISpecification&lt;TEntity><\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a <abbr class=\"habraabbr\" title=\"\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Or \u0438\u043b\u0438 And \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\" data-title=\"&lt;p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Or \u0438\u043b\u0438 And \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438&lt;\/p>&#187; data-abbr=&#187;\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u043c\u0438 &#171;>\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u043c\u0438 <\/abbr>(\u0442\u043e\u0436\u0435 &#171;\u0418&#187; \u0438\u043b\u0438 &#171;\u0418\u041b\u0418&#187;), \u0442\u0430\u043a \u0438 <abbr class=\"habraabbr\" title=\"\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 DirectSpecification\" data-title=\"&lt;p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 DirectSpecification&lt;\/p>&#187; data-abbr=&#187;\u043f\u0440\u043e\u0441\u0442\u044b\u0435 &#171;>\u043f\u0440\u043e\u0441\u0442\u044b\u0435 <\/abbr>\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 <code>DirectSpecification&lt;TEntity><\/code>), \u0442\u0430\u043a \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 <abbr class=\"habraabbr\" title=\"\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 DirectSpecification\" data-title=\"&lt;p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 DirectSpecification&lt;\/p>&lt;p>&lt;\/p>&#187; data-abbr=&#187;\u043f\u0440\u043e\u0441\u0442\u043e\u0439&#187;>\u043f\u0440\u043e\u0441\u0442\u043e\u0439<\/abbr> \u0438 <abbr class=\"habraabbr\" title=\"\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Or \u0438\u043b\u0438 And \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\" data-title=\"&lt;p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Or \u0438\u043b\u0438 And \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438&lt;\/p>&lt;p>&lt;\/p>&#187; data-abbr=&#187;\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439&#187;>\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439<\/abbr> \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 AndSpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0418 \/\/\/ &lt;\/summary> public sealed class AndSpecification&lt;TEntity> : SpecificationBase&lt;TEntity>    where TEntity : class {     #region Fields      private readonly ISpecification&lt;TEntity> _rightSideSpecification;     private readonly ISpecification&lt;TEntity> _leftSideSpecification;      #endregion      #region .ctor      \/\/\/ &lt;inheritdoc \/>     public override object Clone()     {         var left = (ISpecification&lt;TEntity>)_leftSideSpecification.Clone();         var right = (ISpecification&lt;TEntity>)_leftSideSpecification.Clone();          return new AndSpecification&lt;TEntity>(left, right);     }      \/\/\/ &lt;inheritdoc cref=\"AndSpecification{TEnity}\" \/>     public AndSpecification(         ISpecification&lt;TEntity> leftSide,         ISpecification&lt;TEntity> rightSide)     {         Assert.NotNull(leftSide, \"Left specification cannot be null\");         Assert.NotNull(rightSide, \"Right specification cannot be null\");          _leftSideSpecification = leftSide;         _rightSideSpecification = rightSide;     }      #endregion      #region Implementation Of SpecificationBase      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy()     {         var left = _leftSideSpecification.SatisfiedBy();         var right = _rightSideSpecification.SatisfiedBy();         if (left is null &amp;&amp; right is null)         {             return null;         }          if (left is not null &amp;&amp; right is not null)         {             return left.And(right);         }  #pragma warning disable IDE0046 \/\/ Convert to conditional expression         if (left is not null)         {             return left;         } #pragma warning restore IDE0046 \/\/ Convert to conditional expression          return right;     }      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, object>>[] GetIncludes()     {         var leftIncludes = _leftSideSpecification.GetIncludes();         var rightIncludes = _rightSideSpecification.GetIncludes();          leftIncludes.AddRange(rightIncludes);          return leftIncludes;     }      \/\/\/ &lt;inheritdoc \/>     public override OrderModel&lt;TEntity>[] GetOrderModels()     {         var leftOrderModels = _leftSideSpecification.GetOrderModels();         leftOrderModels.AddRange(_rightSideSpecification.GetOrderModels());          return leftOrderModels;     }      #endregion }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 OrSpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0418\u041b\u0418 \/\/\/ &lt;\/summary> public class OrSpecification&lt;TEntity> : SpecificationBase&lt;TEntity>     where TEntity : class {     #region Fields      private readonly ISpecification&lt;TEntity> _leftSideSpecification;     private readonly ISpecification&lt;TEntity> _rightSideSpecification;      #endregion      #region .ctor      \/\/\/ &lt;inheritdoc cref=\"OrSpecification{TEnity}\" \/>     public OrSpecification(         ISpecification&lt;TEntity> left,         ISpecification&lt;TEntity> right)     {         Assert.NotNull(left, \"Left specification cannot be null\");         Assert.NotNull(right, \"Right specification cannot be null\");          _leftSideSpecification = left;         _rightSideSpecification = right;     }      #endregion      #region Implemtation of SpecificationBase      \/\/\/ &lt;inheritdoc \/>     public override object Clone()     {         var left = (ISpecification&lt;TEntity>)_leftSideSpecification.Clone();         var  right = (ISpecification&lt;TEntity>)_leftSideSpecification.Clone();          return new OrSpecification&lt;TEntity>(left, right);     }      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy()     {         var left = _leftSideSpecification.SatisfiedBy();         var right = _rightSideSpecification.SatisfiedBy();         if (left is null &amp;&amp; right is null)         {             return null;         }          if (left is not null &amp;&amp; right is not null)         {             return left.Or(right);         }  #pragma warning disable IDE0046 \/\/ Convert to conditional expression         if (left is not null)         {             return left;         }          return right;     }      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, object>>[] GetIncludes()     {         var leftIncludes = _leftSideSpecification.GetIncludes();         var rightIncludes = _rightSideSpecification.GetIncludes();          leftIncludes.AddRange(rightIncludes);          return leftIncludes;     }      \/\/\/ &lt;inheritdoc \/>     public override OrderModel&lt;TEntity>[] GetOrderModels()     {         var leftOrderModels = _leftSideSpecification.GetOrderModels();         leftOrderModels.AddRange(_rightSideSpecification.GetOrderModels());          return leftOrderModels;     }      #endregion }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p> \u041e\u0431\u0435 \u043e\u043d\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043c\u0435\u0442\u043e\u0434 <code>SatisfiedBy()<\/code>  \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>SpecificationBase&lt;TEntity><\/code>, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044f \u0434\u0432\u0430 <code>Expression&lt;Func><\/code>, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043e\u0442 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u0432\u0443\u0445 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440.<\/p>\n<hr\/>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432<\/h2>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 &#171;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&#187; \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0420\u0438\u0441\u0443\u043d\u043a\u0435 2 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9fa\/9a5\/016\/9fa9a501698277203c3891d97441e7fc.png\" alt=\"\u0420\u0438\u0441 2. UML \u0441\u0445\u0435\u043c\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 &quot;\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439&quot; \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441\u043e &quot;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439&quot;\" title=\"\u0420\u0438\u0441 2. UML \u0441\u0445\u0435\u043c\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 &quot;\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439&quot; \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441\u043e &quot;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439&quot;\" width=\"2888\" height=\"2344\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9fa\/9a5\/016\/9fa9a501698277203c3891d97441e7fc.png\"\/><\/p>\n<div><figcaption>\u0420\u0438\u0441 2. UML \u0441\u0445\u0435\u043c\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 &#171;\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439&#187; \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441\u043e &#171;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439&#187;<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u043f\u0435\u0440\u0432\u044b\u0435 4 \u043c\u0435\u0442\u043e\u0434\u0430 (<code>Get, GetStrict, List, Any<\/code>), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 <code>IRepository&lt;TEntity><\/code>, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>StorageBase&lt;TEntity><\/code> \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 IStorage&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u041e\u0431\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449 \/\/\/ &lt;\/summary> public interface IStorage&lt;T>     where T : class {     \/\/\/ &lt;summary>     \/\/\/     \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435     \/\/\/ &lt;\/summary>     void Add(T model);          \/\/\/ &lt;summary>     \/\/\/     \u0423\u0434\u0430\u043b\u0438\u0442\u044c     \/\/\/ &lt;\/summary>     void Remove(T model);      \/\/\/ &lt;summary>     \/\/\/     \u041d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443     \/\/\/ &lt;\/summary>     \/\/\/ &lt;param name=\"specification\"> \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 &lt;\/param>     \/\/\/ &lt;returns> \u041c\u043e\u0434\u0435\u043b\u044c &lt;\/returns>     T? Get(ISpecification&lt;T> specification);      \/\/\/ &lt;summary>     \/\/\/     \u041d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443, \u0431\u0440\u043e\u0441\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e     \/\/\/ &lt;\/summary>     \/\/\/ &lt;param name=\"specification\"> \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 &lt;\/param>     \/\/\/ &lt;param name=\"errorCode\"> \u041a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430 &lt;\/param>     \/\/\/ &lt;returns> \u041c\u043e\u0434\u0435\u043b\u044c &lt;\/returns>     \/\/\/ &lt;exception cref=\"ErrorException\">     \/\/\/     \u041e\u0448\u0438\u0431\u043a\u0430 \u0441 \u043a\u043e\u0434\u043e\u043c &lt;paramref name=\"errorCode\" \/>, \u0435\u0441\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430     \/\/\/ &lt;\/exception>     T GetStrict(ISpecification&lt;T> specification, string errorCode);      \/\/\/ &lt;summary>     \/\/\/     \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438     \/\/\/ &lt;\/summary>     \/\/\/ &lt;param name=\"specification\"> \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f &lt;\/param>     bool Any(ISpecification&lt;T> specification);      \/\/\/ &lt;summary>     \/\/\/     \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438     \/\/\/ &lt;\/summary>     \/\/\/ &lt;param name=\"specification\"> \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f &lt;\/param>     IEnumerable&lt;T> GetMany(ISpecification&lt;T> specification); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (<code>Get, GetStrict, List, Any<\/code>), \u043e\u043d\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e &#171;\u0433\u0438\u0431\u043a\u0438\u0435&#187;, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u043c.<\/p>\n<pre><code class=\"cs\">    \/\/\/ &lt;inheritdoc \/>     public bool Any(ISpecification&lt;T> specification)         => SpecificationEvaluator               .GetQuery(CreateQuery(), specification)               .Any();      \/\/\/ &lt;inheritdoc \/>     public T? Get(ISpecification&lt;T> specification)         => SpecificationEvaluator               .GetQuery(CreateQuery(), specification)               .FirstOrDefault();      \/\/\/ &lt;inheritdoc \/>     public T GetStrict(ISpecification&lt;T> specification, string errorCode)         => SpecificationEvaluator               .GetQuery(CreateQuery(), specification)               .FirstOrDefault() ?? throw new ErrorException(errorCode);      \/\/\/ &lt;inheritdoc \/>     public IEnumerable&lt;T> GetMany(ISpecification&lt;T> specification)         => SpecificationEvaluator               .GetQuery(CreateQuery(), specification);<\/code><\/pre>\n<blockquote>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0433\u0432\u043e\u0437\u0434\u044c, \u043e\u043f\u043e\u0440\u0443, \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0435\u0435 \u0437\u0432\u0435\u043d\u043e \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<\/blockquote>\n<details class=\"spoiler\">\n<summary>\u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0437\u0430\u0434\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u0440\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043e\u0442\u043a\u0443\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u0430) \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 <code>SpecificationEvaluator<\/code><\/p>\n<\/div>\n<\/details>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430\u043c \u0432 RAM \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f <code>IEnumerable<\/code>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430, \u0435\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c, \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u044f.<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \/\/\/ &lt;\/summary> public class SpecificationEvaluator {     #region IQueryable      \/\/\/ &lt;summary>     \/\/\/     \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441     \/\/\/ &lt;\/summary>     public static IQueryable&lt;TEntity> GetQuery&lt;TEntity>(         IQueryable&lt;TEntity> inputQuery,         ISpecification&lt;TEntity> specification)         where TEntity : class     {         var query = inputQuery;          \/\/ \u0432\u043a\u043b\u044e\u0447\u0430\u044e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438         query = specification             .GetIncludes()             .Aggregate(query, static (current, include) => current.Include(include));          \/\/ \u043e\u0442\u0431\u0438\u0440\u0430\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b         var whereExp = specification.SatisfiedBy();         if (whereExp is not null)         {             query = query.Where(whereExp)!;         }          \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438         var orderModels = specification.GetOrderModels();         if (!orderModels.Any())         {             return query                 .Skip(specification.Skip)                 .Take(specification.Take);         }          \/\/ \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e         var orderedQuery = AddFirstOrderExpression(query, orderModels.First());         foreach (var orderModel in orderModels.Skip(1))         {             orderedQuery = AddAnotherOrderExpression(orderedQuery, orderModel);         }          return orderedQuery             .Skip(specification.Skip)             .Take(specification.Take);     }      \/\/\/ &lt;summary>     \/\/\/     \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0432 \u0441\u0430\u043c\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437     \/\/\/ &lt;\/summary>     private static IOrderedQueryable&lt;TEntity> AddFirstOrderExpression&lt;TEntity>(         IQueryable&lt;TEntity> query,         OrderModel&lt;TEntity> orderModel)         where TEntity : class     {         return orderModel.NeedOrderByDescending             ? query.OrderByDescending(orderModel.OrderExpression)             : query.OrderBy(orderModel.OrderExpression);     }      \/\/\/ &lt;summary>     \/\/\/     \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043e\u043a     \/\/\/ &lt;\/summary>     private static IOrderedQueryable&lt;TEntity> AddAnotherOrderExpression&lt;TEntity>(         IOrderedQueryable&lt;TEntity> query,         OrderModel&lt;TEntity> orderModel)         where TEntity : class     {         return orderModel.NeedOrderByDescending             ? query.ThenByDescending(orderModel.OrderExpression)             : query.ThenBy(orderModel.OrderExpression);     }      #endregion }<\/code><\/pre>\n<hr\/>\n<h2>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <code>Man<\/code> &#8212; \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0438\u043c\u044f, \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0438 \u043f\u043e\u043b: <\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0427\u0435\u043b\u043e\u0432\u0435\u043a \/\/\/ &lt;\/summary> internal sealed class Man {     \/\/\/ &lt;summary>     \/\/\/     \u0412\u043e\u0437\u0440\u0430\u0441\u0442     \/\/\/ &lt;\/summary>     public int Age { get; set; }      \/\/\/ &lt;summary>     \/\/\/     \u0418\u043c\u044f     \/\/\/ &lt;\/summary>     public string Name { get; set; }      \/\/\/ &lt;summary>     \/\/\/     \u041f\u043e\u043b     \/\/\/ &lt;\/summary>     public GenderType Gender { get; set; } }  \/\/\/ &lt;summary> \/\/\/     \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u043b \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \/\/\/ &lt;\/summary> internal enum GenderType {     \/\/\/ &lt;summary>     \/\/\/     \u041c\u0443\u0436\u0447\u0438\u043d\u0430     \/\/\/ &lt;\/summary>     Male,      \/\/\/ &lt;summary>     \/\/\/     \u0416\u0435\u043d\u0449\u0438\u043d\u0430     \/\/\/ &lt;\/summary>     Female }<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u0441\u0430\u0439\u0442\u0435 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043f\u043e\u043b\u0435\u0439 \u044d\u0442\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0420\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438, \u043d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u043c\u0438.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f), \u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u0434\u0443\u043c\u0430\u0435\u0442\u0441\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0431\u044b \u043c\u043d\u0435 \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0441\u0442\u043e\u044f\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f\u0432\u043d\u043e, \u0438 \u043f\u043e\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0438 \u0442.\u043f.<\/p>\n<p>\u0411\u0443\u0434\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 RAM \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0421\u0430\u043c\u043e\u0435 \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043b\u044e\u0434\u0435\u0439 \/\/\/ &lt;\/summary> internal sealed class BadManRepository1 : StorageBase&lt;Man> {     private ImmutableArray&lt;Man> _storage = ImmutableArray&lt;Man>.Empty;      \/\/\/ &lt;inheritdoc \/>     public override void Add(Man model)     {         _storage = _storage.Add(model);     }      \/\/\/ &lt;inheritdoc \/>     public override void Remove(Man model)     {         _storage = _storage.Remove(model);     }      \/\/\/ &lt;inheritdoc \/>     public Man Get(string name)         => CreateQuery().FirstOrDefault(_ => _.Name == name);      \/\/\/ &lt;inheritdoc \/>     public Man Get(int age)         => CreateQuery().FirstOrDefault(_ => _.Age == age);      \/\/\/ &lt;inheritdoc \/>     public Man Get(GenderType gender)         => CreateQuery().FirstOrDefault(_ => _.Gender == gender);      \/\/\/ &lt;inheritdoc \/>     public Man Get(string name, int age)         => CreateQuery().FirstOrDefault(_ => _.Name == name &amp;&amp; _.Age == age);      \/\/\/ &lt;inheritdoc \/>     public Man Get(string name, GenderType gender)         => CreateQuery().FirstOrDefault(_ => _.Name == name &amp;&amp; _.Gender == gender);      \/\/\/ &lt;inheritdoc \/>     public Man Get(string name, int age, GenderType gender)         => CreateQuery().FirstOrDefault(_ => _.Name == name &amp;&amp; _.Age == age &amp;&amp; _.Gender == gender);      \/\/\/ &lt;inheritdoc \/>     public Man Get(string name, int age)         => CreateQuery().FirstOrDefault(_ => _.Name == name || _.Age == age); }<\/code><\/pre>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u0448\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>Get<\/code>, \u043d\u043e \u0434\u0430\u0436\u0435 \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u0440\u0435\u0445 \u043f\u043e\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0418 \u0438 \u0418\u041b\u0418 \u0443\u0436\u0435 \u044f \u043d\u0430\u0441\u0447\u0438\u0442\u0430\u043b 11, \u0430 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u0435\u0439, \u0430 \u0435\u0441\u043b\u0438 \u0435\u0449\u0435 \u043d\u0443\u0436\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b <code>Any()<\/code> , <code>List()<\/code> \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438?<\/p>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445. \u041e\u043d \u0442\u043e\u0436\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c. \u041f\u0440\u0438\u0432\u0435\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>Get<\/code> \u0441 <code>\u0418<\/code> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c. \u041d\u0443\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>Get<\/code> \u0441 <code>\u0418\u041b\u0418<\/code> \u0438 <code>Get<\/code> \u0441 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u044f\u043c\u0438 <code>\u0418<\/code> \u0438 <code>\u0418\u041b\u0418<\/code>. \u0412\u0441\u0435 \u044d\u0442\u043e \u0437\u0430\u0439\u043c\u0435\u0442 \u043a\u0443\u0447\u0443 \u043a\u043e\u0434\u0430 \u0438 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u043a\u043b\u0430\u0441\u0441 Man, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435.<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u041d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043b\u044e\u0434\u0435\u0439 \/\/\/ &lt;\/summary> internal sealed class BadManRepository2 : StorageBase&lt;Man> {     private ImmutableArray&lt;Man> _storage = ImmutableArray&lt;Man>.Empty;      \/\/\/ &lt;inheritdoc \/>     public Man Get(GetManRequest request)     {         var query = CreateQuery();         if (request.Name is not null)         {             query = query.Where(x => x.Name == request.Name);         }         if (request.Age is not null)         {             query = query.Where(x => x.Age == request.Age);         }         if (request.Gender is not null)         {             query = query.Where(x => x.Gender == request.Gender);         }          return query.FirstOrDefault();     } }<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c &#171;\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e&#187; \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0435\u043c\u0443 \u043d\u0430 \u0432\u0445\u043e\u0434. \u041e\u043d \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0438 \u043e\u0442\u0434\u0430\u0447\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043b\u044e\u0434\u0435\u0439 \/\/\/ &lt;\/summary> internal sealed class ManRepository : StorageBase&lt;Man> {     private ImmutableArray&lt;Man> _storage = ImmutableArray&lt;Man>.Empty;      \/\/\/ &lt;inheritdoc \/>     public override void Add(Man model)     {         _storage = _storage.Add(model);     }      \/\/\/ &lt;inheritdoc \/>     public override void Remove(Man model)     {         _storage = _storage.Remove(model);     }      \/\/\/ &lt;inheritdoc \/>     protected override IEnumerable&lt;Man> CreateQuery() => _storage; }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432 \u043d\u0430\u0448\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043d\u043e\u0432\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f &lt;see cref=\"Man\" \/> \/\/\/ &lt;\/summary> internal static class ManSpecification {     \/\/\/ &lt;summary>     \/\/\/     \u0421 \u0438\u043c\u0435\u043d\u0435\u043c     \/\/\/ &lt;\/summary>     public static ISpecification&lt;Man> WithName(string name)         => new DirectSpecification&lt;Man>(_ => _.Name == name);      \/\/\/ &lt;summary>     \/\/\/     \u0421 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u043e\u043c     \/\/\/ &lt;\/summary>     public static ISpecification&lt;Man> WithAge(int age)         => new DirectSpecification&lt;Man>(_ => _.Age == age);      \/\/\/ &lt;summary>     \/\/\/     \u0421 \u0433\u0435\u043d\u0434\u0435\u0440\u043e\u043c     \/\/\/ &lt;\/summary>     public static ISpecification&lt;Man> WithGender(GenderType gender)         => new DirectSpecification&lt;Man>(_ => _.Gender == gender);      \/\/\/ &lt;summary>     \/\/\/     \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0443     \/\/\/ &lt;\/summary>     public static ISpecification&lt;Man> OrderByAge(bool orderByDescending = false)         => new DirectSpecification&lt;Man>().SetOrder(new(static _ => _.Age, orderByDescending));      \/\/\/ &lt;summary>     \/\/\/     \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0438\u043c\u0435\u043d\u0438     \/\/\/ &lt;\/summary>     public static ISpecification&lt;Man> OrderByName(bool orderByDescending = false)         => new DirectSpecification&lt;Man>().SetOrder(new(static _ => _.Name, orderByDescending)); }<\/code><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">    public static int Main()     {         var repository = new ManRepository();          var spec1 = ManSpecification.WithName(\"\u041a\u043e\u043b\u044f\")             &amp; ManSpecification.WithAge(26);          var man1 = repository.Get(spec1);          var spec2 = ManSpecification.WithName(\"\u041a\u043e\u043b\u044f\") | ManSpecification.WithAge(26);         var men2 = repository.Get(spec2);          var spec3 = (ManSpecification.WithName(\"\u0416\u0435\u043d\u044f\") | ManSpecification.WithAge(26))             &amp; ManSpecification.WithGender(GenderType.Male);         var men3 = repository.Get(spec2);          var spec4 = (ManSpecification.WithName(\"\u0416\u0435\u043d\u044f\") | ManSpecification.WithAge(26))             &amp; ManSpecification.WithGender(GenderType.Male)             &amp; ManSpecification.OrderByAge();         var orderedMen4 = repository.Get(spec2);     }<\/code><\/pre>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0447\u043d\u0435\u0435 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u0438 \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<hr\/>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u043e\u0449\u043d\u044b\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435, \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435. \u0414\u043b\u044f \u043c\u0435\u043d\u044f \u043e\u043d\u0438 \u043e\u0442\u043a\u0440\u044b\u043b\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432\u044b\u0439 \u043c\u0438\u0440, \u0433\u0434\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0449\u0435\u043b\u0447\u043a\u0443 \u043f\u0430\u043b\u044c\u0446\u0435\u0432 \u0438 \u0438\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0421\u043e\u0432\u0435\u0442\u044b, \u043f\u043e\u0436\u0435\u043b\u0430\u043d\u0438\u044f \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<p>UPD. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0442\u043e\u0440\u0430\u043c, \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u044e \u0437\u0430\u0431\u044b\u0442\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 Expression:<\/p>\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u041f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \/\/\/ &lt;\/summary> public static class ExpressionHelper {     \/\/\/ &lt;summary>     \/\/\/     \u0421\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0418     \/\/\/ &lt;\/summary>     public static Expression&lt;T> And&lt;T>(this Expression&lt;T> left, Expression&lt;T> right)     {         var param = left.Parameters[0];         if (ReferenceEquals(param, right.Parameters[0]))         {             return Expression.Lambda&lt;T>(                     Expression.AndAlso(left.Body, right.Body),                     param);         }          \/\/ \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u0435\u0432\u044b\u0439 \u043a\u0430\u043a \u0435\u0441\u0442\u044c \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u044b\u0439, \u043d\u043e \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0434\u043b\u044f \u043b\u0435\u0432\u043e\u0433\u043e         return Expression.Lambda&lt;T>(             Expression.AndAlso(                 left.Body,                 Expression.Invoke(right, param)),             param);     }      \/\/\/ &lt;summary>     \/\/\/     \u0421\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0418\u041b\u0418     \/\/\/ &lt;\/summary>     public static Expression&lt;T> Or&lt;T>(this Expression&lt;T> left, Expression&lt;T> right)     {         var param = left.Parameters[0];         if (ReferenceEquals(param, right.Parameters[0]))         {             return Expression.Lambda&lt;T>(                 Expression.OrElse(left, right),                 param);         }          \/\/ \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u0435\u0432\u044b\u0439 \u043a\u0430\u043a \u0435\u0441\u0442\u044c \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u044b\u0439, \u043d\u043e \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0434\u043b\u044f \u043b\u0435\u0432\u043e\u0433\u043e         return Expression.Lambda&lt;T>(             Expression.OrElse(                 left.Body,                 Expression.Invoke(right, param)),             param);     } } <\/code><\/pre>\n<\/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\/778082\/\"> https:\/\/habr.com\/ru\/articles\/778082\/<\/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<figure class=\"\"><\/figure>\n<blockquote>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0442\u043a\u0440\u044b\u043b\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0438\u0440 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/blockquote>\n<h2>\u041c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u0430 \u043c\u043d\u043e\u0433\u043e\u043b\u0435\u0442\u043d\u0438\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043f\u043e\u0431\u044b\u0432\u0430\u0432 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f\u0445, \u0441\u043c\u0435\u043d\u0438\u0432 \u043a\u0443\u0447\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u044f \u041d\u0415 \u0412\u0421\u0422\u0420\u0415\u0427\u0410\u041b \u043f\u0430\u0442\u0442\u0435\u0440\u043d &#171;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&#187; \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c &#171;\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439&#187;.<\/p>\n<p><strong>\u041f\u043b\u044e\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u2013 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u0447\u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0434\u043d\u043e\u0439 \u00a0\u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u2014 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438\u00a0And, Or, Not \u0438 \u0442. \u0434.  <\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u041c\u0438\u043d\u0443\u0441\u044b<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423\u0432\u0435\u0440\u0435\u043d, \u0440\u0435\u0431\u044f\u0442\u0430 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043d\u0430\u0439\u0434\u0443\u0442 \u043c\u0438\u043d\u0443\u0441\u044b \u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430.<br \/>\u0425\u043e\u0442\u044f \u043e\u0442 \u0441\u0435\u0431\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044e, \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0411\u0414, \u043a\u043e\u0434 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c (\u0445\u043e\u0442\u044f \u0431\u044b \u0432 \u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 <code>.Include(_ => _.AnotherEntity)<\/code>)<\/p>\n<\/div>\n<\/details>\n<hr\/>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/h3>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043c\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0420\u0438\u0441\u0443\u043d\u043a\u0435 1 \u043d\u0438\u0436\u0435. \u0414\u043b\u044f \u043c\u043e\u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u043e\u043d\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0438 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0441\u0435 \u043a\u0435\u0439\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0425\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043d\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 <code>And()<\/code> <code>Or()<\/code> <code>Not()<\/code>. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f  \u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f <a href=\"https:\/\/makedev.org\/principles\/solid\/isp.html\" rel=\"noopener noreferrer nofollow\"><em>Interface Segregation Principle<\/em><\/a><em>.<\/em><\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0438\u0441 1. UML \u0441\u0445\u0435\u043c\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 &#171;\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f&#187;<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0441\u0435\u0433\u043e 4 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043f\u0430\u0440\u0430 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u041e\u0413\u0420\u041e\u041c\u041d\u041e\u0419 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0432 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u044e\u0431\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>Expression&lt;Func>.<\/code><\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 ISpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \/\/\/ &lt;\/summary> public interface ISpecification&lt;TEntity> : ICloneable     where TEntity : class {     \/\/\/ &lt;summary>     \/\/\/     \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c     \/\/\/ &lt;\/summary>     int Skip { get; }      \/\/\/ &lt;summary>     \/\/\/     \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432\u0437\u044f\u0442\u044c     \/\/\/ &lt;\/summary>     int Take { get; }      \/\/\/ &lt;summary>     \/\/\/     \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f     \/\/\/ &lt;\/summary>     Expression&lt;Func&lt;TEntity, object>>[] GetIncludes();      \/\/\/ &lt;summary>     \/\/\/     \u0423\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c     \/\/\/ &lt;\/summary>     Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy();      \/\/\/ &lt;summary>     \/\/\/     \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432     \/\/\/ &lt;\/summary>     OrderModel&lt;TEntity>[] GetOrderModels(); } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041c\u0435\u0442\u043e\u0434  <code>Expression&lt;Func&lt;TEntity, object>>[] GetIncludes()<\/code>\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434  <code>Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy()<\/code> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c \u0432 <code>Func&lt;TEntity, bool><\/code>.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434  <code>OrderModel[] GetOrderModels()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 DTO, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 OrderModel&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u041c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \/\/\/ &lt;\/summary> public class OrderModel&lt;TEntity>     where TEntity : class {     #region .ctor      \/\/\/ &lt;inheritdoc cref=\"OrderModel{TEntity}\" \/>     public OrderModel(Expression&lt;Func&lt;TEntity, object>> orderExpression, bool needOrderByDescending)     {         OrderExpression = orderExpression;         NeedOrderByDescending = needOrderByDescending;     }      #endregion      #region Properties      \/\/\/ &lt;summary>     \/\/\/     \u0421\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435     \/\/\/ &lt;\/summary>     public Expression&lt;Func&lt;TEntity, object>> OrderExpression { get; }      \/\/\/ &lt;summary>     \/\/\/     \u041d\u0443\u0436\u043d\u0430 \u043b\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e     \/\/\/ &lt;\/summary>     public bool NeedOrderByDescending { get; }      #endregion }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>BaseSpecification&lt;TEntity><\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <code>Skip<\/code> \u0438 <code>Take<\/code> , \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0418 (<code>&amp;<\/code>) \u0438 \u0418\u041b\u0418 (<code>|<\/code>). \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0447\u0435\u043c\u0443 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>And()<\/code> \u0438 <code>Or()<\/code> \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 BaseSpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \/\/\/ &lt;\/summary> public abstract class SpecificationBase&lt;TEntity> : ISpecification&lt;TEntity>     where TEntity : class {     #region Implementation of ISpecification      \/\/\/ &lt;inheritdoc \/>     public int Skip { get; set; } = 0;      \/\/\/ &lt;inheritdoc \/>     public int Take { get; set; } = int.MaxValue;      \/\/\/ &lt;inheritdoc \/>     public abstract Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy();      \/\/\/ &lt;inheritdoc \/>     public abstract Expression&lt;Func&lt;TEntity, object>>[] GetIncludes();      \/\/\/ &lt;inheritdoc \/>     public abstract OrderModel&lt;TEntity>[] GetOrderModels();      \/\/\/ &lt;inheritdoc \/>     public abstract object Clone();      #endregion      \/\/\/ &lt;summary>     \/\/\/     \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0418     \/\/\/ &lt;\/summary>     public static SpecificationBase&lt;TEntity> operator &amp;(         SpecificationBase&lt;TEntity> left,         SpecificationBase&lt;TEntity> right)     {         return new AndSpecification&lt;TEntity>(left, right);     }      \/\/\/ &lt;summary>     \/\/\/     \u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0418\u041b\u0418     \/\/\/ &lt;\/summary>     public static SpecificationBase&lt;TEntity> operator |(         SpecificationBase&lt;TEntity> left,         SpecificationBase&lt;TEntity> right)     {         return new OrSpecification&lt;TEntity>(left, right);     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>DirectSpecification&lt;TEntity><\/code>. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 DirectSpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u041f\u0440\u044f\u043c\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \/\/\/ &lt;\/summary> public class DirectSpecification&lt;TEntity> : SpecificationBase&lt;TEntity>     where TEntity : class {     #region Fields      private readonly List&lt;Expression&lt;Func&lt;TEntity, object>>> _includes = new();     private readonly Expression&lt;Func&lt;TEntity, bool>>? _matchingCriteria;     private OrderModel&lt;TEntity>? _orderModel;      #endregion      #region .ctor      \/\/\/ &lt;inheritdoc cref=\"DirectSpecification{TEntity}\" \/>     public DirectSpecification(Expression&lt;Func&lt;TEntity, bool>> matchingCriteria)     {         _matchingCriteria = matchingCriteria;     }      \/\/\/ &lt;inheritdoc cref=\"DirectSpecification{TEntity}\" \/>     public DirectSpecification()     { }      \/\/\/ &lt;inheritdoc cref=\"DirectSpecification{TEntity}\" \/>     protected DirectSpecification(         List&lt;Expression&lt;Func&lt;TEntity, object>>> includes,         Expression&lt;Func&lt;TEntity, bool>>? matchingCriteria,         OrderModel&lt;TEntity>? orderModel)     {         _includes = includes;         _matchingCriteria = matchingCriteria;         _orderModel = orderModel;     }      #endregion      #region Implementation of SpecificationBase      \/\/\/ &lt;inheritdoc \/>     public override object Clone()     {         \/\/ NOTE: \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f\u0432\u043d\u043e,         \/\/ \u0442\u043e \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b         \/\/ \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0430 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u0430\u044f         return new DirectSpecification&lt;TEntity>(_includes, _matchingCriteria, _orderModel);     }      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy()         => _matchingCriteria;      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, object>>[] GetIncludes()         => _includes.ToArray();      \/\/\/ &lt;inheritdoc \/>     public override OrderModel&lt;TEntity>[] GetOrderModels()     {         return _orderModel is null ? Array.Empty&lt;OrderModel&lt;TEntity>>() : new[] { _orderModel };     }      #endregion      #region Public methods      \/\/\/ &lt;summary>     \/\/\/     \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     \/\/\/ &lt;\/summary>     public DirectSpecification&lt;TEntity> AddInclude(Expression&lt;Func&lt;TEntity, object>> includeExpression)     {         _includes.Add(includeExpression);          return this;     }      \/\/\/ &lt;summary>     \/\/\/     \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438     \/\/\/ &lt;\/summary>     public DirectSpecification&lt;TEntity> SetOrder(OrderModel&lt;TEntity> orderModel)     {         _orderModel = orderModel;          return this;     }      #endregion }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>&#171;\u0418&#187; \u0438 &#171;\u0418\u041b\u0418&#187; \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0438, \u0438\u0445 \u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0438\u0436\u0435. \u0418\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0445 \u0434\u0432\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 <code>ISpecification&lt;TEntity><\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a <abbr class=\"habraabbr\" title=\"\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Or \u0438\u043b\u0438 And \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\" data-title=\"&lt;p>\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438&#187; data-title=&lt;p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Or \u0438\u043b\u0438 And \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438&lt;\/p>&#187; data-abbr=&#187;\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u043c\u0438 &#171;>\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u043c\u0438 <\/abbr>(\u0442\u043e\u0436\u0435 &#171;\u0418&#187; \u0438\u043b\u0438 &#171;\u0418\u041b\u0418&#187;), \u0442\u0430\u043a \u0438 <abbr class=\"habraabbr\" title=\"\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 DirectSpecification\" data-title=\"&lt;p>&#187; data-title=&#187;&lt;p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 DirectSpecification&lt;\/p>&#187; data-abbr=&#187;\u043f\u0440\u043e\u0441\u0442\u044b\u0435 &#171;>\u043f\u0440\u043e\u0441\u0442\u044b\u0435 <\/abbr>\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 <code>DirectSpecification&lt;TEntity><\/code>), \u0442\u0430\u043a \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 <abbr class=\"habraabbr\" title=\"\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 DirectSpecification\" data-title=\"&lt;p>&#187; data-title=&#187;&lt;p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 DirectSpecification&lt;\/p>&lt;p>&lt;\/p>&#187; data-abbr=&#187;\u043f\u0440\u043e\u0441\u0442\u043e\u0439&#187;>\u043f\u0440\u043e\u0441\u0442\u043e\u0439<\/abbr> \u0438 <abbr class=\"habraabbr\" title=\"\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Or \u0438\u043b\u0438 And \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\" data-title=\"&lt;p>\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438&#187; data-title=&lt;p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 Or \u0438\u043b\u0438 And \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438&lt;\/p>&lt;p>&lt;\/p>&#187; data-abbr=&#187;\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439&#187;>\u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439<\/abbr> \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 AndSpecification&lt;TEntity><\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/\/ &lt;summary> \/\/\/     \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0418 \/\/\/ &lt;\/summary> public sealed class AndSpecification&lt;TEntity> : SpecificationBase&lt;TEntity>    where TEntity : class {     #region Fields      private readonly ISpecification&lt;TEntity> _rightSideSpecification;     private readonly ISpecification&lt;TEntity> _leftSideSpecification;      #endregion      #region .ctor      \/\/\/ &lt;inheritdoc \/>     public override object Clone()     {         var left = (ISpecification&lt;TEntity>)_leftSideSpecification.Clone();         var right = (ISpecification&lt;TEntity>)_leftSideSpecification.Clone();          return new AndSpecification&lt;TEntity>(left, right);     }      \/\/\/ &lt;inheritdoc cref=\"AndSpecification{TEnity}\" \/>     public AndSpecification(         ISpecification&lt;TEntity> leftSide,         ISpecification&lt;TEntity> rightSide)     {         Assert.NotNull(leftSide, \"Left specification cannot be null\");         Assert.NotNull(rightSide, \"Right specification cannot be null\");          _leftSideSpecification = leftSide;         _rightSideSpecification = rightSide;     }      #endregion      #region Implementation Of SpecificationBase      \/\/\/ &lt;inheritdoc \/>     public override Expression&lt;Func&lt;TEntity, bool>>? SatisfiedBy()     {         var left = _leftSideSpecification.SatisfiedBy();         var right = _rightSideSpecification.SatisfiedBy();        <\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-361873","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/361873","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=361873"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/361873\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=361873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=361873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=361873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}