{"id":275564,"date":"2016-03-05T23:29:44","date_gmt":"2016-03-05T20:29:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=275564"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=275564","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0421\u0423\u0411\u0414 Firebird \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432: ADO.NET Entity Framework 6"},"content":{"rendered":"<p>       \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0421\u0423\u0411\u0414 Firebird \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 Entity Framework \u0438 \u0441\u0440\u0435\u0434\u044b Visual Studio 2015. <\/p>\n<p>  <b>ADO.NET Entity Framework (EF)<\/b> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f object-relational mapping (ORM) \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f .NET Framework \u043e\u0442 Microsoft. \u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043a\u0430\u043a \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c LINQ \u0432 \u0432\u0438\u0434\u0435 LINQ to Entities, \u0442\u0430\u043a \u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Entity SQL.<\/p>\n<p>  Entity Framework \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0442\u0440\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445:  <\/p>\n<ul>\n<li><b>Database first<\/b>: Entity Framework \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u0430\u0431\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<li><b>Model first<\/b>: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0442\u0435\u043c Entity Framework \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/li>\n<li><b>Code first<\/b>: \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0411\u0414, \u0430 \u0437\u0430\u0442\u0435\u043c Entity Framework \u043f\u043e \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0435\u0451 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/li>\n<\/ul>\n<p>  \u0412 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434 Code First, \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u044b \u0431\u0435\u0437 \u0442\u0440\u0443\u0434\u0430 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b.<\/p>\n<p>  \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/86f\/af9\/3c6\/86faf93c610848eca16be6e95739fa54.png\" alt=\"diagramm\" \/><\/div>\n<table>\n<tr>\n<td><b>\u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/b> <\/p>\n<p>  \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c. \u0412\u0430\u0448\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0440\u0443\u0433\u043e\u0439. \u041c\u043e\u0434\u0435\u043b\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0433\u0440\u043e\u043c\u043e\u0436\u0434\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.  <\/td>\n<\/tr>\n<\/table>\n<p><a name=\"habracut\"><\/a><\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 Visual Studio 2015 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Firebird<\/h2>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Firebird \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c:   <\/p>\n<ul>\n<li>FirebirdSql.Data.FirebirdClient.dll<\/li>\n<li>EntityFramework.Firebird.dll<\/li>\n<li>DDEX Provider for Visual Studio<\/li>\n<\/ul>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0435\u0440\u0432\u044b\u0445 \u0434\u0432\u0443\u0445 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043d\u0438 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e NuGet. \u0410 \u0432\u043e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0430\u0441\u0442\u0435\u0440\u043e\u0432 Visual Studio, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0443 \u0432\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u0441\u0438\u043b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>  \u0414\u043e\u0431\u0440\u044b\u0435 \u043b\u044e\u0434\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432 \u043e\u0434\u0438\u043d <a href=\"http:\/\/sourceforge.net\/projects\/firebird-4-8-0-ddex-installer\/\">\u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0440\u044f\u0434\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0443\u0447\u043d\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043a\u0430\u0447\u0430\u0442\u044c:  <\/p>\n<ul>\n<li><a href=\"http:\/\/sourceforge.net\/projects\/firebird\/files\/firebird-net-provider\/4.10.0.0\/FirebirdSql.Data.FirebirdClient-4.10.0.0.msi\/download\">FirebirdSql.Data.FirebirdClient-4.10.0.0.msi<\/a><\/li>\n<li><a href=\"http:\/\/sourceforge.net\/projects\/firebird\/files\/firebird-net-provider\/4.10.0.0\/EntityFramework.Firebird-4.10.0.0-NET45.7z\/download\">EntityFramework.Firebird-4.10.0.0-NET45.7z<\/a><\/li>\n<li><a href=\"http:\/\/sourceforge.net\/projects\/firebird\/files\/firebird-net-provider\/DDEX 3.0.2\/DDEXProvider-3.0.2.0.7z\/download\">DDEXProvider-3.0.2.0.7z<\/a><\/li>\n<li><a href=\"http:\/\/sourceforge.net\/projects\/firebird\/files\/firebird-net-provider\/DDEX 3.0.2\/DDEXProvider-3.0.2.0-src.7z\/download\">DDEXProvider-3.0.2.0-src.7z<\/a><\/li>\n<\/ul>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438:<\/p>\n<ol>\n<li>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c FirebirdSql.Data.FirebirdClient-4.10.0.0.msi<\/li>\n<li>\u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c EntityFramework.Firebird-4.10.0.0-NET45.7z \u0432 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c Firebird. \u0423 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u043f\u0430\u043f\u043a\u0430 c:\\Program Files (x86)\\FirebirdClient\\ <br \/> <br \/>\n<table>\n<tr>\n<td><b>\u0412\u0430\u0436\u043d\u043e!<\/b> <\/p>\n<p>  \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430. \u041a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u044b\u043c\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c\u0438.  <\/td>\n<\/tr>\n<\/table>\n<p>   <\/li>\n<li>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 Firebird \u0432 GAC. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 %PATH% \u043f\u0443\u0442\u044c \u0434\u043e \u0443\u0442\u0438\u043b\u0438\u0442\u044b gacutil \u0434\u043b\u044f .NET Framework 4.5. \u0423 \u043c\u0435\u043d\u044f \u044d\u0442\u043e\u0442 \u043f\u0443\u0442\u044c c:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 cmd \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c.<br \/>   <code>chdir &quot;c:\\Program Files (x86)\\FirebirdClient&quot;<br \/>  <\/code>   <\/li>\n<li>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e FirebirdSql.Data.FirebirdClient \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 GAC. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443<br \/>   <code>gacutil \/l FirebirdSql.Data.FirebirdClient<br \/>  Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.0<br \/>  c \u041a\u043e\u0440\u043f\u043e\u0440\u0430\u0446\u0438\u044f \u041c\u0430\u0439\u043a\u0440\u043e\u0441\u043e\u0444\u0442 (Microsoft Corporation). \u0412\u0441\u0435 \u043f\u0440\u0430\u0432\u0430 \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u044b.\n<p>  \u0412 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u044d\u0448\u0435 \u0441\u0431\u043e\u0440\u043e\u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0431\u043e\u0440\u043a\u0438:<br \/>   FirebirdSql.Data.FirebirdClient, Version=4.10.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL<\/p>\n<p>  \u0427\u0438\u0441\u043b\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 = 1<br \/>  <\/code><br \/>  \u0415\u0441\u043b\u0438 FirebirdSql.Data.FirebirdClient \u043d\u0435 \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 GAC, \u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b<br \/>  <code>gacutil \/i FirebirdSql.Data.FirebirdClient.dll<br \/>  <\/code>   <\/li>\n<li>\u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c EntityFramework.Firebird \u0432 GAC<br \/>  <code>gacutil \/i EntityFramework.Firebird.dll<br \/>  <\/code>   <\/li>\n<li>\u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c DDEXProvider-3.0.2.0.7z \u0432 \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e. \u042f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043b \u0435\u0451 \u0432 c:\\Program Files (x86)\\FirebirdDDEX\\<\/li>\n<li>\u0422\u0443\u0434\u0430 \u0436\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c DDEXProvider-3.0.2.0-src.7z \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u043e\u0434\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0430\u0440\u0445\u0438\u0432\u0430 \/reg_files\/VS2015<br \/> <br \/>\n<table>\n<tr>\n<td><b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u0440\u0430<\/b> <\/p>\n<p>  \u0417\u0430\u0431\u0430\u0432\u043d\u043e, \u043d\u043e \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0435\u0442 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0430\u0440\u0445\u0438\u0432\u0435 \u0441\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 dll \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u043d\u043e \u043e\u043d\u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u043a\u043e\u0434\u0430\u043c\u0438.  <\/td>\n<\/tr>\n<\/table>\n<p>  <\/li>\n<li>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b FirebirdDDEXProvider64.reg \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u043b\u043e\u043a\u043d\u043e\u0442\u0430. \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 %path% \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 FirebirdSql.VisualStudio.DataTools.dll\n<p>  &quot;CodeBase&quot;=&quot;c:\\\\Program Files (x86)\\\\FirebirdDDEX\\\\FirebirdSql.VisualStudio.DataTools.dll&quot;  <\/li>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0435\u0433\u043e. \u041d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0440\u0435\u0435\u0441\u0442\u0440 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0414\u0410.<\/li>\n<li>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b machine.config, \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u043f\u0443\u0442\u0438: C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Config<br \/>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0431\u043b\u043e\u043a\u043d\u043e\u0442\u043e\u043c. \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u0435\u043a\u0446\u0438\u044e <br \/>  <code> &lt;system.data&gt;<br \/>   &lt;DbProviderFactories&gt;<br \/>  <\/code><br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u044d\u0442\u0443 \u0441\u0435\u043a\u0446\u0438\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443:<br \/>  <code>&lt;add name=&quot;FirebirdClient Data Provider&quot; invariant=&quot;FirebirdSql.Data.FirebirdClient&quot; description=&quot;.Net Framework Data Provider for Firebird&quot; type=&quot;FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=4.10.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c&quot; \/&gt;<br \/>  <\/code><br \/> <br \/>\n<table>\n<tr>\n<td><b>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b> <br \/>  \u0412\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 4.10.0.  <\/td>\n<\/tr>\n<\/table>\n<p>  \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043b\u044f machine.config. \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 c:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\Config\\  <\/li>\n<\/ol>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0447\u0442\u043e \u0432\u0441\u0451 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Visual Studio 2015. \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 Firebird.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1d1\/fb2\/6e8\/1d1fb26e87534530961406e38fa352a8.png\" \/><\/div>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/91d\/a19\/d2b\/91da19d2bb504f019280e9c29d52f86d.png\" \/><\/div>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/32e\/e2c\/ded\/32ee2cdede7c4a49af43337dddecd78d.png\" \/><\/div>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/7c0\/4b9\/8b1\/7c04b98b158c4abdaedd7d82f745abad.png\" \/><\/div>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f Windows Forms \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0445\u043e\u0442\u044c \u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Firebird \u0447\u0435\u0440\u0435\u0437 Entity Framework \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0442\u0435 \u0436\u0435.<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f Windows Forms \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 NuGet \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:  <\/p>\n<ul>\n<li>FirebirdSql.Data.FirebirdClient<\/li>\n<li>EntityFramework<\/li>\n<li>EntityFramework.Firebird<\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0449\u0451\u043b\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0435\u0439 \u043c\u044b\u0448\u0438 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0432 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u043c \u043c\u0435\u043d\u044e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0443\u043d\u043a\u0442 \u00ab\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 NuGet\u00bb.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e3b\/05f\/b46\/e3b05fb469864521988eadf073e47d72.png\" \/><\/div>\n<p>  \u0412 \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u043c\u0441\u044f \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u0438\u0441\u043a \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f4a\/79d\/24d\/f4a79d24dc3e48be9b75d8766456c04d.png\" \/><\/div>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 EDM \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>  \u0412 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434 Code First. <\/p>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 EDM \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0449\u0451\u043b\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0435\u0439 \u043c\u044b\u0448\u0438 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0443\u043d\u043a\u0442 \u043c\u0435\u043d\u044e \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c -&gt; \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cb3\/3ca\/664\/cb33ca664d2749b291c79e684d01dafb.png\" \/><\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0432 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0443\u043d\u043a\u0442 \u00ab\u041c\u043e\u0434\u0435\u043b\u044c ADO.NET EDM\u00bb.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/26a\/cd8\/70e\/26acd870e8694e3a97cd9eb5a36bbcc0.png\" \/><\/div>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441\u043c. <a href=\"https:\/\/habrahabr.ru\/post\/273549\/\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0421\u0423\u0411\u0414 Firebird \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432: FireDac<\/a>), \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c EDM \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/36c\/799\/54d\/36c79954d3c1445c9591bd7e55d226d0.png\" \/><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c. \u0415\u0441\u043b\u0438 \u0422\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0442, \u0442\u043e \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/53a\/eb3\/44b\/53aeb344b7e04beea02460abb2fe62ab.png\" \/><\/div>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/def\/8d8\/105\/def8d8105a6a4045b316f6f8086dd9b5.png\" \/><\/div>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u044f\u0434 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Read Commited), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0443\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0438 \u0442.\u0434. <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/af3\/02f\/226\/af302f22646b4dadae6edc09a347d4c1.png\" \/><\/div>\n<p>  \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u043f\u0440\u043e\u0441\u044f\u0442, \u043a\u0430\u043a \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d6b\/422\/3d9\/d6b4223d94934d4ab0ffe4ca9e6924a2.png\" \/><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u0442\u0440\u043e\u0438\u0442\u0435 \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0442\u0440\u0451\u0445\u0437\u0432\u0435\u043d\u043a\u0443, \u0433\u0434\u0435 \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e, \u0442\u043e \u0441\u043c\u0435\u043b\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u00ab\u0414\u0430\u00bb. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u00ab\u041d\u0435\u0442\u00bb. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0441 \u043c\u0430\u0441\u0442\u0435\u0440\u0430\u043c\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0432\u044b\u0431\u0440\u0430\u043d \u043f\u0443\u043d\u043a\u0442 \u00ab\u0414\u0430\u00bb. \u0412\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u0433\u043e\u0442\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f .exe.conf. \u0421\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0430 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <b>connectionStrings<\/b> \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435<\/p>\n<pre><code class=\"xml\">&lt;add name=&quot;DbModel&quot; connectionString=&quot;character set=UTF8; data source=localhost;initial catalog=examples; port number=3050; user id=sysdba; dialect=3; isolationlevel=Snapshot; pooling=True; password=masterkey;&quot; providerName=&quot;FirebirdSql.Data.FirebirdClient&quot; \/&gt; <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f   <\/p>\n<pre><code class=\"xml\">password=masterkey;<\/code><\/pre>\n<table>\n<tr>\n<td><b>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Firebird 3.0<\/b> <\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 ADO .Net \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0434\u043b\u044f Firebird (\u0432\u0435\u0440\u0441\u0438\u044f 4.10.0) \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 SRP (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 Firebird 3.0). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u044b \u0436\u0435\u043b\u0430\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 Firebird 3.0, \u0442\u043e \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 firebird.conf (\u0438\u043b\u0438 \u0432 databases.conf \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0411\u0414), \u0447\u0442\u043e\u0431\u044b Firebird \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0447\u0435\u0440\u0435\u0437 Legacy_Auth. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<br \/>  <code>UserManager = Legacy_UserManager<br \/>  WireCrypt = Disabled<br \/>  AuthServer = Legacy_Auth, Srp, WinSspi<br \/>  <\/code><br \/>  \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f SYSDBA \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Legacy_UserManager.  <\/td>\n<\/tr>\n<\/table>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0443 \u0432\u0430\u0441 \u0441\u043f\u0440\u043e\u0441\u044f\u0442, \u043a\u0430\u043a\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/31c\/2b7\/769\/31c2b77697e642d6bf5882bb25a04081.png\" \/><\/div>\n<p>  \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 EDM \u043c\u043e\u0434\u0435\u043b\u044c \u0433\u043e\u0442\u043e\u0432\u0430. \u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0442\u0435\u0440\u0430 \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f 5 \u043d\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432. \u041e\u0434\u0438\u043d \u0444\u0430\u0439\u043b \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u0444\u0430\u0439\u043b\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. <\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c INVOICE.<\/p>\n<pre><code class=\"cs\">[Table(&quot;Firebird.INVOICE&quot;)] public partial class INVOICE {         [System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Microsoft.Usage&quot;, &quot;CA2214:DoNotCallOverridableMethodsInConstructors&quot;)]         public INVOICE()         {             INVOICE_LINES = new HashSet&lt;INVOICE_LINE&gt;();         }          [Key]         [DatabaseGenerated(DatabaseGeneratedOption.None)]         public int INVOICE_ID { get; set; }          public int CUSTOMER_ID { get; set; }          public DateTime? INVOICE_DATE { get; set; }          public double? TOTAL_SALE { get; set; }          public short PAYED { get; set; }          public virtual CUSTOMER CUSTOMER { get; set; }          [System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Microsoft.Usage&quot;, &quot;CA2227:CollectionPropertiesShouldBeReadOnly&quot;)]         public virtual ICollection&lt;INVOICE_LINE&gt; INVOICE_LINES { get; set; } } <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b INVOICE. \u041a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0441\u043d\u0430\u0431\u0436\u0435\u043d\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u041c\u0430\u0439\u043a\u0440\u043e\u0441\u043e\u0444\u0442 <a href=\"https:\/\/msdn.microsoft.com\/en-us\/data\/jj591583\">Code First Data Annotations<\/a>.<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u044b\u043b\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0435\u0449\u0451 \u0434\u0432\u0430 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 CUSTOMER \u0438 INVOICE_LINES. \u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430, \u0432\u0442\u043e\u0440\u043e\u0435 \u2013 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u0442\u0440\u043e\u043a \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445. \u041e\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430 INVOICE_LINE \u0438\u043c\u0435\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 INVOICE. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0438\u0437 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 INVOICE, \u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 CUSTOMER \u0438 INVOICE_LINES \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u00ab\u043b\u0435\u043d\u0438\u0432\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443\u00bb. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u0442.\u0435. \u0435\u0441\u043b\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u0442\u043e \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0411\u0414.<\/p>\n<p>  \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043b\u0435\u043d\u0438\u0432\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430\u0434\u043e \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0422\u0430\u043a, \u043a\u043b\u0430\u0441\u0441\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043b\u0435\u043d\u0438\u0432\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c\u0438, \u0430 \u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b <b>public<\/b> \u0438 <b>virtual<\/b>.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0430\u0441 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0441\u044e\u0440\u043f\u0440\u0438\u0437. \u041f\u043e\u043b\u0435 TOTAL_SALE \u0431\u044b\u043b\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u043a double, \u0445\u043e\u0442\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f NUMERIC(15, 2), \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043f\u043e\u0442\u0435\u0440\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u042f \u0441\u043a\u043b\u043e\u043d\u0435\u043d \u0440\u0430\u0441\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u0430\u043a \u0431\u0430\u0433 \u0432 Firebird ADO.NET Provider. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0434\u043e\u0441\u0430\u0434\u043d\u0443\u044e \u043e\u043f\u043b\u043e\u0448\u043d\u043e\u0441\u0442\u044c. \u0412 C# \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0438\u043f decimal \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e. <\/p>\n<pre><code class=\"cs\">public decimal TOTAL_SALE { get; set; } <\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445, \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0438\u043f Firebird NUMERIC(x, y). \u0410 \u0438\u043c\u0435\u043d\u043d\u043e PRODUCT.PRICE, INVOICE_LINE.QUANTITY, INVOICE_LINE.SALE_PRICE.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0444\u0430\u0439\u043b DbModel.cs \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0446\u0435\u043b\u043e\u043c.<\/p>\n<pre><code class=\"cs\">public partial class DbModel : DbContext {         public DbModel()             : base(&quot;name=DbModel&quot;)         {         }          public virtual DbSet&lt;CUSTOMER&gt; CUSTOMERS { get; set; }         public virtual DbSet&lt;INVOICE&gt; INVOICES { get; set; }         public virtual DbSet&lt;INVOICE_LINE&gt; INVOICE_LINES { get; set; }         public virtual DbSet&lt;PRODUCT&gt; PRODUCTS { get; set; }          protected override void OnModelCreating(DbModelBuilder modelBuilder)         {             modelBuilder.Entity&lt;CUSTOMER&gt;()                 .Property(e =&gt; e.ZIPCODE)                 .IsFixedLength();              modelBuilder.Entity&lt;CUSTOMER&gt;()                 .HasMany(e =&gt; e.INVOICES)                 .WithRequired(e =&gt; e.CUSTOMER)                 .WillCascadeOnDelete(false);              modelBuilder.Entity&lt;PRODUCT&gt;()                 .HasMany(e =&gt; e.INVOICE_LINES)                 .WithRequired(e =&gt; e.PRODUCT)                 .WillCascadeOnDelete(false);              modelBuilder.Entity&lt;INVOICE&gt;()                 .HasMany(e =&gt; e.INVOICE_LINES)                 .WithRequired(e =&gt; e.INVOICE)                 .WillCascadeOnDelete(false);          } } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0410 \u0442\u0430\u043a \u0436\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Fluent API. \u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 Fluent API \u0432\u044b \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Microsoft <a href=\"https:\/\/msdn.microsoft.com\/en-us\/data\/jj591617.aspx\">Configuring\/Mapping Properties and Types with the Fluent API<\/a>. <\/p>\n<p>  \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 OnModelCreating \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0442\u0438\u043f\u0430 decimal \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Fluent API. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438<\/p>\n<pre><code class=\"cs\">            modelBuilder.Entity&lt;PRODUCT&gt;()                 .Property(p =&gt; p.PRICE)                 .HasPrecision(15, 2);             modelBuilder.Entity&lt;INVOICE&gt;()                 .Property(p =&gt; p.TOTAL_SALE)                 .HasPrecision(15, 2);              modelBuilder.Entity&lt;INVOICE_LINE&gt;()                 .Property(p =&gt; p.SALE_PRICE)                 .HasPrecision(15, 2);              modelBuilder.Entity&lt;INVOICE_LINE&gt;()                 .Property(p =&gt; p.QUANTITY)                 .HasPrecision(15, 0); <\/code><\/pre>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430<\/h2>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430: \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0435\u0442\u043a\u0443 DataGridView, \u043f\u0430\u043d\u0435\u043b\u044c \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438 ToolStrip, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 BindingSource, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0444\u043e\u0440\u043c\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/42e\/a76\/167\/42ea7616734e4a0abac048cc95b002a8.png\" \/><\/div>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0443 \u043e\u0431\u0430 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u043f\u043e\u0445\u043e\u0436\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u0445\u043e\u0436\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d.<\/p>\n<h3>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/h3>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (\u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u0438). \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c:<\/p>\n<pre><code class=\"cs\">DbModel dbContext = new DbModel();<\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0430\u0440\u043e\u043b\u044c), \u0430 \u043c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0445 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0438\u043c\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0435\u0440\u0438\u043e\u0434.<\/p>\n<pre><code class=\"cs\">static class AppVariables {          private static DbModel dbContext = null;           \/\/\/ &lt;summary&gt;          \/\/\/ \u0414\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430          \/\/\/ &lt;\/summary&gt;          public static DateTime StartDate { get; set; }           \/\/\/ &lt;summary&gt;          \/\/\/ \u0414\u0430\u0442\u0430 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430          \/\/\/ &lt;\/summary&gt;          public static DateTime FinishDate { get; set; }          \/\/\/ &lt;summary&gt;         \/\/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043c\u043e\u0434\u0435\u043b\u0438 (\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430)         \/\/\/ &lt;\/summary&gt;         \/\/\/ &lt;returns&gt;\u041c\u043e\u0434\u0435\u043b\u044c&lt;\/returns&gt;         public static DbModel CreateDbContext() {             dbContext = dbContext ?? new DbModel();             return dbContext;                 } }  <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0448\u043b\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f Load \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"cs\">private void MainForm_Load(object sender, EventArgs e) {     var dialog = new LoginForm();     if (dialog.ShowDialog() == DialogResult.OK)     {         var dbContext = AppVariables.getDbContext();          try         {             string s = dbContext.Database.Connection.ConnectionString;             var builder = new FbConnectionStringBuilder(s);             builder.UserID = dialog.UserName;             builder.Password = dialog.Password;              dbContext.Database.Connection.ConnectionString = builder.ConnectionString;              \/\/ \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f             dbContext.Database.Connection.Open();         }         catch (Exception ex)         {             \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443             MessageBox.Show(ex.Message, &quot;Error&quot;);             Application.Exit();         }     }     else         Application.Exit(); } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 CreateDbContext.  <\/p>\n<pre><code class=\"cs\">var dbContext = AppVariables.getDbContext() <\/code><\/pre>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h3>\n<p>  \u0421\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u0430\u043c \u043c\u0435\u0442\u043e\u0434\u0430 Load, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">private void LoadCustomersData() {     dbContext.CUSTOMERS.Load();      var customers = dbContext.CUSTOMERS.Local;      bindingSource.DataSource = customers.ToBindingList();     }  private void CustomerForm_Load(object sender, EventArgs e) {     LoadCustomersData();      dataGridView.DataSource = bindingSource;     dataGridView.Columns[&quot;CUSTOMER_ID&quot;].Visible = false; } <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u043c\u0435\u0435\u0442 \u0440\u044f\u0434 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432:  <\/p>\n<ol>\n<li>\u041c\u0435\u0442\u043e\u0434 Load \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b CUSTOMER \u0432 \u043f\u0430\u043c\u044f\u0442\u044c.<\/li>\n<li>\u041b\u0435\u043d\u0438\u0432\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (INVOICES) \u0445\u043e\u0442\u044c \u0438 \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443, \u0430 \u043b\u0438\u0448\u044c \u043f\u043e \u043c\u0435\u0440\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043d\u0438\u043c, \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u043f\u0440\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0433\u0440\u0438\u0434\u0435. \u041f\u0440\u0438\u0447\u0451\u043c \u0440\u043e\u0432\u043d\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e.<\/li>\n<li>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d.<\/li>\n<\/ol>\n<p>  \u0414\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u044d\u0442\u0438\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e LINQ (Language Integrated Query), \u0438\u043b\u0438 \u0442\u043e\u0447\u043d\u0435\u0435 LINQ to Entities. <b>LINQ to Entities<\/b> \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u0444\u043e\u0440\u043c\u0435 \u0431\u043b\u0438\u0437\u043a\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c \u044f\u0437\u044b\u043a\u0430 SQL. \u0421 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c LINQ \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e <a href=\"https:\/\/msdn.microsoft.com\/ru-ru\/library\/bb386964(v=vs.110).aspx\">LINQ to Entities<\/a>.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 LINQ \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430: <b>IEnumerable<\/b> \u0438 <b>IQueryable<\/b>. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IQueryable \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 IEnumerable, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e \u0438\u0434\u0435\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 IQueryable \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 IEnumerable. \u041d\u043e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0435\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430.<\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IEnumerable \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d <b>System.Collections<\/b>. \u041e\u0431\u044a\u0435\u043a\u0442 IEnumerable \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u044d\u0442\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043f\u0435\u0440\u0451\u0434. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 IEnumerable \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0438 \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e, \u0442\u043e \u0441\u0430\u043c\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IQueryable \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0451\u043d System.Linq. \u041e\u0431\u044a\u0435\u043a\u0442 IQueryable \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u043a\u0430\u043a \u0432 \u043f\u0440\u044f\u043c\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e \u043a\u043e\u043d\u0446\u0430, \u0442\u0430\u043a \u0438 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f IQueryable, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0442\u0438.<\/p>\n<p>  \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e Local \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IEnumerable. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c LINQ \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u043d\u0435\u043c\u0443.<\/p>\n<pre><code class=\"cs\">private void LoadCustomersData() {     var dbContext = AppVariables.getDbContext();     dbContext.CUSTOMERS.Load();           var customers =          from customer in dbContext.CUSTOMERS.Local         orderby customer.NAME         select new customer;      bindingSource.DataSource = customers.ToBindingList(); } <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043a\u0430\u043a \u0443\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430\u0434 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0434\u043b\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u044d\u0442\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b LINQ \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 SQL \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 LINQ \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 dbContext.CUSTOMERS.Local \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043a dbContext.CUSTOMERS. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 dbContext.CUSTOMERS.Load(); <br \/>  \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0443\u0442 \u043d\u0430\u0441 \u043f\u043e\u0434\u0441\u0442\u0435\u0440\u0435\u0433\u0430\u0435\u0442 \u043e\u0434\u043d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0437\u0430\u0441\u0430\u0434\u0430. \u041e\u0431\u044a\u0435\u043a\u0442\u044b IQueryable \u043d\u0435 \u0443\u043c\u0435\u044e\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c BindingList. BindingList \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0432\u0443\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 IQueryable \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0430 ToList, \u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043b\u0438\u0448\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0431\u043e\u043d\u0443\u0441\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432 \u0433\u0440\u0438\u0434\u0435 \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445. \u041a\u0441\u0442\u0430\u0442\u0438 \u0432 .NET Framework 5 \u044d\u0442\u043e \u0443\u0436\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0432\u043e\u0451 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435.<\/p>\n<pre><code class=\"cs\">public static class DbExtensions {     \/\/ \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043d\u0430 \u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430     private class IdResult     {         public int Id { get; set; }     }      \/\/ \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 IQueryable \u0432 BindingList     public static BindingList&lt;T&gt; ToBindingList&lt;T&gt;         (this IQueryable&lt;T&gt; source) where T : class     {         return (new ObservableCollection&lt;T&gt;(source)).ToBindingList();     }      \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438     public static int NextValueFor(this DbModel dbContext, string genName)     {         string sql = String.Format(             &quot;SELECT NEXT VALUE FOR {0} AS Id FROM RDB$DATABASE&quot;, genName);         return dbContext.Database.SqlQuery&lt;IdResult&gt;(sql).First().Id;     }      \/\/ \u041e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 DbSet \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430     \/\/ \u041f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043a\u0435\u0448\u0430     public static void DetachAll&lt;T&gt;(this DbModel dbContext, DbSet&lt;T&gt; dbSet)          where T : class      {                  foreach (var obj in dbSet.Local.ToList())         {             dbContext.Entry(obj).State = EntityState.Detached;         }     }      \/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438     public static void Refresh(this DbModel dbContext, RefreshMode mode,         IEnumerable collection)     {         var objectContext = ((IObjectContextAdapter)dbContext).ObjectContext;         objectContext.Refresh(mode, collection);     }      \/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430     public static void Refresh(this DbModel dbContext, RefreshMode mode,           object entity)     {         var objectContext = ((IObjectContextAdapter)dbContext).ObjectContext;         objectContext.Refresh(mode, entity);     } } <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439. <\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 NextValueFor \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u041c\u0435\u0442\u043e\u0434 dbContext.Database.SqlQuery \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c (\u043f\u0440\u043e\u0435\u043a\u0446\u0438\u044e). \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. <\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 DetachAll \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 DBSet \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043a\u0435\u0448\u0430. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u0441\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c\u044b\u0435 \u043a\u0435\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043d\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043d\u043e\u0432\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0445 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. <\/p>\n<table>\n<tr>\n<td><b>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b> <\/p>\n<p>  \u0412 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043e\u0431\u044b\u0447\u043d\u043e \u0436\u0438\u0432\u0451\u0442 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0430 \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u0435\u0448.  <\/td>\n<\/tr>\n<\/table>\n<p>  \u041c\u0435\u0442\u043e\u0434 Refresh \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041e\u043d \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f. <\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u0448 \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a<\/p>\n<pre><code class=\"cs\">        private void LoadCustomersData()         {             var dbContext = AppVariables.getDbContext();             \/\/ \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0432\u0441\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b             \/\/ \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043a\u0435\u0448             \/\/ \u043f\u0440\u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430             dbContext.DetachAll(dbContext.CUSTOMERS);              var customers =                 from customer in dbContext.CUSTOMERS                 orderby customer.NAME                 select customer;               bindingSource.DataSource = customers.ToBindingList();         }          private void CustomerForm_Load(object sender, EventArgs e)         {             LoadCustomersData();              dataGridView.DataSource = bindingSource;             dataGridView.Columns[&quot;INVOICES&quot;].Visible = false;             dataGridView.Columns[&quot;CUSTOMER_ID&quot;].Visible = false;             dataGridView.Columns[&quot;NAME&quot;].HeaderText = &quot;Name&quot;;             dataGridView.Columns[&quot;ADDRESS&quot;].HeaderText = &quot;Address&quot;;             dataGridView.Columns[&quot;ZIPCODE&quot;].HeaderText = &quot;ZipCode&quot;;             dataGridView.Columns[&quot;PHONE&quot;].HeaderText = &quot;Phone&quot;;         } <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"cs\">private void btnAdd_Click(object sender, EventArgs e) {     var dbContext = AppVariables.getDbContext();     \/\/ \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438             var customer = (CUSTOMER)bindingSource.AddNew();     \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     using (CustomerEditorForm editor = new CustomerEditorForm()) {         editor.Text = &quot;\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430&quot;;         editor.Customer = customer;         \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0440\u043c\u044b         editor.FormClosing += delegate (object fSender, FormClosingEventArgs fe) {            if (editor.DialogResult == DialogResult.OK) {               try {                  \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430                  \/\/ \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443                  customer.CUSTOMER_ID = dbContext.NextValueFor(&quot;GEN_CUSTOMER_ID&quot;);                  \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430                  dbContext.CUSTOMERS.Add(customer);                  \/\/ \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f                  dbContext.SaveChanges();                  \/\/ \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c                  dbContext.Refresh(RefreshMode.StoreWins, customer);               }               catch (Exception ex) {                  \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443                  MessageBox.Show(ex.Message, &quot;Error&quot;);                  \/\/ \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438                  fe.Cancel = true;               }            }            else                bindingSource.CancelEdit();          };         \/\/ \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443         editor.ShowDialog(this);     } }            <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430, \u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0431\u044b BEFORE INSERT \u0442\u0440\u0438\u0433\u0433\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0434\u0451\u0440\u043d\u0443\u043b \u0431\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u043d\u043e\u0432\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c. <\/p>\n<p>  \u041a\u043e\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"cs\">private void btnEdit_Click(object sender, EventArgs e) {     var dbContext = AppVariables.getDbContext();     \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c     var customer = (CUSTOMER)bindingSource.Current;     \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f     using (CustomerEditorForm editor = new CustomerEditorForm()) {         editor.Text = &quot;\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430&quot;;         editor.Customer = customer;         \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0440\u043c\u044b         editor.FormClosing += delegate (object fSender, FormClosingEventArgs fe) {             if (editor.DialogResult == DialogResult.OK) {                 try {                     \/\/ \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f                     dbContext.SaveChanges();                     dbContext.Refresh(RefreshMode.StoreWins, customer);                     \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044b                     bindingSource.ResetCurrentItem();                 }                 catch (Exception ex) {                     \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443                     MessageBox.Show(ex.Message, &quot;Error&quot;);                     \/\/ \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438                     fe.Cancel = true;                 }             }             else                 bindingSource.CancelEdit();          };         \/\/ \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443         editor.ShowDialog(this);     } } <\/code><\/pre>\n<p>  \u0424\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/0bc\/c05\/ff9\/0bcc05ff953a482da9e48392bb1ebb12.png\" \/><\/div>\n<p>  \u041a\u043e\u0434 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442.<\/p>\n<pre><code class=\"cs\">public CUSTOMER Customer { get; set; }  private void CustomerEditorForm_Load(object sender, EventArgs e) {     edtName.DataBindings.Add(&quot;Text&quot;, this.Customer, &quot;NAME&quot;);     edtAddress.DataBindings.Add(&quot;Text&quot;, this.Customer, &quot;ADDRESS&quot;);     edtZipCode.DataBindings.Add(&quot;Text&quot;, this.Customer, &quot;ZIPCODE&quot;);     edtPhone.DataBindings.Add(&quot;Text&quot;, this.Customer, &quot;PHONE&quot;); } <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"cs\">private void btnDelete_Click(object sender, EventArgs e) {     var dbContext = AppVariables.getDbContext();     var result = MessageBox.Show(&quot;\u0412\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430?&quot;,                 &quot;\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435&quot;,                 MessageBoxButtons.YesNo,                 MessageBoxIcon.Question);     if (result == DialogResult.Yes) {        \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c         var customer = (CUSTOMER)bindingSource.Current;        try {            dbContext.CUSTOMERS.Remove(customer);            \/\/ \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f            dbContext.SaveChanges();            \/\/ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430            bindingSource.RemoveCurrent();        }        catch (Exception ex) {            \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443            MessageBox.Show(ex.Message, &quot;Error&quot;);        }     } } <\/code><\/pre>\n<h3>\u0416\u0443\u0440\u043d\u0430\u043b\u044b<\/h3>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d \u0436\u0443\u0440\u043d\u0430\u043b \u00ab\u0421\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b\u00bb. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c\u0438. <\/p>\n<p>  \u0421\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0430 \u2013 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430, \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0431\u0449\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b (\u043d\u043e\u043c\u0435\u0440, \u0434\u0430\u0442\u0430, \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a \u2026), \u0438 \u0441\u0442\u0440\u043e\u043a \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0442\u043e\u0432\u0430\u0440\u043e\u043c, \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c, \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0438 \u0442.\u0434. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u0432\u0430 \u0433\u0440\u0438\u0434\u0430: \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0448\u0430\u043f\u043a\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0430 \u0432 \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0435\u043c \u2014 \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u0432\u0430\u0440\u043e\u0432. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430 \u0444\u043e\u0440\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0434\u0432\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 DataGridView, \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u0441\u0432\u043e\u0439 BindingSource<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1e7\/feb\/83e\/1e7feb83e76a4e9187daa3e8b2447828.png\" \/><\/div>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0436\u0443\u0440\u043d\u0430\u043b\u043e\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043f\u043e\u043b\u0435 \u0441 \u0434\u0430\u0442\u043e\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0431\u044a\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0420\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u2013 \u044d\u0442\u043e \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0434\u0430\u0442, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0436\u0443\u0440\u043d\u0430\u043b\u0430, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0434\u0430\u0442\u0443 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430, \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 AppVariables (\u0441\u043c. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430), \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u0441 \u0411\u0414. \u041f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u0430\u0442\u043e\u0439 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u0430 (\u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b). \u0412 \u0445\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e \u0434\u0430\u0442\u0435 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 LINQ. \u0421 \u0443\u0447\u0451\u0442\u043e\u043c \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e, \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0448\u0430\u043f\u043e\u043a \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440 \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 void LoadInvoicesData() {     var dbContext = AppVariables.getDbContext();      \/\/ \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 LINQ \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 SQL     var invoices =         from invoice in dbContext.INVOICES         where (invoice.INVOICE_DATE &gt;= AppVariables.StartDate) &&               (invoice.INVOICE_DATE &lt;= AppVariables.FinishDate)         orderby invoice.INVOICE_DATE descending         select new InvoiceView         {             Id = invoice.INVOICE_ID,             Cusomer_Id = invoice.CUSTOMER_ID,             Customer = invoice.CUSTOMER.NAME,             Date = invoice.INVOICE_DATE,             Amount = invoice.TOTAL_SALE,             Payed = (invoice.PAYED == 1) ? &quot;Yes&quot; : &quot;No&quot;         };      masterBinding.DataSource = invoices.ToBindingList(); } <\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0435 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u0442\u0438\u043f, \u0430 \u043a\u043b\u0430\u0441\u0441 InvoiceView. \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 InvoiceView \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"cs\">public class InvoiceView {     public int Id { get; set; }     public int Cusomer_Id { get; set; }     public string Customer { get; set; }     public DateTime? Date { get; set; }     public decimal? Amount { get; set; }     public string Payed { get; set; }      public void Load(int Id) {         var dbContext = AppVariables.getDbContext();          var invoices =             from invoice in dbContext.INVOICES             where invoice.INVOICE_ID == Id             select new InvoiceView             {                 Id = invoice.INVOICE_ID,                 Cusomer_Id = invoice.CUSTOMER_ID,                 Customer = invoice.CUSTOMER.NAME,                 Date = invoice.INVOICE_DATE,                 Amount = invoice.TOTAL_SALE,                 Payed = (invoice.PAYED == 1) ? &quot;Yes&quot; : &quot;No&quot;             };          InvoiceView invoiceView = invoices.ToList().First();         this.Id = invoiceView.Id;         this.Cusomer_Id = invoiceView.Cusomer_Id;         this.Customer = invoiceView.Customer;         this.Date = invoiceView.Date;         this.Amount = invoiceView.Amount;         this.Payed = invoiceView.Payed;     } } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 Load \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c 1 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0433\u0440\u0438\u0434\u0435, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>  \u041a\u043e\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.  <\/p>\n<pre><code class=\"cs\">private void btnAddInvoice_Click(object sender, EventArgs e) {     var dbContext = AppVariables.getDbContext();     var invoice = dbContext.INVOICES.Create();      using (InvoiceEditorForm editor = new InvoiceEditorForm()) {         editor.Text = &quot;\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0447\u0451\u0442 \u0444\u0430\u043a\u0442\u0443\u0440\u044b&quot;;         editor.Invoice = invoice;         \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0440\u043c\u044b         editor.FormClosing += delegate (object fSender, FormClosingEventArgs fe) {             if (editor.DialogResult == DialogResult.OK) {                 try {                     \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430                     invoice.INVOICE_ID = dbContext.NextValueFor(&quot;GEN_INVOICE_ID&quot;);                     \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c                     dbContext.INVOICES.Add(invoice);                     \/\/ \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f                     dbContext.SaveChanges();                     \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u044e \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u0433\u0440\u0438\u0434\u0430                     ((InvoiceView)masterBinding.AddNew()).Load(invoice.INVOICE_ID);                 }                 catch (Exception ex) {                     \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443                     MessageBox.Show(ex.Message, &quot;Error&quot;);                     \/\/ \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438                     fe.Cancel = true;                 }             }         };         \/\/ \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443         editor.ShowDialog(this);     } } <\/code><\/pre>\n<p>  \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 dbContext.Refresh, \u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 Load \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438 InvoiceView. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e dbContext.Refresh \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 LINQ \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. <\/p>\n<p>  \u041a\u043e\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.  <\/p>\n<pre><code class=\"cs\">private void btnEditInvoice_Click(object sender, EventArgs e) {     \/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430     var dbContext = AppVariables.getDbContext();     \/\/ \u043f\u043e\u0438\u0441\u043a \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443     var invoice = dbContext.INVOICES.Find(this.CurrentInvoice.Id);      if (invoice.PAYED == 1) {         MessageBox.Show(&quot;\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0447\u0451\u0442 \u0444\u0430\u043a\u0442\u0443\u0440\u0430 \u0443\u0436\u0435 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430.&quot;, &quot;\u041e\u0448\u0438\u0431\u043a\u0430&quot;);         return;     }      using (InvoiceEditorForm editor = new InvoiceEditorForm()) {         editor.Text = &quot;Edit invoice&quot;;         editor.Invoice = invoice;         \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0440\u043c\u044b         editor.FormClosing += delegate (object fSender, FormClosingEventArgs fe) {             if (editor.DialogResult == DialogResult.OK) {                 try {                     \/\/ \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f                     dbContext.SaveChanges();                     \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u044e                     CurrentInvoice.Load(invoice.INVOICE_ID);                     masterBinding.ResetCurrentItem();                 }                 catch (Exception ex) {                     \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443                     MessageBox.Show(ex.Message, &quot;Error&quot;);                     \/\/ \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438                     fe.Cancel = true;                 }             }         };         \/\/ \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443         editor.ShowDialog(this);     } } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0435\u0451 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e CurrentInvoice \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u0433\u0440\u0438\u0434\u0435 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b. \u041e\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cs\">public InvoiceView CurrentInvoice {     get {         return (InvoiceView)masterBinding.Current;     } } <\/code><\/pre>\n<p>  \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0448\u0430\u043f\u043a\u0438 \u0441\u0447\u0451\u0442 \u0444\u0430\u043a\u0442\u0443\u0440\u044b \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u043c\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440 \u043c\u044b \u0432\u0432\u0435\u043b\u0438 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u043f\u043b\u0430\u0442\u044b, \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u044d\u0442\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"cs\">private void btnInvoicePay_Click(object sender, EventArgs e) {     var dbContext = AppVariables.getDbContext();     var invoice = dbContext.INVOICES.Find(this.CurrentInvoice.Id);     try {         if (invoice.PAYED == 1)            throw new Exception(&quot;\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0447\u0451\u0442 \u0444\u0430\u043a\u0442\u0443\u0440\u0430 \u0443\u0436\u0435 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430.&quot;);          invoice.PAYED = 1;         \/\/ \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f         dbContext.SaveChanges();         \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c         CurrentInvoice.Load(invoice.INVOICE_ID);         masterBinding.ResetCurrentItem();     }     catch (Exception ex) {         \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443         MessageBox.Show(ex.Message, &quot;\u041e\u0448\u0438\u0431\u043a\u0430&quot;);     } } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430:  <\/p>\n<ol>\n<li>\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0435 \u0438\u0437 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 INVOICE_LINE \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438 LINQ) \u0432 \u0434\u0435\u0442\u0435\u0439\u043b \u0433\u0440\u0438\u0434\u0435.<\/li>\n<li>\u041f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c LINQ \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0432 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0432 \u043c\u0430\u0441\u0442\u0435\u0440 \u0433\u0440\u0438\u0434\u0435.<\/li>\n<\/ol>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. <\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0444\u043e\u0440\u043c\u044b \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0440\u0430\u0437\u0443 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u0441\u0435 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b \u0437\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0438\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u043c. \u042d\u0442\u043e \u0445\u043e\u0442\u044c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0451\u043c\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f WEB \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0433\u0434\u0435 \u0432\u044b\u0432\u043e\u0434 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e.<\/p>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u0435\u043d \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b \u0438 \u043c\u0435\u043d\u0435\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043d \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0432 \u043c\u0430\u0441\u0442\u0435\u0440 \u0433\u0440\u0438\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0442\u0440\u0430\u0444\u0438\u043a (\u0445\u043e\u0442\u044f \u043e\u0431\u044a\u0451\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0432\u0435\u043b\u0438\u043a).<\/p>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 BindingSource.  <\/p>\n<pre><code class=\"cs\">private void masterBinding_CurrentChanged(object sender, EventArgs e) {    LoadInvoiceLineData(this.CurrentInvoice.Id);    detailGridView.DataSource = detailBinding; } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u0445 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"cs\">private void LoadInvoiceLineData(int? id) {     var dbContext = AppVariables.getDbContext();      var lines =         from line in dbContext.INVOICE_LINES         where line.INVOICE_ID == id         select new InvoiceLineView         {             Id = line.INVOICE_LINE_ID,             Invoice_Id = line.INVOICE_ID,             Product_Id = line.PRODUCT_ID,             Product = line.PRODUCT.NAME,             Quantity = line.QUANTITY,             Price = line.SALE_PRICE,             Total = Math.Round(line.QUANTITY * line.SALE_PRICE, 2)         };      detailBinding.DataSource = lines.ToBindingList(); } <\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 InvoiceLineView.   <\/p>\n<pre><code class=\"cs\">public class InvoiceLineView {    public int Id { get; set; }    public int Invoice_Id { get; set; }    public int Product_Id { get; set; }    public string Product { get; set; }    public decimal Quantity { get; set; }    public decimal Price { get; set; }    public decimal Total { get; set; } } <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 InvoiceView \u0437\u0434\u0435\u0441\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u0434\u043d\u043e\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u0417\u0434\u0435\u0441\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0435\u0442\u0435\u0439\u043b \u0433\u0440\u0438\u0434\u0430 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0434\u0438\u043d \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u044b\u0441\u044f\u0447\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u0434\u0435\u0442\u0435\u0439\u043b \u0433\u0440\u0438\u0434\u0435.  <\/p>\n<pre><code class=\"cs\">public InvoiceLineView CurrentInvoiceLine {     get {         return (InvoiceLineView)detailBinding.Current;     } } <\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c\u0438 \u0432 Entity Framework. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cs\">private void btnAddInvoiceLine_Click(object sender, EventArgs e) {     var dbContext = AppVariables.getDbContext();     \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0443     var invoice = dbContext.INVOICES.Find(this.CurrentInvoice.Id);     \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0435 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430 \u043b\u0438 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0430     if (invoice.PAYED == 1) {         MessageBox.Show(&quot;\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0430 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430.&quot;, &quot;Error&quot;);         return;     }     \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b     var invoiceLine = dbContext.INVOICE_LINES.Create();     invoiceLine.INVOICE_ID = invoice.INVOICE_ID;     \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u0447\u0451\u0442 \u0444\u0430\u043a\u0442\u0443\u0440\u044b     using (InvoiceLineEditorForm editor = new InvoiceLineEditorForm()) {         editor.Text = &quot;Add invoice line&quot;;         editor.InvoiceLine = invoiceLine;         \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0440\u043c\u044b         editor.FormClosing += delegate (object fSender, FormClosingEventArgs fe) {             if (editor.DialogResult == DialogResult.OK) {                 try {                    \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0425\u041f                    var invoiceIdParam = new FbParameter(&quot;INVOICE_ID&quot;, FbDbType.Integer);                    var productIdParam = new FbParameter(&quot;PRODUCT_ID&quot;, FbDbType.Integer);                    var quantityParam = new FbParameter(&quot;QUANTITY&quot;, FbDbType.Integer);                    \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438                    invoiceIdParam.Value = invoiceLine.INVOICE_ID;                    productIdParam.Value = invoiceLine.PRODUCT_ID;                    quantityParam.Value = invoiceLine.QUANTITY;                    \/\/ \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043c\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443                    dbContext.Database.ExecuteSqlCommand(                      &quot;EXECUTE PROCEDURE SP_ADD_INVOICE_LINE(@INVOICE_ID, @PRODUCT_ID, @QUANTITY)&quot;,                       invoiceIdParam,                       productIdParam,                       quantityParam);                    \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0433\u0440\u0438\u0434\u044b                    \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b                    CurrentInvoice.Load(invoice.INVOICE_ID);                    \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u0435\u0442\u0435\u0439\u043b \u0433\u0440\u0438\u0434\u0430                    LoadInvoiceLineData(invoice.INVOICE_ID);                    \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435                    masterBinding.ResetCurrentItem();                 }                 catch (Exception ex) {                    \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443                    MessageBox.Show(ex.Message, &quot;Error&quot;);                    \/\/ \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438                    fe.Cancel = true;                 }             }         };         \/\/ \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443         editor.ShowDialog(this);     } } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u0430\u0441\u0442\u0435\u0440 \u0433\u0440\u0438\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0439 (TotalSale) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u0430\u043a.  <\/p>\n<pre><code class=\"cs\">private void btnEditInvoiceLine_Click(object sender, EventArgs e) {     var dbContext = AppVariables.getDbContext();     \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0443     var invoice = dbContext.INVOICES.Find(this.CurrentInvoice.Id);     \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0435 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430 \u043b\u0438 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0430     if (invoice.PAYED == 1) {         MessageBox.Show(&quot;\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0447\u0451\u0442 \u0444\u0430\u043a\u0442\u0443\u0440\u0430 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430.&quot;, &quot;Error&quot;);         return;     }     \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b     var invoiceLine = invoice.INVOICE_LINES         .Where(p =&gt; p.INVOICE_LINE_ID == this.CurrentInvoiceLine.Id)         .First();     \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u0447\u0451\u0442 \u0444\u0430\u043a\u0442\u0443\u0440\u044b     using (InvoiceLineEditorForm editor = new InvoiceLineEditorForm()) {         editor.Text = &quot;Edit invoice line&quot;;         editor.InvoiceLine = invoiceLine;          \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0440\u043c\u044b         editor.FormClosing += delegate (object fSender, FormClosingEventArgs fe) {            if (editor.DialogResult == DialogResult.OK) {                try {                    \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0425\u041f                    var idParam = new FbParameter(&quot;INVOICE_LINE_ID&quot;, FbDbType.Integer);                    var quantityParam = new FbParameter(&quot;QUANTITY&quot;, FbDbType.Integer);                    \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438                    idParam.Value = invoiceLine.INVOICE_LINE_ID;                    quantityParam.Value = invoiceLine.QUANTITY;                    \/\/ \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043c\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443                    dbContext.Database.ExecuteSqlCommand(                       &quot;EXECUTE PROCEDURE SP_EDIT_INVOICE_LINE(@INVOICE_LINE_ID, @QUANTITY)&quot;,                        idParam,                        quantityParam);                    \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0433\u0440\u0438\u0434\u044b                    \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b                    CurrentInvoice.Load(invoice.INVOICE_ID);                    \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u0435\u0442\u0435\u0439\u043b \u0433\u0440\u0438\u0434\u0430                    LoadInvoiceLineData(invoice.INVOICE_ID);                    \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044b                    masterBinding.ResetCurrentItem();                }                catch (Exception ex) {                    \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443                    MessageBox.Show(ex.Message, &quot;Error&quot;);                    \/\/ \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438                    fe.Cancel = true;                }            }        };         \/\/ \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443        editor.ShowDialog(this);     } } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u0430\u043a.  <\/p>\n<pre><code class=\"cs\">private void btnDeleteInvoiceLine_Click(object sender, EventArgs e) {     var result = MessageBox.Show(&quot;\u0412\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b?&quot;,                 &quot;\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435&quot;,                 MessageBoxButtons.YesNo,                 MessageBoxIcon.Question);     if (result == DialogResult.Yes) {        var dbContext = AppVariables.getDbContext();        \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0443        var invoice = dbContext.INVOICES.Find(this.CurrentInvoice.Id);        try {            \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0435 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430 \u043b\u0438 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0430            if (invoice.PAYED == 1)               throw new Exception(&quot;\u041d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c, \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u0430 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430.&quot;);            \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0425\u041f            var idParam = new FbParameter(&quot;INVOICE_LINE_ID&quot;, FbDbType.Integer);            \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438            idParam.Value = this.CurrentInvoiceLine.Id;            \/\/ \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043c\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443            dbContext.Database.ExecuteSqlCommand(               &quot;EXECUTE PROCEDURE SP_DELETE_INVOICE_LINE(@INVOICE_LINE_ID)&quot;,                idParam);             \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0433\u0440\u0438\u0434\u044b            \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b            CurrentInvoice.Load(invoice.INVOICE_ID);            \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u0435\u0442\u0435\u0439\u043b \u0433\u0440\u0438\u0434\u0430            LoadInvoiceLineData(invoice.INVOICE_ID);            \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044b            masterBinding.ResetCurrentItem();        }        catch (Exception ex) {            \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443            MessageBox.Show(ex.Message, &quot;Error&quot;);        }     } } <\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0441\u0447\u0451\u0442-\u0444\u0430\u043a\u0442\u0443\u0440\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/48f\/b48\/d4f\/48fb48d4fc01422e962789f8569c9c3c.png\" \/><\/div>\n<p>  \u0414\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u0432\u0430\u0440\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TextBox. \u041f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u0441 \u0433\u0440\u0438\u0434\u043e\u043c \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0442\u043e\u0432\u0430\u0440\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u043a\u043d\u0430 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u0443 \u0436\u0435 \u0444\u043e\u0440\u043c\u0443, \u0447\u0442\u043e \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0434\u043b\u044f \u0438\u0445 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041a\u043e\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u043e\u0440\u043c\u044b \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 partial class InvoiceLineEditorForm : Form {     public InvoiceLineEditorForm() {         InitializeComponent();     }       public INVOICE_LINE InvoiceLine { get; set; }      private void InvoiceLineEditorForm_Load(object sender, EventArgs e) {         if (this.InvoiceLine.PRODUCT != null) {            edtProduct.Text = this.InvoiceLine.PRODUCT.NAME;            edtPrice.Text = this.InvoiceLine.PRODUCT.PRICE.ToString(&quot;F2&quot;);            btnChooseProduct.Click -= this.btnChooseProduct_Click;         }         if (this.InvoiceLine.QUANTITY == 0)            this.InvoiceLine.QUANTITY = 1;         edtQuantity.DataBindings.Add(&quot;Value&quot;, this.InvoiceLine, &quot;QUANTITY&quot;);     }      private void btnChooseProduct_Click(object sender, EventArgs e) {        GoodsForm goodsForm = new GoodsForm();        if (goodsForm.ShowDialog() == DialogResult.OK) {           InvoiceLine.PRODUCT_ID = goodsForm.CurrentProduct.Id;           edtProduct.Text = goodsForm.CurrentProduct.Name;           edtPrice.Text = goodsForm.CurrentProduct.Price.ToString(&quot;F2&quot;);        }    } } <\/code><\/pre>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434 SaveChanges(), \u0442\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 Entity Framework \u043d\u0435\u044f\u0432\u043d\u043e \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u043e \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e EF \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043a\u0438\u0434\u043a\u0443 \u043d\u0430 \u0442\u043e\u0432\u0430\u0440\u044b, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0433\u0440\u0438\u0434\u0435. \u041a\u043e\u0434 \u0431\u0435\u0437 \u044f\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \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\">var dbContext = AppVariables.getDbContext(); foreach (DataGridViewRow gridRows in dataGridView.SelectedRows) {     int id = (int)gridRows.Cells[&quot;Id&quot;].Value;     \/\/ \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u044f\u0432\u043d\u044b\u0439 \u0441\u0442\u0430\u0440\u0442 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438     var product = dbContext.PRODUCTS.Find(id);     \/\/ \u0441\u043a\u0438\u0434\u043a\u0430 10%     decimal discount = 10.0m;     product.PRICE = product.PRICE * (100 - discount) \/100; } \/\/ \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u044f\u0432\u043d\u044b\u0439 \u0441\u0442\u0430\u0440\u0442 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \/\/ \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e dbContext.SaveChanges(); <\/code><\/pre>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 10 \u0442\u043e\u0432\u0430\u0440\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u044f\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e 10 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0442\u043e\u0432\u0430\u0440\u0430 \u043f\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u0438 \u043e\u0434\u0438\u043d\u043d\u0430\u0434\u0446\u0430\u0442\u0430\u044f \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cs\">var dbContext = AppVariables.getDbContext(); \/\/ \u044f\u0432\u043d\u044b\u0439 \u0441\u0442\u0430\u0440\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e using (var dbTransaction = dbContext.Database.BeginTransaction()) {     string sql =          &quot;UPDATE PRODUCT &quot; +          &quot;SET PRICE =  PRICE * ROUND((100 - @DISCOUNT)\/100, 2) &quot; +          &quot;WHERE PRODUCT_ID = @PRODUCT_ID&quot;;     try {         \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430         var idParam = new FbParameter(&quot;PRODUCT_ID&quot;, FbDbType.Integer);         var discountParam = new FbParameter(&quot;DISCOUNT&quot;, FbDbType.Decimal);         \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c SQL \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439         var sqlCommand = dbContext.Database.Connection.CreateCommand();         sqlCommand.CommandText = sql;         \/\/ \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u043a\u0430\u043a\u0443\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c         sqlCommand.Transaction = dbTransaction.UnderlyingTransaction;         sqlCommand.Parameters.Add(discountParam);         sqlCommand.Parameters.Add(idParam);         \/\/ \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443         sqlCommand.Prepare();         \/\/ \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0433\u0440\u0438\u0434\u0435         foreach (DataGridViewRow gridRows in dataGridView.SelectedRows) {             int id = (int)gridRows.Cells[&quot;Id&quot;].Value;             \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430             idParam.Value = id;             discountParam.Value = 10.0m; \/\/ \u0441\u043a\u0438\u0434\u043a\u0430 10%             \/\/ \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c sql \u0437\u0430\u043f\u0440\u043e\u0441             sqlCommand.ExecuteNonQuery();         }         dbTransaction.Commit();     }     catch (Exception ex) {         dbTransaction.Rollback();         MessageBox.Show(ex.Message, &quot;error&quot;);                      } } <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 UseTransaction.  <\/p>\n<pre><code class=\"cs\">private void btnDiscount_Click(object sender, EventArgs e) {              DiscountEditorForm editor = new DiscountEditorForm();      editor.Text = &quot;Enter discount&quot;;     if (editor.ShowDialog() != DialogResult.OK)         return;       bool needUpdate = false;      var dbContext = AppVariables.getDbContext();     var connection = dbContext.Database.Connection;     \/\/ \u044f\u0432\u043d\u044b\u0439 \u0441\u0442\u0430\u0440\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e     using (var dbTransaction = connection.BeginTransaction(IsolationLevel.Snapshot)) {         dbContext.Database.UseTransaction(dbTransaction);         string sql =             &quot;UPDATE PRODUCT &quot; +             &quot;SET PRICE =  ROUND(PRICE * (100 - @DISCOUNT)\/100, 2) &quot; +             &quot;WHERE PRODUCT_ID = @PRODUCT_ID&quot;;         try {             \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430             var idParam = new FbParameter(&quot;PRODUCT_ID&quot;, FbDbType.Integer);             var discountParam = new FbParameter(&quot;DISCOUNT&quot;, FbDbType.Decimal);             \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c SQL \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439             var sqlCommand = connection.CreateCommand();             sqlCommand.CommandText = sql;             \/\/ \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043a\u0430\u043a\u0443\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c             sqlCommand.Transaction = dbTransaction;             sqlCommand.Parameters.Add(discountParam);             sqlCommand.Parameters.Add(idParam);             \/\/ \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443             sqlCommand.Prepare();             \/\/ \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0433\u0440\u0438\u0434\u0435             foreach (DataGridViewRow gridRows in dataGridView.SelectedRows) {                 int id = (int)gridRows.Cells[&quot;PRODUCT_ID&quot;].Value;                 \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430                 idParam.Value = id;                 discountParam.Value = editor.Discount;                 \/\/ \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c sql \u0437\u0430\u043f\u0440\u043e\u0441                                             needUpdate = (sqlCommand.ExecuteNonQuery() &gt; 0) || needUpdate;             }             dbTransaction.Commit();         }         catch (Exception ex) {             dbTransaction.Rollback();             MessageBox.Show(ex.Message, &quot;error&quot;);             needUpdate = false;         }     }     \/\/ \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0433\u0440\u0438\u0434\u0430&lt;a href=&quot;http:\/\/ib-aid.com\/download\/docs\/NET_DB.zip&quot;&gt;&lt;\/a&gt;     if (needUpdate) {        \/\/ \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0433\u0440\u0438\u0434\u0435        foreach (DataGridViewRow gridRows in dataGridView.SelectedRows) {             var product = (PRODUCT)bindingSource.List[gridRows.Index];             dbContext.Refresh(RefreshMode.StoreWins, product);        }        bindingSource.ResetBindings(false);     } } <\/code><\/pre>\n<p>  \u041d\u0443 \u0432\u043e\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f, \u0438 \u043d\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0438\u0430\u043b\u043e\u0433 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043a\u0438\u0434\u043a\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0433\u0440\u0438\u0434\u0435. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0432\u0430\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 C# \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Entity Framework \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0421\u0423\u0411\u0414 Firebird.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e27\/38a\/7ef\/e2738a7eff774dda8347426091bfa510.png\" \/><\/div>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  <a href=\"http:\/\/ib-aid.com\/download\/docs\/NET_source.zip\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <\/a><br \/>  <a href=\"http:\/\/ib-aid.com\/download\/docs\/NET_DB.zip\">\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0435\u0451 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f<\/a>               <\/p>\n<div class=\"clear\"><\/div>\n<p> \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:\/\/habrahabr.ru\/post\/278405\/\"> https:\/\/habrahabr.ru\/post\/278405\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0421\u0423\u0411\u0414 Firebird \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 Entity Framework \u0438 \u0441\u0440\u0435\u0434\u044b Visual Studio 2015. <\/p>\n<p>  <b>ADO.NET Entity Framework (EF)<\/b> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f object-relational mapping (ORM) \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f .NET Framework \u043e\u0442 Microsoft. \u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043a\u0430\u043a \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c LINQ \u0432 \u0432\u0438\u0434\u0435 LINQ to Entities, \u0442\u0430\u043a \u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Entity SQL.<\/p>\n<p>  Entity Framework \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0442\u0440\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445:  <\/p>\n<ul>\n<li><b>Database first<\/b>: Entity Framework \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u0430\u0431\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<li><b>Model first<\/b>: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0442\u0435\u043c Entity Framework \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/li>\n<li><b>Code first<\/b>: \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0411\u0414, \u0430 \u0437\u0430\u0442\u0435\u043c Entity Framework \u043f\u043e \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0435\u0451 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/li>\n<\/ul>\n<p>  \u0412 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434 Code First, \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u044b \u0431\u0435\u0437 \u0442\u0440\u0443\u0434\u0430 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b.<\/p>\n<p>  \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/86f\/af9\/3c6\/86faf93c610848eca16be6e95739fa54.png\" alt=\"diagramm\" \/><\/div>\n<table>\n<tr>\n<td><b>\u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/b> <\/p>\n<p>  \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c. \u0412\u0430\u0448\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0440\u0443\u0433\u043e\u0439. \u041c\u043e\u0434\u0435\u043b\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0433\u0440\u043e\u043c\u043e\u0436\u0434\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.  <\/td>\n<\/tr>\n<\/table>\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-275564","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275564","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=275564"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275564\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=275564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=275564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=275564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}