{"id":333958,"date":"2022-06-02T09:00:47","date_gmt":"2022-06-02T09:00:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=333958"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=333958","title":{"rendered":"<span>.NET 6 \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0445\u043e\u0434\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b<a href=\"https:\/\/github.com\/vliashko\/CommunicationWithDB\" rel=\"noopener noreferrer nofollow\"> \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>. \u0412\u043f\u043e\u043b\u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f, \u0438\u043b\u0438, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0445\u043e\u0442\u044f\u0442 \u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438.<\/p>\n<p><strong>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0431\u0443\u0434\u044c \u0442\u043e \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u044b \u0438\u043b\u0438 \u0432\u0435\u0431, \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437?<\/strong> <\/p>\n<p>\u041d\u0443, \u0447\u0438\u0441\u0442\u043e \u0432 \u0442\u0435\u043e\u0440\u0438\u0438 \u043c\u043e\u0436\u043d\u043e, \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0441\u0442\u0430\u0440\u0435\u043d\u044c\u043a\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0438\u0434\u0435\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0441\u043a\u0438\u0445 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u043e \u0441\u0435\u0439 \u0434\u0435\u043d\u044c.  <\/p>\n<p>\u0412 \u0447\u0435\u043c \u0436\u0435 \u0442\u0430\u043a \u043f\u043b\u043e\u0445\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430? \u041d\u0443 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0433\u043e\u0432\u043e\u0440\u044f \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0443\u043d\u043a\u0442\u044b:<\/p>\n<ol>\n<li>\n<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 (\u0430\u043d\u0430\u043b\u043e\u0433 \u0421\u0423\u0411\u0414)<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0430, \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0449\u0435 \u043c\u0438\u043d\u0443\u0441\u044b, \u0438\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0443\u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u043d\u043e\u0439. \u041d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u2013 \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043f\u043e\u043b\u044f\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446, \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0442.\u0434.)  <\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u0441\u043c\u043e\u0433 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0440\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c, \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0437\u0430\u0438\u043d\u0442\u0440\u0438\u0433\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u0431\u0430\u0437\u044b \u2013 \u044d\u0442\u043e \u043a\u0440\u0443\u0442\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0437\u043d\u0430\u0442\u044c \u0438 \u0443\u043c\u0435\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.  <\/p>\n<p>\u0413\u043e\u0432\u043e\u0440\u044f \u043e \u0431\u0430\u0437\u0430\u0445, \u044f \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u0437\u0430\u043f\u0440\u043e\u0441 \u2013 \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u0448\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0431\u0430\u0437\u0435. \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 SQL, \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0438 \u0432\u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445:  <\/p>\n<ul>\n<li>\n<p>SELECT<\/p>\n<\/li>\n<li>\n<p>FROM<\/p>\n<\/li>\n<li>\n<p>JOIN<\/p>\n<\/li>\n<li>\n<p>WHERE<\/p>\n<\/li>\n<li>\n<p>GROUP BY<\/p>\n<\/li>\n<li>\n<p>HAVING<\/p>\n<\/li>\n<li>\n<p>ORDER BY<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0437 3 \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<p><em>dbo.Student<\/em><\/p>\n<ul>\n<li>\n<p><em>Id<\/em><\/p>\n<\/li>\n<li>\n<p><em>Name<\/em><\/p>\n<\/li>\n<li>\n<p><em>Course<\/em><\/p>\n<\/li>\n<li>\n<p><em>BirthDate<\/em><\/p>\n<\/li>\n<\/ul>\n<p><em>dbo.Department<\/em><\/p>\n<ul>\n<li>\n<p><em>Id<\/em><\/p>\n<\/li>\n<li>\n<p><em>Name<\/em><\/p>\n<\/li>\n<\/ul>\n<p><em>dbo.Coursework<\/em><\/p>\n<ul>\n<li>\n<p><em>Id<\/em><\/p>\n<\/li>\n<li>\n<p><em>StudentId<\/em><\/p>\n<\/li>\n<li>\n<p><em>DepartmentId<\/em><\/p>\n<\/li>\n<li>\n<p><em>DeliveryDate<\/em><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"sql\">-- SELECT \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c.  -- \u0415\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c *, \u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u044b\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439. SELECT Student.Name, Student.BirthDate, COUNT(*) AS [\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445] -- FROM \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0438\u0437 \u043a\u0430\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 FROM Student -- JOIN \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043b\u0438\u0431\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e. -- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0432\u044f\u0437\u044c \u043f\u043e \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a\u0430\u043c \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432. JOIN Coursework ON Student.Id = Coursework.StudentId -- WHERE \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0443 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043b\u0438\u0431\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e . -- \u0422\u0430\u043a, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0438\u0449\u0443 \u0442\u0435\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0432 \u0438\u043c\u0435\u043d\u0438 \u043d\u0430\u0447\u0430\u043b\u043e Vladzimir. WHERE Student.Name LIKE 'Vladzimir%' -- GROUP BY \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c,  -- \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430 \u0441\u0434\u0430\u043d\u043e \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445. GROUP BY Student.Name, Student.BirthDate -- HAVING \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0442\u043e\u0440\u0438\u0447\u043d\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 GROUP BY. -- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0442\u0435 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 1 \u043a\u0443\u0440\u0441\u043e\u0432\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. HAVING COUNT(*) > 1 -- ORDER BY \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438. \u0422\u0430\u043a, \u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e -- \u043f\u043e \u043f\u043e\u043b\u044e \u0434\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f. -- \u0414\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u043d\u0430\u0434\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e DESC. ORDER BY BirthDate DESC<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0418\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0445 \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445, \u0435\u0441\u043b\u0438 \u0438\u0445 \u0441\u0434\u0430\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 1. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 Vladzimir. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0434\u0430\u0442\u044b \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0441 SQL \u0438 \u043e\u043d \u0443\u0436\u0435 \u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u043c \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c.\u00a0\u0425\u043e\u0442\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0438\u043c \u043d\u0430\u0434\u043e \u043c\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043d\u0430\u0448\u0435\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.. \u041a\u0430\u043a \u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445?   <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441 \u0447\u0435\u043c \u043d\u0430\u0434\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f &#8212; \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u0448\u0430 \u0431\u0430\u0437\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0421\u0423\u0411\u0414, \u0442\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c41\/a8e\/a39\/c41a8ea3927884e503b4d651d7ccfe4e.png\" width=\"469\" height=\"307\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c41\/a8e\/a39\/c41a8ea3927884e503b4d651d7ccfe4e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f MS SQL Server, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Microsoft SQL Server Managment Studio (SSMS) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, PostgreSQL \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c PG Admin \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0421\u0423\u0411\u0414.<\/p>\n<p>\u041f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 SQL \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 (Express \u0438\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f) \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432:\u00a0<\/p>\n<p>{\u0418\u043c\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430}\\SQLEXPRESS,\u00a0\u00a0<\/p>\n<p>{\u0418\u043c\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430}.\u00a0<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c (localdb)\\MSSQLLocalDB.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432\u0448\u0438\u0441\u044c \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u0443\u0433\u043e\u0434\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043d\u0438\u0436\u0435 \u0431\u0430\u0437\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f University), \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b .NET. <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 .NET \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 (\u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043d\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445, \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0438).   <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b0f\/4a2\/4bf\/b0f4a24bf5319745f8e3be6458730446.png\" width=\"704\" height=\"245\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b0f\/4a2\/4bf\/b0f4a24bf5319745f8e3be6458730446.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0442\u0435\u043e\u0440\u0438\u0438.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u044f, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f:<\/p>\n<ol>\n<li>\n<p>ORM &#8212; \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a Object\/Relational Mapping, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439, \u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a, CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437 \u043f\u043e\u0434 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Change Tracker, Unit of Work \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<li>\n<p>Micro-ORM &#8212; \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 C#. \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441. \u0412\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u043f\u043b\u0435\u0447\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 ADO.NET &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, EntityFramework (EF) &#8212; ORM, \u0430 Dapper &#8212; micro-ORM.<\/strong><\/p>\n<h2>ADO.NET<\/h2>\n<p><strong>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:<\/strong><\/p>\n<ul>\n<li>\n<p>System.Data.SqlClient<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c, \u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0441\u0442\u043e\u043b\u043f\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f ADO.NET. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0441\u0442\u0430\u0440\u044b\u043c, \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0432\u043e\u0431\u043e\u0434\u0443 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0427\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f? \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439, \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0431\u0430\u0437\u0443, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435.. \u041d\u0443 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0432 \u043e\u0431\u0449\u0435\u043c, \u0435\u0433\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u0438\u043c \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0438 \u0441\u0430\u043c\u0438\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0434\u0430, \u0434\u043b\u044f \u043e\u0441\u043e\u0431\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0445 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f using \u0435\u0449\u0435).<\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ADO.NET:<\/strong><\/p>\n<ul>\n<li>\n<p>SqlConnection  <\/p>\n<\/li>\n<li>\n<p>SqlCommand<\/p>\n<\/li>\n<li>\n<p>SqlDataReader<\/p>\n<\/li>\n<li>\n<p>SqlParameter<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 ADO.NET:<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c &#8212; \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 SqlConnection, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c connectionString, \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435<\/p>\n<p>\u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f: <\/p>\n<pre><code class=\"cs\">var connectionString =    \"Data Source=.\\\\SQLEXPRESS;Initial Catalog=University;Integrated Security=True\";<\/code><\/pre>\n<pre><code class=\"cs\">\/\/ \u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. var sqlConnection = new SqlConnection(connectionString);<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439:<\/p>\n<pre><code class=\"cs\">try {     sqlConnection.Open();     Console.WriteLine(\"SQL \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u043e.\");      \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \/ \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f).     var sqlCommand = sqlConnection.CreateCommand();     sqlCommand.CommandText = \"INSERT INTO Student VALUES ('TestUser', 1, '20220101')\";     var affectedRows = sqlCommand.ExecuteNonQuery();     Console.WriteLine($\"\u0427\u0438\u0441\u043b\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a: {affectedRows}\");      \/\/ \u0427\u0442\u0435\u043d\u0438\u0435.     var sqlCommandForRead = sqlConnection.CreateCommand();     sqlCommandForRead.CommandText = \"SELECT * FROM Student\";     SqlDataReader reader = sqlCommandForRead.ExecuteReader();      if (reader.HasRows)     {         while (reader.Read())         {             \/\/ \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 reader[\"\"] - \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c object,             \/\/ \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f,             \/\/ \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c reader.GetString() \/ reader.GetInt() \u0438 \u0442.\u0434.             Console.WriteLine($\"\u0421\u0442\u0443\u0434\u0435\u043d\u0442 \u0441 Id: {reader[\"Id\"]}, \" +                 $\"\u0441 \u043a\u0443\u0440\u0441\u043e\u043c: {reader[\"Course\"]}, \" +                 $\"\u0441 \u0438\u043c\u0435\u043d\u0435\u043c: {reader[\"Name\"]}, \" +                 $\"\u0441 \u0434\u0430\u0442\u043e\u0439 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f: {reader[\"BirthDate\"]}\");         }     }      reader.Close();      \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438     var sqlCommandForCount = sqlConnection.CreateCommand();     sqlCommandForCount.CommandText = \"SELECT COUNT(*) FROM Student\";     var count = sqlCommandForCount.ExecuteScalar();     Console.WriteLine($\"\u041f\u043e\u043b\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432: {count}\");      \/\/ \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.     var name = \"Some Student Name\";      \/\/ \u041f\u043b\u043e\u0445\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      \/\/\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 SQL-\u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0439.     var sqlString = $\"INSERT INTO Student VALUES ('{name}', 1, '20220101')\";      var sqlCommandForInsertBadPractice = new SqlCommand(sqlString)     {         Connection = sqlConnection     };      affectedRows = sqlCommandForInsertBadPractice.ExecuteNonQuery();      \/\/ \u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 SQL \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.     sqlString = $\"INSERT INTO Student VALUES (@name, 1, '20220101')\";     var sqlParamForName = new SqlParameter(\"@name\", name);     var sqlCommandForInsertGoodPractice = new SqlCommand(sqlString);      \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.     sqlCommandForInsertGoodPractice.Parameters.Add(sqlParamForName);     affectedRows = sqlCommandForInsertBadPractice.ExecuteNonQuery(); } catch (Exception ex) {     Console.WriteLine($\"\u041e\u0448\u0438\u0431\u043a\u0430: {ex.Message}\");     throw; } finally {     sqlConnection.Close();     Console.WriteLine(\"SQL \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u043e.\"); }<\/code><\/pre>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u0442\u0443\u0442 \u0441\u043e\u0431\u0440\u0430\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u043e \u043d\u0430\u0434\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0442\u0443\u0442 \u043e\u0434\u043d\u0430: <\/p>\n<ol>\n<li>\n<p>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e try catch finally<\/p>\n<\/li>\n<li>\n<p>\u0412 try \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0432 finally \u0435\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0431\u043e\u0440: \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e &#8212; \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435?<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 SqlCommand, \u0437\u0430\u0442\u0435\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 ExecuteNonQuery(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a:<\/p>\n<pre><code class=\"cs\">var sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = \"INSERT INTO Student VALUES ('TestUser', 1, '20220101')\"; var affectedRows = sqlCommand.ExecuteNonQuery(); Console.WriteLine($\"\u0427\u0438\u0441\u043b\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a: {affectedRows}\");<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u043a\u0443 1 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u043a\u0436\u0435 \u0440\u043e\u0432\u043d\u043e 1.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u0432\u0430\u0442\u044c ExecuteNonQuery(), \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c ExecuteReader(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 SqlDataReader.<\/p>\n<pre><code class=\"cs\">var sqlCommandForRead = sqlConnection.CreateCommand(); sqlCommandForRead.CommandText = \"SELECT * FROM Student\"; SqlDataReader reader = sqlCommandForRead.ExecuteReader();<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u0435\u0440\u043d\u0443\u043b \u043b\u0438 \u043e\u043d \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043b\u0438\u0431\u043e \u0441\u0442\u0440\u043e\u043a\u0438, \u0438 \u0435\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u043b, \u0442\u043e \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u044c<\/p>\n<pre><code class=\"cs\">if (reader.HasRows) {   while (reader.Read())   {     \/\/ \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 reader[\"\"] - \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c object,     \/\/ \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f,     \/\/ \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c reader.GetString() \/ reader.GetInt() \u0438 \u0442.\u0434.     Console.WriteLine($\"\u0421\u0442\u0443\u0434\u0435\u043d\u0442 \u0441 Id: {reader[\"Id\"]}, \" +                       $\"\u0441 \u043a\u0443\u0440\u0441\u043e\u043c: {reader[\"Course\"]}, \" +                       $\"\u0441 \u0438\u043c\u0435\u043d\u0435\u043c: {reader[\"Name\"]}, \" +                       $\"\u0441 \u0434\u0430\u0442\u043e\u0439 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f: {reader[\"BirthDate\"]}\");   } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0432\u044b\u0439\u0434\u0435\u043c \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 while &#8212; \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c reader.<\/p>\n<pre><code class=\"cs\">reader.Close();<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (COUNT, MIN, MAX, AVG, SUM) &#8212; \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u043c\u0435\u0442\u043e\u0434 ExecuteScalar(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 (\u0447\u0442\u043e\u0431 \u0432 \u0446\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u0438 \u043d\u0443\u0436\u043d\u043e).<\/p>\n<pre><code class=\"cs\">var sqlCommandForCount = sqlConnection.CreateCommand(); sqlCommandForCount.CommandText = \"SELECT COUNT(*) FROM Student\"; var count = sqlCommandForCount.ExecuteScalar(); Console.WriteLine($\"\u041f\u043e\u043b\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432: {count}\");<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438: \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0438 SQL-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f name, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<pre><code class=\"cs\">var name = \"Some Student Name\";<\/code><\/pre>\n<p><strong>\u0418\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a<\/strong><\/p>\n<p>\u041a \u043f\u043b\u044e\u0441\u0430\u043c \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a<\/p>\n<pre><code class=\"cs\">var sqlString = $\"INSERT INTO Student VALUES ('{name}', 1, '20220101')\";  var sqlCommandForInsertBadPractice = new SqlCommand(sqlString) { Connection = sqlConnection };  affectedRows = sqlCommandForInsertBadPractice.ExecuteNonQuery();<\/code><\/pre>\n<p>\u0412 \u0447\u0435\u043c \u043c\u0438\u043d\u0443\u0441 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430? \u0412 \u0442\u043e\u0442, \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0435\u0441\u043b\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043e\u0434 \u043d\u0438\u043a\u0430\u043a \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0431\u044b\u0442\u044c \u0432\u0441\u044f\u043a\u0438\u0435 SQL-\u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438, \u043b\u0438\u0448\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u0442.\u0434.<\/p>\n<p><strong>SQL-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/strong><\/p>\n<p>\u0422\u0443\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435 \u0438 \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0432\u044b\u0448\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">sqlString = $\"INSERT INTO Student VALUES (@name, 1, '20220101')\"; var sqlParamForName = new SqlParameter(\"@name\", name); var sqlCommandForInsertGoodPractice = new SqlCommand(sqlString);  sqlCommandForInsertGoodPractice.Parameters.Add(sqlParamForName); affectedRows = sqlCommandForInsertBadPractice.ExecuteNonQuery();<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 ADO.NET \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u0412 \u0446\u0435\u043b\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f &#8212; \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430, \u0438 \u043f\u0438\u0441\u0430\u0442\u044c SQL \u043a\u043e\u0434.<\/p>\n<h2>Dapper<\/h2>\n<p><strong>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:<\/strong><\/p>\n<ul>\n<li>\n<p>Dapper<\/p>\n<\/li>\n<li>\n<p>System.Data.SqlClient<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0435\u0439 \u0442\u0435\u043e\u0440\u0438\u0438 \u0442\u0443\u0442 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443. \u0412 \u0446\u0435\u043b\u043e\u043c Dapper &#8212; \u044d\u0442\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u0441\u0451 \u0435\u0449\u0435 \u043d\u0443\u0436\u0435\u043d SqlConnection, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438 \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 using. \u0422\u0430\u043a\u0436\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u043f\u043b\u044e\u0441\u043e\u0432 Dapper &#8212; \u044d\u0442\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 C#, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 reader, \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 ADO.NET<\/p>\n<p><strong>\u041a\u043b\u0430\u0441\u0441\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Dapper<\/strong><\/p>\n<ul>\n<li>\n<p>SqlConnection<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043e\u0442 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b: .Query&lt;T>() \u0438 .Execute().<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u043b\u0433\u043e \u043d\u0435 \u0442\u044f\u043d\u0443\u0442\u044c &#8212; \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Dapper:<\/p>\n<pre><code class=\"cs\">using (var sqlConnection = new SqlConnection(connectionString)) {     \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \/ \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f).     sqlConnection.Execute(       \"INSERT INTO Student VALUES ('TestUserDapper', 1, '20220101')\"     );      \/\/ \u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.     var students = sqlConnection.Query&lt;Student>(\"SELECT * FROM Student\").ToList();      foreach (var student in students)     {         Console.WriteLine($\"\u0421\u0442\u0443\u0434\u0435\u043d\u0442 \u0441 Id: {student.Id}, \" +             $\"\u0441 \u043a\u0443\u0440\u0441\u043e\u043c: {student.Course}, \" +             $\"\u0441 \u0438\u043c\u0435\u043d\u0435\u043c: {student.Name}, \" +             $\"\u0441 \u0434\u0430\u0442\u043e\u0439 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f: {student.BirthDate}\");     }      \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438     \/\/ \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 .FirstOrDefault(), \u0442\u0430\u043a \u043a\u0430\u043a     \/\/ .Query&lt;T> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 IEnumerable&lt;T>, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439.     \/\/ \u0418 \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 1 \u0437\u0430\u043f\u0438\u0441\u044c, \u0442\u043e \u0431\u0435\u0437 \u0437\u0430\u0437\u0440\u0435\u043d\u0438\u0439 \u0441\u043e\u0432\u0435\u0441\u0442\u0438     \/\/ \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c .FirstOrDefault(), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439.     var count = sqlConnection.Query&lt;int>(\"SELECT COUNT(*) FROM Student\")        .FirstOrDefault();      Console.WriteLine($\"\u041e\u0431\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432: {count}\");      \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.     sqlConnection.Execute(\"INSERT INTO Student VALUES (@Name, @Course, @BirthDate)\",          new Student         {              Name = \"SomeParamName\",              Course = 2,              BirthDate = new DateTime(2022, 04, 04)         });      \/\/ \u0410\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b new { }.     sqlConnection.Execute(\"DELETE FROM Student WHERE Name = @name\",          new { name = \"TestUserDapper\" }); }<\/code><\/pre>\n<p>\u0414\u0430\u0436\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u043e\u0431\u044a\u0435\u043c\u0443 \u043a\u043e\u0434\u0430 \u0443\u0436\u0435 \u0432\u0438\u0434\u043d\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e Dapper \u043f\u0440\u043e\u0449\u0435 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443 Dapper \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ol>\n<li>\n<p>\u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 using \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 SqlConnection \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u0432 \u043d\u0435\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0445\u043e\u0442\u0438\u043c \u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u043b\u0438 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c &#8212; \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c .Query&lt;T> \u0438\u043b\u0438 .Execute<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c .Query&lt;T>, \u0433\u0434\u0435 T &#8212; \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0443\u0442 \u043c\u0430\u043f\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b. \u0422\u0430\u043a, \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0440\u0443\u043a\u0430\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0440\u0443\u043a\u0430\u043c\u0438 &#8212; Dapper \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430 \u043d\u0430\u0441, \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c IEnumerable&lt;T>.<\/p>\n<pre><code class=\"cs\">var students = sqlConnection.Query&lt;Student>(\"SELECT * FROM Student\").ToList(); \/\/ \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 students \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a ToList()  \/\/ \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u043c \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445.<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 Query&lt;T>, \u0433\u0434\u0435 \u0432 T \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 (int, double, float \u0438 \u0442.\u0434), \u0430 \u0437\u0430\u0442\u0435\u043c \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043a\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0431\u0430\u0437\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 1 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 1 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u043c.<\/p>\n<pre><code class=\"cs\">var count = sqlConnection.Query&lt;int>(\"SELECT COUNT(*) FROM Student\")        .FirstOrDefault();<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u0438\u043b\u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>\u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c:<\/p>\n<pre><code class=\"cs\">sqlConnection.Execute(\"INSERT INTO Student VALUES (@Name, @Course, @BirthDate)\",          new Student         {              Name = \"SomeParamName\",              Course = 2,              BirthDate = new DateTime(2022, 04, 04)         });<\/code><\/pre>\n<p>Dapper \u0441\u0430\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043f\u043e \u0438\u043c\u0435\u043d\u0438. \u0415\u0441\u043b\u0438 \u0442\u0438\u043f\u044b \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 &#8212; \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0418 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"cs\">sqlConnection.Execute(\"DELETE FROM Student WHERE Name = @name\",          new { name = \"TestUserDapper\" });<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Dapper \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u041e\u043d \u043f\u0440\u043e\u0441\u0442 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0438 \u043a\u0430\u043a \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0430\u043b\u0435\u0435, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043d. <\/p>\n<h2>EntityFramework<\/h2>\n<p><strong>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:<\/strong><\/p>\n<ul>\n<li>\n<p>Microsoft.EntityFrameworkCore<\/p>\n<\/li>\n<li>\n<p>Microsoft.EntityFrameworkCore.SqlServer<\/p>\n<\/li>\n<li>\n<p>Microsoft.EntityFrameworkCore.Tools (\u041d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u043d\u0430\u044e \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c, \u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u0439 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u043c\u043e\u043d\u0441\u0442\u0440\u043e\u043c, \u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u041e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0437 \u043d\u0438\u0445 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c &#8212; \u0442\u043e EF \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. <\/p>\n<p><strong>\u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0441\u0442\u043e\u0440\u043e\u043d \u043e\u0442 EF:<\/strong><\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 (Code First, Database First)<\/p>\n<\/li>\n<li>\n<p>\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>LINQ To Entities (\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 EntityFrameworkCore)<\/p>\n<\/li>\n<li>\n<p>AsNoTracking<\/p>\n<\/li>\n<li>\n<p>CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 &#8212; EF \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u043e \u0441\u043f\u043e\u043b\u043d\u0430 \u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0430\u0435\u0442 \u0437\u0430 \u043d\u0435\u0451. \u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (Student, Department, Coursework):<\/p>\n<pre><code class=\"cs\">public class Student {   public int Id { get; set; }    public int Course { get; set; }    [StringLength(90)]   public string Name { get; set; }    public DateTime BirthDate { get; set; } }  public class Department {   public int Id { get; set; }    [StringLength(90)]   public string Name { get; set; } }  public class Coursework {   public int Id { get; set; }    public int StudentId { get; set; }    public int DepartmentId { get; set; }    public DateTime DeliveryDate { get; set; } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (\u0447\u0442\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0435\u0433\u043a\u043e), \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0451 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 &#8212; \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f &#8212; \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u0411\u0430\u0437\u044bContext, \u0442\u0430\u043a \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 UniversityContext.<\/p>\n<pre><code class=\"cs\">public class UniversityContext : DbContext { public UniversityContext() { } public UniversityContext(DbContextOptions options) : base(options) { }  public DbSet&lt;Student> Student { get; set; }  public DbSet&lt;Department> Department { get; set; }  public DbSet&lt;Coursework> Coursework { get; set; }  protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)   {   var dbConfig = new DbConfiguration(); optionsBuilder.UseSqlServer(dbConfig.GetConnectionString(\"connString\"));   } }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0443\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443.<\/p>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 DbSet&lt;T>. \u0412 \u0446\u0435\u043b\u043e\u043c, \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f &#8212; DbSet \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e (\u043d\u043e \u043d\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u0443\u044e), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u0443\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, DbSet&lt;Student> Student &#8212; \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 &#171;\u0435\u0441\u0442\u044c&#187; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 \u0442\u0430\u043a\u0438\u043c\u0438 \u043a\u0430\u043a \u043f\u043e\u043b\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Student, \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0443 \u0442\u0430\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Student.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 OnConfiguring(DbContextOptionsBuilder optionsBuilder). \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0441 \u043a\u0430\u043a\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u0412 \u0446\u0435\u043b\u043e\u043c \u0442\u0430\u043c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u043d\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f. <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b: \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0445 2, \u0445\u043e\u0442\u044f \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438 \u043e\u0434\u043d\u043e\u0433\u043e. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 DI \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u0435\u0439\u0441\u0435 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 OnConfiguring, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441 \u043f\u0443\u0441\u0442\u044b\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c. \u041d\u043e \u043d\u0435 \u0432\u0441\u0451 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c &#8212; \u044d\u0442\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438. \u0427\u0443\u0442\u044c \u043d\u0438\u0436\u0435 \u043c\u044b \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435, \u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u043b &#8212; \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439:<\/p>\n<ul>\n<li>\n<p>\u0418\u043c\u0435\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u0435\u0442\u044c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IDesignTimeDbContextFactory&lt;T>, \u0433\u0434\u0435 T &#8212; \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">public class UniversityContextFactory :  IDesignTimeDbContextFactory&lt;UniversityContext> { public UniversityContext CreateDbContext(string[] args) { var dbConfig = new DbConfiguration(); var optionsBuilder = new DbContextOptionsBuilder&lt;UniversityContext>(); optionsBuilder.UseSqlServer(dbConfig.GetConnectionString(\"connString\"));  return new UniversityContext(optionsBuilder.Options); } }<\/code><\/pre>\n<p><strong>\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/strong><\/p>\n<p>\u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 &#8212; \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043b\u043e\u0432\u043e EF \u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0435\u0433\u043e \u0441\u0442\u043e\u0440\u043e\u043d. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438? <\/p>\n<p>\u042d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0433\u0438\u0442\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0432\u043d\u043e\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0432\u044b \u201c\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0435\u201d \u044d\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e. \u041e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430: Up \u0438 Down. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u201c\u0432\u0432\u0435\u0440\u0445\u201d \u0438\u043b\u0438 \u201c\u0432\u043d\u0438\u0437\u201d. \u041d\u0435\u043c\u0430\u043b\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u043f\u043b\u044e\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 &#8212; \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0431\u0430\u0437\u0443. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0442\u0438 \u043f\u043e \u0446\u0438\u043a\u043b\u0443: \u0432\u043d\u0435\u0441\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 C# \u043a\u043b\u0430\u0441\u0441\u044b, \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e. <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c Package Manager Console \u0432 Visual Studio \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code>Add-Migration &lt;\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438><\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f 2 \u043a\u043b\u0430\u0441\u0441\u0430 (\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 1 \u043a\u043b\u0430\u0441\u0441).<\/p>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 &#8212; ModelSnapshot, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u043e\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439, \u0438 \u0437\u043d\u0430\u0435\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f. <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 &#8212; \u044d\u0442\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u0448\u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0438 \u0438\u043c\u0435\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"cs\">public partial class Initial : Migration     {         protected override void Up(MigrationBuilder migrationBuilder)         {             migrationBuilder.CreateTable(                 name: \"Coursework\",                 columns: table => new                 {                     Id = table.Column&lt;int>(type: \"int\", nullable: false)                         .Annotation(\"SqlServer:Identity\", \"1, 1\"),                     StudentId = table.Column&lt;int>(type: \"int\", nullable: false),                     DepartmentId = table.Column&lt;int>(type: \"int\", nullable: false),                     DeliveryDate = table.Column&lt;DateTime>(type: \"datetime2\",                      nullable: false)                 },                 constraints: table =>                 {                     table.PrimaryKey(\"PK_Coursework\", x => x.Id);                 });              migrationBuilder.CreateTable(                 name: \"Department\",                 columns: table => new                 {                     Id = table.Column&lt;int>(type: \"int\", nullable: false)                         .Annotation(\"SqlServer:Identity\", \"1, 1\"),                     Name = table.Column&lt;string>(type: \"nvarchar(90)\",                      maxLength: 90, nullable: false)                 },                 constraints: table =>                 {                     table.PrimaryKey(\"PK_Department\", x => x.Id);                 });              migrationBuilder.CreateTable(                 name: \"Student\",                 columns: table => new                 {                     Id = table.Column&lt;int>(type: \"int\", nullable: false)                         .Annotation(\"SqlServer:Identity\", \"1, 1\"),                     Course = table.Column&lt;int>(type: \"int\", nullable: false),                     Name = table.Column&lt;string>(type: \"nvarchar(90)\",                      maxLength: 90, nullable: false),                     BirthDate = table.Column&lt;DateTime>(type: \"datetime2\",                      nullable: false)                 },                 constraints: table =>                 {                     table.PrimaryKey(\"PK_Student\", x => x.Id);                 });         }          protected override void Down(MigrationBuilder migrationBuilder)         {             migrationBuilder.DropTable(                 name: \"Coursework\");              migrationBuilder.DropTable(                 name: \"Department\");              migrationBuilder.DropTable(                 name: \"Student\");         }     }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435 &#8212; \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430, \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e (\u0442\u043e \u0435\u0441\u0442\u044c \u0438\u0434\u0435\u043c &#171;\u0432\u0432\u0435\u0440\u0445&#187;), \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e (\u0442\u043e \u0435\u0441\u0442\u044c \u0438\u0434\u0435\u043c &#171;\u0432\u043d\u0438\u0437&#187;). \u0422\u0430\u043a, \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0441 \u0438\u043c\u0435\u043d\u0435\u043c Initial, \u0438 \u043f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0442\u0440\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 \u043f\u0440\u0438 \u043e\u0442\u043c\u0435\u043d\u0435 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 &#8212; \u0443\u0434\u0430\u043b\u044f\u0442\u0441\u044f 3 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>\u041c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u0437 \u0431\u0430\u0437\u044b (\u0434\u0430\u0436\u0435 \u0441\u0430\u043c\u0443 \u0431\u0430\u0437\u0443), \u0438 \u0432\u0432\u0435\u0441\u0442\u0438 \u0432 Package Manager Console \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code>Update-Database<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0434\u0438\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 Code First, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u0430 \u043f\u043e\u0442\u043e\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e EF \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0431\u0430\u0437\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f &#8212; Database First, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e, \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u0442\u043e\u043b\u044c\u043a\u043e C# \u043a\u043e\u0434. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434, \u0438 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0432\u0441\u0451 \u0442\u043e\u0442 \u0436\u0435 Package Manager Console:<\/p>\n<pre><code class=\"cs\">Scaffold-DbContext \"Server=(localdb)\\mssqllocaldb;Database=University;Trusted_Connection=True;\" Microsoft.EntityFrameworkCore.SqlServer<\/code><\/pre>\n<p>\u0418 \u0442\u0430\u043a, \u043a\u0430\u043a \u0438 \u044f \u0441\u043a\u0430\u0437\u0430\u043b, \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 EF, \u043d\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439.<\/p>\n<p><strong>LINQ To Entities<\/strong><\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c EF &#8212; \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0435\u0437 \u0437\u043d\u0430\u043d\u0438\u044f SQL, \u0442\u0430\u043a \u043a\u0430\u043a EF \u0441\u0430\u043c \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f C# \u043a\u043e\u0434\u0430 \u0432 SQL.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u0442\u043e\u043c\u0443 SQL \u0441\u043a\u0440\u0438\u043f\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435:<\/p>\n<pre><code class=\"sql\">SELECT Student.Name, Student.BirthDate, COUNT(*) AS [\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445] FROM Student JOIN Coursework ON Student.Id = Coursework.StudentId WHERE Student.Name LIKE 'Vladzimir%' GROUP BY Student.Name, Student.BirthDate HAVING COUNT(*) > 1 ORDER BY BirthDate DESC<\/code><\/pre>\n<p>\u041d\u0430 \u044f\u0437\u044b\u043a\u0435 LINQ \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">var sqlQueryToLinq = dbContext.Student   .Where(student => student.Name.Contains(\"Vladzimir\"))   .Join(dbContext.Coursework,          student => student.Id,          coursework => coursework.StudentId,          (student, coursework) => student)   .GroupBy(student => new { student.Name, student.BirthDate })   .Where(grouped => grouped.Count() > 1)   .OrderByDescending(grouped => grouped.Key.BirthDate)   .Select(grouped =>            new { grouped.Key.Name, grouped.Key.BirthDate, Count = grouped.Count() })   .ToList();<\/code><\/pre>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u043b\u044e\u0431\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c \u0438\u0437 SQL. \u0410 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u043a\u0430 &#8216;=>&#8217; \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0430\u044f, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u044b. \u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435, \u0442\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 LINQ \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">\/\/ \u041e\u0431\u0440\u0430\u0449\u0430\u044e\u0441\u044c \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Student dbContext.Student \/\/ \u0418\u0437 \u0432\u0441\u0435\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430,  \/\/ \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u043c\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \"Vladzimir\"   .Where(student => student.Name.Contains(\"Vladzimir\")) \/\/ \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 Coursework   .Join(dbContext.Coursework,  \/\/ \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b Student \u0441\u0432\u044f\u0437\u044c \u043f\u043e \u043f\u043e\u043b\u044e Id         student => student.Id,  \/\/ \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b Coursework \u0441\u0432\u044f\u0437\u044c \u043f\u043e \u043f\u043e\u043b\u044e StudentId         coursework => coursework.StudentId, \/\/ \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0443         (student, coursework) => student) \/\/ \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0443 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438 \u0434\u0430\u0442\u0435 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f   .GroupBy(student => new { student.Name, student.BirthDate }) \/\/ \u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438,  \/\/ \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 1 \/\/ (\u044d\u0442\u043e \u043c\u044b \u043f\u0440\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438)   .Where(grouped => grouped.Count() > 1) \/\/ \u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0434\u043d\u044f \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f   .OrderByDescending(grouped => grouped.Key.BirthDate) \/\/ \u0418\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u043e\u0431\u044c\u0435\u043a\u0442\u043e\u0432, \/\/ \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u0438\u0437 \u0438\u043c\u0435\u043d\u0438, \u0434\u043d\u044f \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445   .Select(grouped =>            new { grouped.Key.Name, grouped.Key.BirthDate,                  Count = grouped.Count() }) \/\/ \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430   .ToList();<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p><strong>AsNoTracking<\/strong><\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c EntityFramework, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c:<\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 EntityFramework \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442.\u0434. <\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u044f\u0432\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Change Tracker, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 C#. \u0422\u0430\u043a\u0436\u0435, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u043c, \u0442\u043e \u043c\u044b \u0435\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 AsNoTracking(). <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430:<\/p>\n<pre><code class=\"cs\">var studentVladzimir = dbContext.Student   .Where(student => student.Name.Contains(\"Vladzimir\"))   .FirstOrDefault();  studentVladzimir.Course = 999; dbContext.SaveChanges();  var studentVladzimirWithoutTracking = dbContext.Student       .Where(student => student.Name.Contains(\"Vladzimir\"))       .AsNoTracking()       .FirstOrDefault();  studentVladzimirWithoutTracking.Course = 777; dbContext.SaveChanges();<\/code><\/pre>\n<p>\u0427\u0442\u043e \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0435\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043c \u0442\u0430\u043a\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c? \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 999.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0442\u043e \u043e\u043d \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0430 \u0441\u0442\u0430\u0432\u0438\u0442 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c \u0438 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0438\u0437 \u0431\u0430\u0437\u044b \u0441\u0432\u044f\u0437\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0431\u0430\u0437\u0435 \u043f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 SaveChanges().<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f AsNoTracking() &#8212; \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u044c, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e new Student().<\/p>\n<p><strong>CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/strong><\/p>\n<p>\u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u043e\u043d\u0443\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0435\u0442 EF &#8212; \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>\u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">dbContext.Student.Add(   new Student()  {      Name = \"SomeStudent For EF Test\",      Course = 3,      BirthDate = new DateTime(2022, 4, 7)  });<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f (Update), \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f (Remove).<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u043f\u043b\u044e\u0441\u043e\u0432, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 &#8212; AddRange, UpdateRange, RemoveRange, \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c bulk-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/h2>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430\u043c\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0440\u0430\u0437\u0443. <\/p>\n<p>\u042f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0442\u0435\u0441\u0442\u043e\u0432, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0446\u0435\u043b\u043e\u043c \u043b\u044e\u0431\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e.<\/p>\n<p> \u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u043d\u0430 20000 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">Method<\/p>\n<\/td>\n<td>\n<p align=\"left\">Time<\/p>\n<\/td>\n<td>\n<p align=\"left\">Allocated Memory<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">GetAll_EF_WithTracking<\/p>\n<\/td>\n<td>\n<p align=\"left\">51.79 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\">22 MB<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">GetAll_EF_WithNoTracking<\/p>\n<\/td>\n<td>\n<p align=\"left\">16.52 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\">6 MB<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">GetAll_ADO<\/p>\n<\/td>\n<td>\n<p align=\"left\">7.351 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\">2 MB<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">GetAll_Dapper<\/p>\n<\/td>\n<td>\n<p align=\"left\">13.07 ms<\/p>\n<\/td>\n<td>\n<p align=\"left\">4 MB<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, EF \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0435 \u0441\u0430\u043c\u044b\u0435 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0438 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u0432\u0441\u044f\u0447\u0435\u0441\u043a\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043a\u0435\u0448\u0430 \u043a\u0430\u043a\u0438\u0445 \u043b\u0438\u0431\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 Dapper \u0438 EF \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e 5%. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u043e\u0441\u0442\u044c EF \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e, \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u043d \u043a\u0443\u0448\u0430\u0435\u0442.<\/p>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u0432\u043e\u0435\u043c &#8212; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0434\u043a\u0438\u0439 \u043a\u0435\u0439\u0441, \u0438 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0430\u0434\u043e \u0432\u044b\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u043e\u0442 1 \u0434\u043e 100 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0437\u0430 \u0440\u0430\u0437, \u0438 \u043d\u0430 \u0442\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. <\/p>\n<p><strong>\u0412\u043e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0439\u0442\u0438, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e:<\/strong><\/p>\n<ol>\n<li>\n<p>.NET \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b, \u0438 \u0432\u044b\u0431\u043e\u0440 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043d\u0443\u0448\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0434\u0432\u0443\u0445 \u0434\u0440\u0443\u0433\u0438\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0417\u043d\u0430\u043d\u0438\u0435 SQL \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u0412\u043b\u0438\u044f\u043d\u0438\u0435 EntityFramework \u0441 \u0433\u043e\u0434\u0430\u043c\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u0438 \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u0438 \u043d\u0430 \u0442\u043e \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0432\u044b\u0431\u043e\u0440 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 Dapper \u0438 EntityFramework.<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0432\u0441\u0451, \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438!<\/p>\n<p>\u041a\u0430\u043a \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0441\u0430\u043c\u0438, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 github-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/669198\/\"> https:\/\/habr.com\/ru\/post\/669198\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0445\u043e\u0434\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b<a href=\"https:\/\/github.com\/vliashko\/CommunicationWithDB\" rel=\"noopener noreferrer nofollow\"> \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>. \u0412\u043f\u043e\u043b\u043d\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f, \u0438\u043b\u0438, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0445\u043e\u0442\u044f\u0442 \u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438.<\/p>\n<p><strong>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0431\u0443\u0434\u044c \u0442\u043e \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u044b \u0438\u043b\u0438 \u0432\u0435\u0431, \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437?<\/strong> <\/p>\n<p>\u041d\u0443, \u0447\u0438\u0441\u0442\u043e \u0432 \u0442\u0435\u043e\u0440\u0438\u0438 \u043c\u043e\u0436\u043d\u043e, \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0441\u0442\u0430\u0440\u0435\u043d\u044c\u043a\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0438\u0434\u0435\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0441\u043a\u0438\u0445 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u043e \u0441\u0435\u0439 \u0434\u0435\u043d\u044c.  <\/p>\n<p>\u0412 \u0447\u0435\u043c \u0436\u0435 \u0442\u0430\u043a \u043f\u043b\u043e\u0445\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430? \u041d\u0443 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0433\u043e\u0432\u043e\u0440\u044f \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0443\u043d\u043a\u0442\u044b:<\/p>\n<ol>\n<li>\n<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 (\u0430\u043d\u0430\u043b\u043e\u0433 \u0421\u0423\u0411\u0414)<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0430, \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0449\u0435 \u043c\u0438\u043d\u0443\u0441\u044b, \u0438\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0443\u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u043d\u043e\u0439. \u041d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u2013 \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u043f\u043e\u043b\u044f\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446, \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0442.\u0434.)  <\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u0441\u043c\u043e\u0433 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0440\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c, \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0437\u0430\u0438\u043d\u0442\u0440\u0438\u0433\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u0431\u0430\u0437\u044b \u2013 \u044d\u0442\u043e \u043a\u0440\u0443\u0442\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0437\u043d\u0430\u0442\u044c \u0438 \u0443\u043c\u0435\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.  <\/p>\n<p>\u0413\u043e\u0432\u043e\u0440\u044f \u043e \u0431\u0430\u0437\u0430\u0445, \u044f \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u0437\u0430\u043f\u0440\u043e\u0441 \u2013 \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u0448\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0431\u0430\u0437\u0435. \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 SQL, \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0438 \u0432\u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445:  <\/p>\n<ul>\n<li>\n<p>SELECT<\/p>\n<\/li>\n<li>\n<p>FROM<\/p>\n<\/li>\n<li>\n<p>JOIN<\/p>\n<\/li>\n<li>\n<p>WHERE<\/p>\n<\/li>\n<li>\n<p>GROUP BY<\/p>\n<\/li>\n<li>\n<p>HAVING<\/p>\n<\/li>\n<li>\n<p>ORDER BY<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0437 3 \u0442\u0430\u0431\u043b\u0438\u0446:<\/p>\n<p><em>dbo.Student<\/em><\/p>\n<ul>\n<li>\n<p><em>Id<\/em><\/p>\n<\/li>\n<li>\n<p><em>Name<\/em><\/p>\n<\/li>\n<li>\n<p><em>Course<\/em><\/p>\n<\/li>\n<li>\n<p><em>BirthDate<\/em><\/p>\n<\/li>\n<\/ul>\n<p><em>dbo.Department<\/em><\/p>\n<ul>\n<li>\n<p><em>Id<\/em><\/p>\n<\/li>\n<li>\n<p><em>Name<\/em><\/p>\n<\/li>\n<\/ul>\n<p><em>dbo.Coursework<\/em><\/p>\n<ul>\n<li>\n<p><em>Id<\/em><\/p>\n<\/li>\n<li>\n<p><em>StudentId<\/em><\/p>\n<\/li>\n<li>\n<p><em>DepartmentId<\/em><\/p>\n<\/li>\n<li>\n<p><em>DeliveryDate<\/em><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"sql\">-- SELECT \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c.  -- \u0415\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c *, \u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u044b\u0431\u043e\u0440 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439. SELECT Student.Name, Student.BirthDate, COUNT(*) AS [\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445] -- FROM \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0438\u0437 \u043a\u0430\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 FROM Student -- JOIN \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043b\u0438\u0431\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e. -- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0432\u044f\u0437\u044c \u043f\u043e \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a\u0430\u043c \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432. JOIN Coursework ON Student.Id = Coursework.StudentId -- WHERE \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0443 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043b\u0438\u0431\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e . -- \u0422\u0430\u043a, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u0438\u0449\u0443 \u0442\u0435\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0432 \u0438\u043c\u0435\u043d\u0438 \u043d\u0430\u0447\u0430\u043b\u043e Vladzimir. WHERE Student.Name LIKE 'Vladzimir%' -- GROUP BY \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c,  -- \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430 \u0441\u0434\u0430\u043d\u043e \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445. GROUP BY Student.Name, Student.BirthDate -- HAVING \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0442\u043e\u0440\u0438\u0447\u043d\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 GROUP BY. -- \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u0442\u0435 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 1 \u043a\u0443\u0440\u0441\u043e\u0432\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. HAVING COUNT(*) > 1 -- ORDER BY \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438. \u0422\u0430\u043a, \u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e -- \u043f\u043e \u043f\u043e\u043b\u044e \u0434\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f. -- \u0414\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u043d\u0430\u0434\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e DESC. ORDER BY BirthDate DESC<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0418\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0445 \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0445, \u0435\u0441\u043b\u0438 \u0438\u0445 \u0441\u0434\u0430\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 1. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u043c\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 Vladzimir. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0434\u0430\u0442\u044b \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0441 SQL \u0438 \u043e\u043d \u0443\u0436\u0435 \u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u043c \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c.\u00a0\u0425\u043e\u0442\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0438\u043c \u043d\u0430\u0434\u043e \u043c\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043d\u0430\u0448\u0435\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435.. \u041a\u0430\u043a \u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445?   <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441 \u0447\u0435\u043c \u043d\u0430\u0434\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f &#8212; \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u0448\u0430 \u0431\u0430\u0437\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0421\u0423\u0411\u0414, \u0442\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f MS SQL Server, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Microsoft SQL Server Managment Studio (SSMS) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, PostgreSQL \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c PG Admin \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0421\u0423\u0411\u0414.<\/p>\n<p>\u041f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 SQL \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 (Express \u0438\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f) \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432:\u00a0<\/p>\n<p>{\u0418\u043c\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430}\\SQLEXPRESS,\u00a0\u00a0<\/p>\n<p>{\u0418\u043c\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430}.\u00a0<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c (localdb)\\MSSQLLocalDB.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432\u0448\u0438\u0441\u044c \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u0443\u0433\u043e\u0434\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043d\u0438\u0436\u0435 \u0431\u0430\u0437\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f University), \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b .NET. <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 .NET \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 (\u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043d\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445, \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0438).   <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0442\u0435\u043e\u0440\u0438\u0438.<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 3 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u044f, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f:<\/p>\n<ol>\n<li>\n<p>ORM &#8212; \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a Object\/Relational Mapping, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439, \u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a, CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437 \u043f\u043e\u0434 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Change Tracker, Unit of Work \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<li>\n<p>Micro-ORM &#8212; \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 C#. \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441. \u0412\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u043f\u043b\u0435\u0447\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 ADO.NET &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, EntityFramework (EF) &#8212; ORM, \u0430 Dapper &#8212; micro-ORM.<\/strong><\/p>\n<h2>ADO.NET<\/h2>\n<p><strong>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:<\/strong><\/p>\n<ul>\n<li>\n<p>System.Data.SqlClient<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c, \u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0441\u0442\u043e\u043b\u043f\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f ADO.NET. \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0441\u0442\u0430\u0440\u044b\u043c, \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0441\u0432\u043e\u0431\u043e\u0434\u0443 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0427\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f? \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439, \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0431\u0430\u0437\u0443, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435.. \u041d\u0443 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0432 \u043e\u0431\u0449\u0435\u043c, \u0435\u0433\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u0438\u043c \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0438 \u0441\u0430\u043c\u0438\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0434\u0430, \u0434\u043b\u044f \u043e\u0441\u043e\u0431\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0445 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f using \u0435\u0449\u0435).<\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ADO.NET:<\/strong><\/p>\n<ul>\n<li>\n<p>SqlConnection  <\/p>\n<\/li>\n<li>\n<p>SqlCommand<\/p>\n<\/li>\n<li>\n<p>SqlDataReader<\/p>\n<\/li>\n<li>\n<p>SqlParameter<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 ADO.NET:<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c &#8212; \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 SqlConnection, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c connectionString, \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435<\/p>\n<p>\u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0430\u044f: <\/p>\n<pre><code class=\"cs\">var connectionString =    \"Data Source=.\\\\SQLEXPRESS;Initial Catalog=University;Integrated Security=True\";<\/code><\/pre>\n<pre><code class=\"cs\">\/\/ \u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. var sqlConnection = new SqlConnection(connectionString);<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439:<\/p>\n<pre><code class=\"cs\">try {     sqlConnection.Open();     Console.WriteLine(\"SQL \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u043e.\");      \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \/ \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f).     var sqlCommand = sqlConnection.CreateCommand();     sqlCommand.CommandText = \"INSERT INTO Student VALUES ('TestUser', 1, '20220101')\";     var affectedRows = sqlCommand.ExecuteNonQuery();     Console.WriteLine($\"\u0427\u0438\u0441\u043b\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a: {affectedRows}\");      \/\/ \u0427\u0442\u0435\u043d\u0438\u0435.     var sqlCommandForRead = sqlConnection.CreateCommand();     sqlCommandForRead.CommandText = \"SELECT * FROM Student\";     SqlDataReader reader = sqlCommandForRead.ExecuteReader();      if (reader.HasRows)     {         while (reader.Read())         {             \/\/ \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 reader[\"\"] - \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c object,             \/\/ \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f,             \/\/ \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c reader.GetString() \/ reader.GetInt() \u0438 \u0442.\u0434.             Console.WriteLine($\"\u0421\u0442\u0443\u0434\u0435\u043d\u0442 \u0441 Id: {reader[\"Id\"]}, \" +                 $\"\u0441 \u043a\u0443\u0440\u0441\u043e\u043c: {reader[\"Course\"]}, \" +                 $\"\u0441 \u0438\u043c\u0435\u043d\u0435\u043c: {reader[\"Name\"]}, \" +                 $\"\u0441 \u0434\u0430\u0442\u043e\u0439 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f: {reader[\"BirthDate\"]}\");         }     }      reader.Close();      \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438     var sqlCommandForCount = sqlConnection.CreateCommand();     sqlCommandForCount.CommandText = \"SELECT COUNT(*) FROM Student\";     var count = sqlCommandForCount.ExecuteScalar();     Console.WriteLine($\"\u041f\u043e\u043b\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432: {count}\");      \/\/ \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.     var name = \"Some Student Name\";      \/\/ \u041f\u043b\u043e\u0445\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435      \/\/\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 SQL-\u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0439.     var sqlString = $\"INSERT INTO Student VALUES ('{name}', 1, '20220101')\";      var sqlCommandForInsertBadPractice = new SqlCommand(sqlString)     {         Connection = sqlConnection     };      affectedRows = sqlCommandForInsertBadPractice.ExecuteNonQuery();      \/\/ \u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 SQL \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.     sqlString = $\"INSERT INTO Student VALUES (@name, 1, '20220101')\";     var sqlParamForName = new SqlParameter(\"@name\", name);     var sqlCommandForInsertGoodPractice = new SqlCommand(sqlString);      \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.     sqlCommandForInsertGoodPractice.Parameters.Add(sqlParamForName);     affectedRows = sqlCommandForInsertBadPractice.ExecuteNonQuery(); } catch (Exception ex) {     Console.WriteLine($\"\u041e\u0448\u0438\u0431\u043a\u0430: {ex.Message}\");     throw; } finally {     sqlConnection.Close();     Console.WriteLine(\"SQL \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u043e.\"); }<\/code><\/pre>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u0442\u0443\u0442 \u0441\u043e\u0431\u0440\u0430\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u043e \u043d\u0430\u0434\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0442\u0443\u0442 \u043e\u0434\u043d\u0430: <\/p>\n<ol>\n<li>\n<p>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e try catch finally<\/p>\n<\/li>\n<li>\n<p>\u0412 try \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0432 finally \u0435\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0431\u043e\u0440: \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e &#8212; \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435?<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 SqlCommand, \u0437\u0430\u0442\u0435\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 ExecuteNonQuery(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a:<\/p>\n<pre><code class=\"cs\">var sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = \"INSERT INTO Student VALUES ('TestUser', 1, '20220101')\"; var affectedRows = sqlCommand.ExecuteNonQuery(); Console.WriteLine($\"\u0427\u0438\u0441\u043b\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a: {affectedRows}\");<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u043a\u0443 1 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u043a\u0436\u0435 \u0440\u043e\u0432\u043d\u043e 1.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u0432\u0430\u0442\u044c ExecuteNonQuery(), \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c ExecuteReader(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 SqlDataReader.<\/p>\n<pre><code class=\"cs\">var sqlCommandForRead = sqlConnection.CreateCommand(); sqlCommandForRead.CommandText = \"SELECT * FROM Student\"; SqlDataReader reader = sqlCommandForRead.ExecuteReader();<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u0435\u0440\u043d\u0443\u043b \u043b\u0438 \u043e\u043d \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043b\u0438\u0431\u043e \u0441\u0442\u0440\u043e\u043a\u0438, \u0438 \u0435\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u043b, \u0442\u043e \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u044c<\/p>\n<pre><code class=\"cs\">if (reader.HasRows) {   while (reader.Read())   {     \/\/ \u041f\u0440\u0438<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-333958","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333958","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=333958"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333958\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}