{"id":357289,"date":"2024-05-20T23:47:36","date_gmt":"2024-05-20T23:47:36","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=357289"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T23:47:36","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=357289","title":{"rendered":"<span>\u041f\u044f\u0442\u044c \u0437\u0430\u0431\u0430\u0432\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u043a\u043e\u0434\u0435 Entity Framework Core<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 Entity Framework Core \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044b, \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043e\u043f\u044b\u0442\u0443, \u0440\u0435\u0432\u044c\u044e \u0438 \u043c\u043e\u0449\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0434\u0430\u0436\u0435 \u0432 \u0442\u0430\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435 \u0431\u0435\u0437 \u043f\u0440\u0438\u043a\u043e\u043b\u043e\u0432. \u041f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044f\u0445, \u0443\u043a\u0440\u044b\u0432\u0448\u0438\u0445\u0441\u044f \u043e\u0442 \u0432\u0437\u0433\u043b\u044f\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/386\/ab3\/73a\/386ab373acb1221b945744eb466291a3.png\" alt=\"1070_EntityFrameworkCoreCheck_ru\/image1.png\" title=\"\" width=\"1600\" height=\"902\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/386\/ab3\/73a\/386ab373acb1221b945744eb466291a3.png\"\/><\/figure>\n<h3>\u041c\u0438\u043d\u0438-\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0441\u0442\u0430\u0442\u044c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0446\u0435\u043b\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PVS-Studio \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u041a\u043e\u0434 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d :). \u0422\u0430\u043a \u0447\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u044f \u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u0438\u0437\u043c, \u044d\u0442\u043e \u0431\u044b\u043b \u043d\u0435 \u0441\u0430\u0440\u043a\u0430\u0437\u043c.<\/p>\n<p>\u042d\u0442\u043e \u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442, \u043d\u043e \u043d\u0435 \u043c\u043e\u0433\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u0440\u0430\u0437\u0431\u043e\u0440 \u043e\u0448\u0438\u0431\u043e\u043a. \u0415\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0438, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u0447\u0438\u0441\u0442\u044b\u043c, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c, \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0432\u044b\u0434\u0430\u0451\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u044f\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 PVS-Studio 7.26. \u0412\u0435\u0440\u0441\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e Entity Framework Core \u2014 <a href=\"https:\/\/github.com\/dotnet\/efcore\/releases\/tag\/v7.0.10\">7.0.10<\/a>. \u0422\u043e\u043f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0441\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043e \u0441\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0435 \u043c\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u2014 \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043e\u0431\u0441\u0443\u0434\u0438\u043c.<\/p>\n<h3>5 \u043c\u0435\u0441\u0442\u043e. \u041d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c<\/h3>\n<pre><code class=\"cs\">protected virtual ModelBuilder VisitDatabaseModel(....) {   ....   if (!string.IsNullOrEmpty(databaseModel.DatabaseName)) \/\/ &lt;=   {     modelBuilder.Model.SetDatabaseName(            !_options.UseDatabaseNames         &amp;&amp; !string.IsNullOrEmpty(databaseModel.DatabaseName) \/\/ &lt;=       ? _candidateNamingService.GenerateCandidateIdentifier(....)       : databaseModel.DatabaseName     );   }   .... } <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u0442\u043e\u043f\u0430 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0434\u0435\u044e, \u043b\u0435\u0436\u0430\u0449\u0443\u044e \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043d\u0430\u0448\u0451\u043b \u0432 Entity Framework Core. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043f\u0440\u0438\u0447\u0451\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432\u0443.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 <em>databaseModel.DatabaseName<\/em> \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438\u043b\u0438 <em>null<\/em>. \u0415\u0441\u043b\u0438 \u0442\u0430\u043c \u043b\u0435\u0436\u0438\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0434 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0435\u0449\u0451 \u0440\u0430\u0437. \u0417\u0430\u0447\u0435\u043c? \u0427\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0445\u043e\u0442\u0435\u043b \u044d\u0442\u0438\u043c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f?<\/p>\n<p>\u0418 \u0432\u0435\u0434\u044c \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0435 \u2014 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e 3 \u0441\u0442\u0440\u043e\u0447\u043a\u0438! \u041d\u0443 \u043a\u0430\u043a \u0442\u0430\u043a-\u0442\u043e?<\/p>\n<details class=\"spoiler\">\n<summary>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u0441\u0442\u0440\u043e\u0447\u043a\u0430\u0445<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043c\u043d\u043e\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u2014 4 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 (\u043e \u0434\u0430, \u044d\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 :D). \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043e\u0442\u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043a\u043e\u0434 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u043b\u0435\u0433\u043a\u0430 \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0412 &#171;\u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435&#187; \u0432\u044b\u0437\u043e\u0432\u044b <em>_options.UseDatabaseNames<\/em> \u0438 \u043b\u0438\u0448\u043d\u044f\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 <em>DatabaseName<\/em> \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443. <\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430:<\/p>\n<p><a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3063\/\">V3063<\/a> A part of conditional expression is always true if it is evaluated: !string.IsNullOrEmpty(databaseModel.DatabaseName).<\/p>\n<h3>4 \u043c\u0435\u0441\u0442\u043e. \u041c\u043e\u0434\u0435\u043b\u0438 \u043d\u0435\u0442, \u0432\u043e\u0437\u044c\u043c\u0438\u0442\u0435 \u0438\u0437 \u043d\u0435\u0451 \u0441\u0445\u0435\u043c\u0443<\/h3>\n<pre><code class=\"cs\">protected virtual IEnumerable&lt;IReadOnlyModificationCommand>    GenerateModificationCommands(InsertDataOperation operation,                                IModel? model) {   ....    if (   operation.ColumnTypes != null       &amp;&amp; operation.Columns.Length != operation.ColumnTypes.Length)   {     throw new InvalidOperationException(         RelationalStrings.InsertDataOperationTypesCountMismatch(             ....,             FormatTable(operation.Table,                         operation.Schema ?? model?.GetDefaultSchema())));   }     if (operation.ColumnTypes == null &amp;&amp; model == null)   {     throw new InvalidOperationException(         RelationalStrings.InsertDataOperationNoModel(             FormatTable(operation.Table,                         operation.Schema ?? model?.GetDefaultSchema())));   }   .... } <\/code><\/pre>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u0432\u0434\u0443\u043c\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043a\u0430\u043a\u0430\u044f \u0442\u0430\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430, \u043f\u0440\u043e \u0447\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0438\u0442\u044c :). \u0412 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043c\u044b \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e <em>model<\/em> \u0440\u0430\u0432\u043d\u0430 <em>null<\/em>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043a\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e <strong>\u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0435\u0442<\/strong>. \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043f\u0440\u0438 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043c\u043e\u0434\u0435\u043b\u0438? \ud83d\ude42<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0433\u043e\u0434\u0438, \u0442\u0430\u043c \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217;, \u0432\u0441\u0451 \u043e\u043a!<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u0435\u043b\u043e \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u0442\u0443\u0442 \u043a \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 (\u043a\u0430\u0436\u0435\u0442\u0441\u044f) \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044f\u0441\u044c \u043e \u0435\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0435. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0438 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u043e\u0434 .NET, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043c\u0443\u0449\u0430\u0435\u0442. <\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0440\u0443\u0433\u0430\u044f \u0442\u0435\u043e\u0440\u0438\u044f \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0438 \u0432\u043c\u0435\u0441\u0442\u043e &#8216;&amp;&amp;&#8217; \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c &#8216;||&#8217;. \u041d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u043e\u043c\u044b\u0441\u043b\u044b.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0442\u0443\u0442 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u044f \u043d\u0430\u0448\u0451\u043b \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3022\/\">V3022<\/a>:<\/p>\n<p>Expression &#8216;model&#8217; is always null. The operator &#8216;?.&#8217; is meaningless.<\/p>\n<h3>3 \u043c\u0435\u0441\u0442\u043e. \u0414\u0432\u043e\u0439\u043d\u043e\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c<\/h3>\n<pre><code class=\"cs\">public virtual SqlExpression? Translate(....) {   if (SupportedMethods.TryGetValue(method, out var sqlFunctionName))   {     RelationalTypeMapping? typeMapping;     List&lt;SqlExpression>? newArguments = null;     if (sqlFunctionName == \"max\" || sqlFunctionName == \"max\") \/\/ &lt;=     {       typeMapping = ExpressionExtensions.InferTypeMapping(arguments[0],                                                            arguments[1]);       newArguments = new List&lt;SqlExpression>       {         ....       };     }     else     {       typeMapping = arguments[0].TypeMapping;     }      var finalArguments = newArguments ?? arguments;      return _sqlExpressionFactory.Function(....);   }    return null; } <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0430\u0441\u043d\u0435\u0435. \u041f\u043e\u0445\u043e\u0436\u0435, \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>max<\/em> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u043e\u0441\u043e\u0431\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430. \u041d\u0443 \u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0436\u0435 \u0445\u043e\u0442\u0435\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0435\u0449\u0451 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0441\u0443\u0434\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>min<\/em>, \u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>\u0423\u0432\u044b, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442: &#171;\u0410 \u043c\u043e\u0436\u0435\u0442, \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 max?&#187; (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043d\u0443\u043b\u043e <em>false<\/em>). \u041d\u0435, \u043d\u0443 \u0430 \u0432\u0434\u0440\u0443\u0433 \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c? \ud83d\ude42<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0438 PVS-Studio \u0434\u0430\u0451\u0442 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439:<\/p>\n<p><a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3001\/\">V3001<\/a> There are identical sub-expressions &#8216;sqlFunctionName == &#171;max&#187;&#8216; to the left and to the right of the &#8216;||&#8217; operator.<\/p>\n<h3>2 \u043c\u0435\u0441\u0442\u043e. \u041f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0443\u0441\u043f\u0435\u0445<\/h3>\n<pre><code class=\"cs\">public override Expression Visit(Expression expression) {   ....   if (   TryGetPartitionKeyProperty(entityType,                                     out var partitionKeyProperty)       &amp;&amp; entityTypePrimaryKeyProperties.SequenceEqual(queryProperties)       &amp;&amp; (partitionKeyProperty == null || ....)       &amp;&amp; ....)   {     var propertyParameterList = queryProperties.Zip(....);      var readItemExpression = new ReadItemExpression(entityType,                                                      propertyParameterList);      return ....;   }   .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0433\u043b\u044f\u0434\u0435\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434. \u0412\u0438\u0434\u0438\u0442\u0435 \u043b\u0438 \u0432\u044b \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c, \u0441\u043a\u0440\u044b\u0442\u0443\u044e \u0432 \u043d\u0451\u043c?<\/p>\n<p>\u041d\u0443, \u044f \u0442\u043e\u0436\u0435 \u043d\u0435 \u0432\u0438\u0436\u0443 :). \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u0442\u0443\u0442, \u043c\u043e\u0436\u0435\u0442, \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043d\u0435\u0442, \u043d\u043e \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0441\u043b\u0443\u0447\u0430\u0439 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439.<\/p>\n<p>\u041d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>TryGetPartitionKeyProperty<\/em>. \u041f\u043e \u0438\u0434\u0435\u0435, \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 Try-\u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>true<\/em>, \u0435\u0441\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430, \u0438 <em>false<\/em> \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u044f, \u0442\u043e \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e \u2014 \u043a\u043e\u0434 \u0432\u0430\u0441 \u043e\u0431\u043c\u0430\u043d\u0443\u043b. \u0412\u0435\u0434\u044c \u043c\u0435\u0442\u043e\u0434 <em>TryGetPartitionKeyProperty<\/em> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">static bool TryGetPartitionKeyProperty(IEntityType entityType,                                        out IProperty partitionKeyProperty) {   var partitionKeyPropertyName = entityType.GetPartitionKeyPropertyName();   if (partitionKeyPropertyName is null)   {     partitionKeyProperty = null;     return true;   }    partitionKeyProperty = entityType.FindProperty(partitionKeyPropertyName);   return true; } <\/code><\/pre>\n<p>\u041d\u0443 \u043a\u0430\u043a \u0431\u044b \u0434\u0430, \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438, \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e :).<\/p>\n<p>\u0421\u043f\u043e\u0440\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0442\u0443\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>partitionKeyPropertyName<\/em> \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e, \u0442\u043e \u0432 out-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u044f\u0432\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>null.<\/em> \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <em>TryGetPartitionKeyProperty<\/em> \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e (\u0447\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f). \u041d\u0430 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0441 \u0434\u0432\u0443\u0445 \u0441\u0442\u043e\u0440\u043e\u043d.<\/p>\n<p>\u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0442\u0443\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e, \u0432\u0435\u0434\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432\u043f\u043e\u043b\u043d\u0435 \u0433\u043e\u0442\u043e\u0432 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432 out-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d <em>null<\/em>:<\/p>\n<pre><code class=\"cs\">if (   TryGetPartitionKeyProperty(entityType,                                   out var partitionKeyProperty)     &amp;&amp; entityTypePrimaryKeyProperties.SequenceEqual(queryProperties)     &amp;&amp; (partitionKeyProperty == null || ....)     &amp;&amp; ....) <\/code><\/pre>\n<p>\u0414\u0430, \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b <em>IProperty<\/em> (\u0431\u0435\u0437\u043e \u0432\u0441\u044f\u043a\u0438\u0445 Try, out-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f). \u041d\u043e \u043a\u0430\u043a \u0431\u044b \u0432\u0440\u043e\u0434\u0435 \u0438 \u043d\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e.<\/p>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043d\u0430 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 <em>null<\/em>. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043e\u043d\u0430 \u043c\u043e\u0433\u043b\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 <em>null<\/em> \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u044b\u0437\u043e\u0432 <em>entityType.FindProperty(partitionKeyPropertyName)<\/em>.<\/p>\n<p>\u042f \u0441\u043a\u043b\u043e\u043d\u044f\u044e\u0441\u044c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0442\u0443\u0442 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u041d\u0443 \u043e\u0447\u0435\u043d\u044c \u0443\u0436 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <em>TryGetPartitionKeyProperty<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 *true *(\u043a\u0430\u043a \u0431\u044b \u0433\u043e\u0432\u043e\u0440\u044f: &#171;\u0414\u0430, \u043c\u044b \u0432\u0441\u0451 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438!&#187;), \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0430\u043c \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <em>null<\/em> \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 out-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0440\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u044f \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044e PVS-Studio:<\/p>\n<p><a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3063\/\">V3063<\/a> A part of conditional expression is always true if it is evaluated: TryGetPartitionKeyProperty(entityType, out var partitionKeyProperty).<\/p>\n<h3>1 \u043c\u0435\u0441\u0442\u043e. \u0414\u0430 \u043a\u043e\u043c\u0443 \u043d\u0443\u0436\u0435\u043d \u044d\u0442\u043e\u0442 ef.exe?<\/h3>\n<pre><code class=\"cs\">protected override int Execute(string[] _) {   ....   var targetPlatformIdentifier = startupProject.TargetPlatformIdentifier!;   if (   targetPlatformIdentifier.Length != 0       &amp;&amp; !string.Equals(targetPlatformIdentifier, \"Windows\", ....))   {     executable = Path.Combine(             toolsPath,             \"net461\",             startupProject.PlatformTarget switch             {               \"x86\" => \"win-x86\",               \"ARM64\" => \"win-arm64\",               _ => \"any\"             },             \"ef.exe\");   }    executable = \"dotnet\";   args.Add(\"exec\");   args.Add(\"--depsfile\");   args.Add(depsFile);    ....    return Exe.Run(executable, args, startupProject.ProjectDir); } <\/code><\/pre>\n<p>\u042f \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043f\u043e\u0437\u0430\u0431\u0430\u0432\u0438\u043b \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0440\u0443\u0433\u0438\u0445. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0451\u0442 \u0441\u0443\u0440\u043e\u0432\u0430\u044f \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0434\u0451\u0442 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <em>Path.Combine<\/em>. \u0410 \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0442\u0438\u0440\u0430\u044e\u0442\u0441\u044f :). \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0441\u0442\u043e &#8216;dotnet&#8217; \u0438 \u0432\u0441\u0451.<\/p>\n<p>\u0418 \u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u043c\u0435\u044e \u043f\u0440\u043e\u0442\u0438\u0432, \u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0438 \u0437\u0430\u0431\u0430\u0432\u043d\u043e. \u0415\u0441\u043b\u0438 \u0442\u0443\u0442 \u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438, \u0442\u043e \u043e\u043f\u044f\u0442\u044c \u0438\u043c\u0435\u0435\u043c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0434\u0438\u043a\u0443\u044e \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438, \u0431\u0443\u0434\u0442\u043e \u0432 \u043a\u043e\u0434 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0431\u0435\u0437 \u043e\u0433\u043b\u044f\u0434\u043a\u0438 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432\u0443. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u0438\u044f\u043d\u0438\u044f \u0432\u0435\u0442\u043e\u043a.<\/p>\n<p>\u041d\u0430\u0448\u0451\u043b \u044f \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u043e\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3008\/\">V3008<\/a>:<\/p>\n<p>The &#8216;executable&#8217; variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 139, 127.<\/p>\n<h3>\u041c\u0438\u043d\u0438-\u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0432\u0441\u0435 \u043c\u043e\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f, \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e Entity Framework \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043f\u0438\u0448\u0443\u0442 \u043c\u043e\u0449\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044b. \u041f\u043e\u0447\u0442\u0438 \u043d\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430 100% \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0430 \u044f, \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0441\u0430\u043c\u043e\u0435 \u043b\u0443\u0447\u0448\u0435\u0435.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f, \u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a \u0432\u044b\u0448\u043b\u043e, \u0447\u0442\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043e\u043d \u0432\u043f\u043e\u043b\u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u043c\u0430\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u0442\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <a href=\"https:\/\/pvs-studio.ru\/ru\/pvs-studio\/try-free-a\/?utm_source=website&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=1070\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u041d\u0443 \u0430 \u043c\u0435\u043d\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e :).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0441 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: Nikita Lipilin. <a href=\"https:\/\/pvs-studio.com\/en\/blog\/posts\/csharp\/1070\/\">5 amusing oddities in the code of Entity Framework Core<\/a>.<\/p>\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\/766948\/\"> https:\/\/habr.com\/ru\/articles\/766948\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 Entity Framework Core \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044b, \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043e\u043f\u044b\u0442\u0443, \u0440\u0435\u0432\u044c\u044e \u0438 \u043c\u043e\u0449\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0434\u0430\u0436\u0435 \u0432 \u0442\u0430\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435 \u0431\u0435\u0437 \u043f\u0440\u0438\u043a\u043e\u043b\u043e\u0432. \u041f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044f\u0445, \u0443\u043a\u0440\u044b\u0432\u0448\u0438\u0445\u0441\u044f \u043e\u0442 \u0432\u0437\u0433\u043b\u044f\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>\u041c\u0438\u043d\u0438-\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0441\u0442\u0430\u0442\u044c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0446\u0435\u043b\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a, \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PVS-Studio \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u041a\u043e\u0434 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d :). \u0422\u0430\u043a \u0447\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u044f \u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u0438\u0437\u043c, \u044d\u0442\u043e \u0431\u044b\u043b \u043d\u0435 \u0441\u0430\u0440\u043a\u0430\u0437\u043c.<\/p>\n<p>\u042d\u0442\u043e \u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442, \u043d\u043e \u043d\u0435 \u043c\u043e\u0433\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u0440\u0430\u0437\u0431\u043e\u0440 \u043e\u0448\u0438\u0431\u043e\u043a. \u0415\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0438, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u0447\u0438\u0441\u0442\u044b\u043c, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c, \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0432\u044b\u0434\u0430\u0451\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u044f\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 PVS-Studio 7.26. \u0412\u0435\u0440\u0441\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e Entity Framework Core \u2014 <a href=\"https:\/\/github.com\/dotnet\/efcore\/releases\/tag\/v7.0.10\">7.0.10<\/a>. \u0422\u043e\u043f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0441\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043e \u0441\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0435 \u043c\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u2014 \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043e\u0431\u0441\u0443\u0434\u0438\u043c.<\/p>\n<h3>5 \u043c\u0435\u0441\u0442\u043e. \u041d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c<\/h3>\n<pre><code class=\"cs\">protected virtual ModelBuilder VisitDatabaseModel(....) {   ....   if (!string.IsNullOrEmpty(databaseModel.DatabaseName)) \/\/ &lt;=   {     modelBuilder.Model.SetDatabaseName(            !_options.UseDatabaseNames         &amp;&amp; !string.IsNullOrEmpty(databaseModel.DatabaseName) \/\/ &lt;=       ? _candidateNamingService.GenerateCandidateIdentifier(....)       : databaseModel.DatabaseName     );   }   .... } <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u0442\u043e\u043f\u0430 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0434\u0435\u044e, \u043b\u0435\u0436\u0430\u0449\u0443\u044e \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043d\u0430\u0448\u0451\u043b \u0432 Entity Framework Core. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043f\u0440\u0438\u0447\u0451\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432\u0443.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 <em>databaseModel.DatabaseName<\/em> \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438\u043b\u0438 <em>null<\/em>. \u0415\u0441\u043b\u0438 \u0442\u0430\u043c \u043b\u0435\u0436\u0438\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0434 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0435\u0449\u0451 \u0440\u0430\u0437. \u0417\u0430\u0447\u0435\u043c? \u0427\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0445\u043e\u0442\u0435\u043b \u044d\u0442\u0438\u043c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f?<\/p>\n<p>\u0418 \u0432\u0435\u0434\u044c \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0435 \u2014 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e 3 \u0441\u0442\u0440\u043e\u0447\u043a\u0438! \u041d\u0443 \u043a\u0430\u043a \u0442\u0430\u043a-\u0442\u043e?<\/p>\n<details class=\"spoiler\">\n<summary>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u0441\u0442\u0440\u043e\u0447\u043a\u0430\u0445<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043c\u043d\u043e\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u2014 4 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 (\u043e \u0434\u0430, \u044d\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 :D). \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043e\u0442\u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043a\u043e\u0434 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u043b\u0435\u0433\u043a\u0430 \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0412 &#171;\u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435&#187; \u0432\u044b\u0437\u043e\u0432\u044b <em>_options.UseDatabaseNames<\/em> \u0438 \u043b\u0438\u0448\u043d\u044f\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 <em>DatabaseName<\/em> \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443. <\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043d\u0430\u0439\u0434\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430:<\/p>\n<p><a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3063\/\">V3063<\/a> A part of conditional expression is always true if it is evaluated: !string.IsNullOrEmpty(databaseModel.DatabaseName).<\/p>\n<h3>4 \u043c\u0435\u0441\u0442\u043e. \u041c\u043e\u0434\u0435\u043b\u0438 \u043d\u0435\u0442, \u0432\u043e\u0437\u044c\u043c\u0438\u0442\u0435 \u0438\u0437 \u043d\u0435\u0451 \u0441\u0445\u0435\u043c\u0443<\/h3>\n<pre><code class=\"cs\">protected virtual IEnumerable&lt;IReadOnlyModificationCommand>    GenerateModificationCommands(InsertDataOperation operation,                                IModel? model) {   ....    if (   operation.ColumnTypes != null       &amp;&amp; operation.Columns.Length != operation.ColumnTypes.Length)   {     throw new InvalidOperationException(         RelationalStrings.InsertDataOperationTypesCountMismatch(             ....,             FormatTable(operation.Table,                         operation.Schema ?? model?.GetDefaultSchema())));   }     if (operation.ColumnTypes == null &amp;&amp; model == null)   {     throw new InvalidOperationException(         RelationalStrings.InsertDataOperationNoModel(             FormatTable(operation.Table,                         operation.Schema ?? model?.GetDefaultSchema())));   }   .... } <\/code><\/pre>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u0432\u0434\u0443\u043c\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043a\u0430\u043a\u0430\u044f \u0442\u0430\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430, \u043f\u0440\u043e \u0447\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0438\u0442\u044c :). \u0412 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043c\u044b \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e <em>model<\/em> \u0440\u0430\u0432\u043d\u0430 <em>null<\/em>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043a\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e <strong>\u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0435\u0442<\/strong>. \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043f\u0440\u0438 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043c\u043e\u0434\u0435\u043b\u0438? \ud83d\ude42<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0433\u043e\u0434\u0438, \u0442\u0430\u043c \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8216;?.&#8217;, \u0432\u0441\u0451 \u043e\u043a!<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u0435\u043b\u043e \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u0442\u0443\u0442 \u043a \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 (\u043a\u0430\u0436\u0435\u0442\u0441\u044f) \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044f\u0441\u044c \u043e \u0435\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0435. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0438 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u043e\u0434 .NET, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043c\u0443\u0449\u0430\u0435\u0442. <\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0440\u0443\u0433\u0430\u044f \u0442\u0435\u043e\u0440\u0438\u044f \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u0438 \u0432\u043c\u0435\u0441\u0442\u043e &#8216;&amp;&amp;&#8217; \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c &#8216;||&#8217;. \u041d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u043e\u043c\u044b\u0441\u043b\u044b.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0442\u0443\u0442 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u044f \u043d\u0430\u0448\u0451\u043b \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3022\/\">V3022<\/a>:<\/p>\n<p>Expression &#8216;model&#8217; is always null. The operator &#8216;?.&#8217; is meaningless.<\/p>\n<h3>3 \u043c\u0435\u0441\u0442\u043e. \u0414\u0432\u043e\u0439\u043d\u043e\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c<\/h3>\n<pre><code class=\"cs\">public virtual SqlExpression? Translate(....) {   if (SupportedMethods.TryGetValue(method, out var sqlFunctionName))   {     RelationalTypeMapping? typeMapping;     List&lt;SqlExpression>? newArguments = null;     if (sqlFunctionName == \"max\" || sqlFunctionName == \"max\") \/\/ &lt;=     {       typeMapping = ExpressionExtensions.InferTypeMapping(arguments[0],                                                            arguments[1]);       newArguments = new List&lt;SqlExpression>       {         ....       };     }     else     {       typeMapping = arguments[0].TypeMapping;     }      var finalArguments = newArguments ?? arguments;      return _sqlExpressionFactory.Function(....);   }    return null; } <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0430\u0441\u043d\u0435\u0435. \u041f\u043e\u0445\u043e\u0436\u0435, \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>max<\/em> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u043e\u0441\u043e\u0431\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430. \u041d\u0443 \u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0436\u0435 \u0445\u043e\u0442\u0435\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0435\u0449\u0451 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0441\u0443\u0434\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>min<\/em>, \u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>\u0423\u0432\u044b, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442: &#171;\u0410 \u043c\u043e\u0436\u0435\u0442, \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 max?&#187; (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043d\u0443\u043b\u043e <em>false<\/em>). \u041d\u0435, \u043d\u0443 \u0430 \u0432\u0434\u0440\u0443\u0433 \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c? \ud83d\ude42<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0438 PVS-Studio \u0434\u0430\u0451\u0442 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439:<\/p>\n<p><a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3001\/\">V3001<\/a> There are identical sub-expressions &#8216;sqlFunctionName == &#171;max&#187;&#8216; to the left and to the right of the &#8216;||&#8217; operator.<\/p>\n<h3>2 \u043c\u0435\u0441\u0442\u043e. \u041f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0443\u0441\u043f\u0435\u0445<\/h3>\n<pre><code class=\"cs\">public override Expression Visit(Expression expression) {   ....   if (   TryGetPartitionKeyProperty(entityType,                                     out var partitionKeyProperty)       &amp;&amp; entityTypePrimaryKeyProperties.SequenceEqual(queryProperties)       &amp;&amp; (partitionKeyProperty == null || ....)       &amp;&amp; ....)   {     var propertyParameterList = queryProperties.Zip(....);      var readItemExpression = new ReadItemExpression(entityType,                                                      propertyParameterList);      return ....;   }   .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0433\u043b\u044f\u0434\u0435\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434. \u0412\u0438\u0434\u0438\u0442\u0435 \u043b\u0438 \u0432\u044b \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c, \u0441\u043a\u0440\u044b\u0442\u0443\u044e \u0432 \u043d\u0451\u043c?<\/p>\n<p>\u041d\u0443, \u044f \u0442\u043e\u0436\u0435 \u043d\u0435 \u0432\u0438\u0436\u0443 :). \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u0442\u0443\u0442, \u043c\u043e\u0436\u0435\u0442, \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043d\u0435\u0442, \u043d\u043e \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0441\u043b\u0443\u0447\u0430\u0439 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439.<\/p>\n<p>\u041d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>TryGetPartitionKeyProperty<\/em>. \u041f\u043e \u0438\u0434\u0435\u0435, \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 Try-\u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>true<\/em>, \u0435\u0441\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430, \u0438 <em>false<\/em> \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u044f, \u0442\u043e \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e \u2014 \u043a\u043e\u0434 \u0432\u0430\u0441 \u043e\u0431\u043c\u0430\u043d\u0443\u043b. \u0412\u0435\u0434\u044c \u043c\u0435\u0442\u043e\u0434 <em>TryGetPartitionKeyProperty<\/em> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">static bool TryGetPartitionKeyProperty(IEntityType entityType,                                        out IProperty partitionKeyProperty) {   var partitionKeyPropertyName = entityType.GetPartitionKeyPropertyName();   if (partitionKeyPropertyName is null)   {     partitionKeyProperty = null;     return true;   }    partitionKeyProperty = entityType.FindProperty(partitionKeyPropertyName);   return true; } <\/code><\/pre>\n<p>\u041d\u0443 \u043a\u0430\u043a \u0431\u044b \u0434\u0430, \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438, \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e :).<\/p>\n<p>\u0421\u043f\u043e\u0440\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0442\u0443\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>partitionKeyPropertyName<\/em> \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e, \u0442\u043e \u0432 out-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u044f\u0432\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>null.<\/em> \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <em>TryGetPartitionKeyProperty<\/em> \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e (\u0447\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f). \u041d\u0430 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0441 \u0434\u0432\u0443\u0445 \u0441\u0442\u043e\u0440\u043e\u043d.<\/p>\n<p>\u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0442\u0443\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e, \u0432\u0435\u0434\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432\u043f\u043e\u043b\u043d\u0435 \u0433\u043e\u0442\u043e\u0432 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432 out-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d <em>null<\/em>:<\/p>\n<pre><code class=\"cs\">if (   TryGetPartitionKeyProperty(entityType,                                   out var partitionKeyProperty)     &amp;&amp; entityTypePrimaryKeyProperties.SequenceEqual(queryProperties)     &amp;&amp; (partitionKeyProperty == null || ....)     &amp;&amp; ....) <\/code><\/pre>\n<p>\u0414\u0430, \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b <em>IProperty<\/em> (\u0431\u0435\u0437\u043e \u0432\u0441\u044f\u043a\u0438\u0445 Try, out-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f). \u041d\u043e \u043a\u0430\u043a \u0431\u044b \u0432\u0440\u043e\u0434\u0435 \u0438 \u043d\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e.<\/p>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043d\u0430 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 <em>null<\/em>. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043e\u043d\u0430 \u043c\u043e\u0433\u043b\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 <em>null<\/em> \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u044b\u0437\u043e\u0432 <em>entityType.FindProperty(partitionKeyPropertyName)<\/em>.<\/p>\n<p>\u042f \u0441\u043a\u043b\u043e\u043d\u044f\u044e\u0441\u044c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0442\u0443\u0442 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u041d\u0443 \u043e\u0447\u0435\u043d\u044c \u0443\u0436 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <em>TryGetPartitionKeyProperty<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 *true *(\u043a\u0430\u043a \u0431\u044b \u0433\u043e\u0432\u043e\u0440\u044f: &#171;\u0414\u0430, \u043c\u044b \u0432\u0441\u0451 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438!&#187;), \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0430\u043c \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <em>null<\/em> \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 out-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0440\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u044f \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044e PVS-Studio:<\/p>\n<p><a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v3063\/\">V3063<\/a> A part of conditional expression is always true if it is evaluated: TryGetPartitionKeyProperty(entityType, out var partitionKeyProperty).<\/p>\n<h3>1 \u043c\u0435\u0441\u0442\u043e. \u0414\u0430 \u043a\u043e\u043c\u0443 \u043d\u0443\u0436\u0435\u043d \u044d\u0442\u043e\u0442 ef.exe?<\/h3>\n<pre><code class=\"cs\">protected override int Execute(string[] _) {   ....   var targetPlatformIdentifier = startupProject.TargetPlatformIdentifier!;   if (   targetPlatformIdentifier.Length != 0       &amp;&amp; !string.Equals(targetPlatformIdentifier, \"Windows\", ....))   {     executable = Path.Combine(             toolsPath,             \"net461\",             startupProject.PlatformTarget switch             {               \"x86\" => \"win-x86\",               \"ARM64\" => \"win-arm64\",               _ => \"any\"             },             \"ef.exe\");   }    executable = \"dotnet\";   args.Add(\"exec\");   args.Add(\"--depsfile\");   args.Add(depsFile);    ....    return Exe.Run(executable, args, startupProject.ProjectDir); } <\/code><\/pre>\n<p>\u042f \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043f\u043e\u0437\u0430\u0431\u0430\u0432\u0438\u043b \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0440\u0443\u0433\u0438\u0445. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0451\u0442 \u0441\u0443\u0440\u043e\u0432\u0430\u044f \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0434\u0451\u0442 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <em>Path.Combine<\/em>. \u0410 \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0442\u0438\u0440\u0430\u044e\u0442\u0441\u044f :). \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0441\u0442\u043e &#8216;dotnet&#8217; \u0438 \u0432\u0441\u0451.<\/p>\n<p>\u0418 \u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u043c\u0435\u044e \u043f\u0440\u043e\u0442\u0438\u0432, \u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0438 \u0437\u0430\u0431\u0430\u0432\u043d\u043e.<\/p>\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-357289","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357289","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=357289"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357289\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=357289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=357289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=357289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}