{"id":415022,"date":"2024-06-30T00:06:25","date_gmt":"2024-06-30T00:06:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=415022"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=415022","title":{"rendered":"<span>\u0414\u0435\u043b\u0430\u0435\u043c \u0441\u0432\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 CRUD \u0434\u043b\u044f asp.net mvc (\u0447\u0430\u0441\u0442\u044c 1 \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/ce4\/6fd\/6a3\/ce46fd6a3f1bb3634a813b60963b9be6.jpg\" alt=\"\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u043f\u0440\u044f\u0442\u043d\u043e\u043c \u0434\u0438\u0437\u0430\u0439\u043d\u0435\" title=\"\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u043f\u0440\u044f\u0442\u043d\u043e\u043c \u0434\u0438\u0437\u0430\u0439\u043d\u0435\" width=\"768\" height=\"768\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ce4\/6fd\/6a3\/ce46fd6a3f1bb3634a813b60963b9be6.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u043f\u0440\u044f\u0442\u043d\u043e\u043c \u0434\u0438\u0437\u0430\u0439\u043d\u0435<\/figcaption><\/div>\n<\/figure>\n<h2>\u0412\u043e \u0438\u043c\u044f \u0447\u0435\u0433\u043e?<\/h2>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c CRUD \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 5 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0435\u0439 3 (\u0442\u0430\u0431\u043b\u0438\u0446\u0430 1->\u0442\u0430\u0431\u043b\u0438\u0446\u0430 2->\u0442\u0430\u0431\u043b\u0438\u0446\u0430 3).<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u044d\u0442\u043e \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433 \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0444\u043e\u0440\u0443\u043c\u0430 (users, files, themes, groups, messages). \u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u043d\u0430\u043c \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430 phphbb :). \u0418 \u0441\u043b\u044b\u0448\u0430\u0442\u044c &#171;\u041e\u0439, \u0430 \u0432\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043b\u043e\u0445\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f&#187; \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0442\u0440\u0443\u0434 \u0431\u043e\u043b\u0435\u0435 \u0434\u0432\u0443\u0445 \u0434\u043d\u0435\u0439 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 <strong>VisualStudio<\/strong> \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 CRUD \u043f\u043e <strong>EntityFramework<\/strong> \u0442\u043e\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u0431\u0435\u0441\u0441\u0438\u043b\u0435\u043d.<\/p>\n<p>\u041f\u043b\u044e\u0441, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 CRUD <strong>EasyData<\/strong>(<a href=\"https:\/\/github.com\/KorzhCom\/EasyData\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>) \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 <a href=\"https:\/\/github.com\/KorzhCom\/EasyData\/issues\/117\" rel=\"noopener noreferrer nofollow\">\u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/a>).<\/p>\n<p>(<a href=\"#IdReflexy\" rel=\"noopener noreferrer nofollow\">\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/a>)<\/p>\n<h2>\u0427\u0430\u0441\u0442\u044c 1 &#8212; \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/067\/57a\/97b\/06757a97b2124dc3b0e55a81dcf2514d.png\" alt=\"\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0437 DbContext \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b\" title=\"\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0437 DbContext \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b\" width=\"692\" height=\"407\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/067\/57a\/97b\/06757a97b2124dc3b0e55a81dcf2514d.png\"\/><\/p>\n<div><figcaption>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0437 DbContext \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>DbSetInfo.cs &#8212; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445      \/\/\/ &lt;\/summary>     internal class DbSetInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0411\u0414         \/\/\/ &lt;\/summary>         public string Name;         \/\/\/ &lt;summary>         \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0411\u0414         \/\/\/ &lt;\/summary>         public List&lt;ModelInfo> Models = new List&lt;ModelInfo>();     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>ModelInfo.cs &#8212; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\"> \/\/\/ &lt;summary>     \/\/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0411\u0414     \/\/\/ &lt;\/summary>     internal class ModelInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string ClassName;          \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string TableName         {             get             {                 if (ClassName.EndsWith(\"Model\"))                     return ClassName.Substring(0, ClassName.Length - 5);                 else                     return ClassName;             }         }          \/\/\/ &lt;summary>         \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public List&lt;ItemInfo> Items = new List&lt;ItemInfo>();          \/\/\/ &lt;summary>         \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public List&lt;SingleRelativeElementInfo> RelativeElements = new List&lt;SingleRelativeElementInfo>();     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>ItemInfo.cs &#8212; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u043b\u044f\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\"> \/\/\/ &lt;summary>     \/\/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u043b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435     \/\/\/ &lt;\/summary>     internal class ItemInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string Name { get; set; }          \/\/\/ &lt;summary>         \/\/\/ \u0422\u0438\u043f \u043f\u043e\u043b\u044f         \/\/\/ &lt;\/summary>         public eItemTypeInfo Type { get; set; }          \/\/\/ &lt;summary>         \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432         \/\/\/ &lt;\/summary>         public List&lt;ValidationAttributeInfo> ValidationAttributes { get; set; }     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>eItemTypeInfo.cs &#8212; \u0422\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u043e\u043b\u044f\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0442\u0438\u043f\u043e\u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435     \/\/\/ &lt;\/summary>     internal enum eItemTypeInfo     {         \/\/\u0421\u0442\u0440\u043e\u043a\u0430         @string,         \/\/GUID         Guid     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>ValidationAttributeInfo.cs &#8212; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u043f\u043e\u043b\u0435\u0439 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432)<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0435     \/\/\/ &lt;\/summary>     public class ValidationAttributeInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u041e\u0431\u044c\u0435\u043a\u0442 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430         \/\/\/ &lt;\/summary>         public Attribute Attribute;     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>RelativeElementInfo.cs &#8212; \u0441\u0441\u044b\u043b\u043a\u0430 1 \u043a 1 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443     \/\/\/ &lt;\/summary>     internal class SingleRelativeElementInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043f\u043e\u043b\u044f         \/\/\/ &lt;\/summary>         public string PropertyName;          \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string TableName         {             get             {                 if (@Type.Name.EndsWith(\"Model\"))                     return @Type.Name.Substring(0, @Type.Name.Length - 5);                 else                     return @Type.Name;             }         }          \/\/\/ &lt;summary>         \/\/\/ \u0422\u0438\u043f, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f         \/\/\/ &lt;\/summary>         public Type @Type;     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e, \u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044f, \u0443 \u043f\u043e\u043b\u0435\u0439 \u0435\u0441\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b. \u0415\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044f (\u0441\u0441\u044b\u043b\u043a\u0430 1 \u043a 1).<\/p>\n<h2>\u0427\u0430\u0441\u0442\u044c 2 &#8212; \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0430\u0440\u0441\u0435\u0440\u0430 <\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c1b\/407\/7f7\/c1b4077f7dc5b4242a478e512af231fa.png\" alt=\"\u0422\u0438\u043f\u044b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430, \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u043a\u043b\u0430\u0441\u0441\u044b Helper-\u044b\" title=\"\u0422\u0438\u043f\u044b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430, \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u043a\u043b\u0430\u0441\u0441\u044b Helper-\u044b\" width=\"670\" height=\"245\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c1b\/407\/7f7\/c1b4077f7dc5b4242a478e512af231fa.png\"\/><\/p>\n<div><figcaption>\u0422\u0438\u043f\u044b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430, \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u043a\u043b\u0430\u0441\u0441\u044b Helper-\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442 Helper-\u0430 \u0442\u043e\u0436\u0435 \u0437\u0430\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<details class=\"spoiler\">\n<summary>RawTableInfo.cs &#8212; \u041a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0441\u0435\u0440\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \"\u0441\u044b\u0440\u0430\u044f\" \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435     \/\/\/ &lt;\/summary>     internal class RawTableInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string ClassName;         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string TableName;         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string FieldName;         \/\/\/ &lt;summary>         \/\/\/ \u0422\u0438\u043f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public Type TableType;         \/\/\/ &lt;summary>         \/\/\/ \u0422\u0438\u043f \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public Type ModelType;     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 Extention-\u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f object, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043f\u043e\u0447\u0442\u0438 \u043b\u044e\u0431\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0438\u043f\u0435 (\u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f typeof\\GetType).<\/p>\n<details class=\"spoiler\">\n<summary>ObjectExtentions.cs &#8212; \u041c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u043b\u044f\u0445, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445, \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u0447\u0435\u0440\u0435\u0437 Extention-\u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043e\u0431\u044c\u0435\u043a\u0442\u043e\u0432     \/\/\/ &lt;\/summary>     internal static class ObjectExtentions     {         public static List&lt;PropertyInfo> GetProperties(this object obj)         {             var t = obj.GetType();              return t.GetRuntimeProperties().ToList();         }          public static List&lt;FieldInfo> GetFields(this object obj)         {             var t = obj.GetType();              return t.GetRuntimeFields().ToList();         }          public static List&lt;Attribute> GetAttributes(this object obj)         {             var t = obj.GetType();              return t.GetCustomAttributes().ToList();         }           public static List&lt;PropertyInfo> GetProperties(this Type obj)         {             return obj.GetRuntimeProperties().ToList();         }          public static List&lt;FieldInfo> GetFields(this Type obj)         {             return obj.GetRuntimeFields().ToList();         }          public static List&lt;Attribute> GetAttributes(this Type obj)         {             return obj.GetCustomAttributes().ToList();         }     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e <strong>DbContext<\/strong> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 DbSetInfo.<\/p>\n<details class=\"spoiler\">\n<summary>DbSetParser.cs &#8212; \u041f\u0430\u0440\u0441\u0435\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 DbContext<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">internal class DbSetParser     {         \/\/\/ &lt;summary>         \/\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445, \u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445 \u0438 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"dbcontext\">\u041e\u0431\u044c\u0435\u043a\u0442 \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438&lt;\/param>         \/\/\/ &lt;returns>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445&lt;\/returns>         public DbSetInfo ParseDefinition(Type dbcontextType)         {              \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u043c \u0447\u0442\u043e dbcontextType \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f DbContext             if (!typeof(DbContext).IsAssignableFrom(dbcontextType))                 throw new Exception(\"\u041d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0411\u0414\");              var tables = dbcontextType.GetTables();              var tableReferences = tables.Select(item => item.ModelType).ToList();              var res = new DbSetInfo();              foreach (var table in tables)             {                 ProcessTable(res, table, tableReferences);             }              return res;         }           \/\/\/ &lt;summary>         \/\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445, \u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445 \u0438 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"dbcontext\">\u041e\u0431\u044c\u0435\u043a\u0442 \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438&lt;\/param>         \/\/\/ &lt;returns>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445&lt;\/returns>         public DbSetInfo ParseDefinition(DbContext dbcontext)         {             var tables = dbcontext.GetTables();              var tableReferences = tables.Select(item => item.ModelType).ToList();              var res = new DbSetInfo();              foreach (var table in tables)             {                 ProcessTable(res, table, tableReferences);             }              return res;         }          \/\/\/ &lt;summary>         \/\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044f\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u0418\u043c\u044f, \u0442\u0438\u043f - \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u043e\u043b\u0435\u0439)         \/\/\/ \u0422\u0438\u043f - \u0434\u043b\u044f \u0441\u0441\u044b\u043b\u043e\u043a         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"res\">\u041e\u0431\u044c\u0435\u043a\u0442 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0430&lt;\/param>         \/\/\/ &lt;param name=\"table\">\u041f\u043e\u043b\u0435 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443&lt;\/param>         \/\/\/ &lt;param name=\"tableReferences\">\u0421\u043f\u0438\u0441\u043e\u043a \u0442\u0438\u043f\u043e\u0432 \u0441 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438&lt;\/param>         private void ProcessTable(DbSetInfo res, RawTableInfo table, List&lt;Type> tableReferences)         {              var model = new ModelInfo()             {                 ClassName = table.ModelType.Name             };              processDataFields(model, table, tableReferences);              process1to1References(model, table, tableReferences);              res.Models.Add(model);         }          \/\/\/ &lt;summary>         \/\/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0441\u044b\u043b\u043a\u0430\u0445 1 \u043a 1 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 table         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"model\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b&lt;\/param>         \/\/\/ &lt;param name=\"table\">\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430&lt;\/param>         \/\/\/ &lt;param name=\"tableReferences\">\u041e\u0431\u044c\u0435\u043a\u0442\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446&lt;\/param>         private void process1to1References(ModelInfo model, RawTableInfo table, List&lt;Type> tableReferences)         {             var relFields = table.GetReferenceFields(tableReferences);              model.RelativeElements = relFields.Select(item =>             new SingleRelativeElementInfo()             {                 PropertyName = item.Name,                 Type = item.PropertyType             })                 .ToList();         }          \/\/\/ &lt;summary>         \/\/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044f\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 table         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"model\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b&lt;\/param>         \/\/\/ &lt;param name=\"table\">\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430&lt;\/param>         \/\/\/ &lt;param name=\"tableReferences\">\u041e\u0431\u044c\u0435\u043a\u0442\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446&lt;\/param>         private void processDataFields(ModelInfo model, RawTableInfo table, List&lt;Type> tableReferences)         {             var dataFields = table.GetDataFields(tableReferences);              model.Items = dataFields.Select(item =>             new ItemInfo()             {                 Name = item.Name,                 @Type = Enum.Parse&lt;eItemTypeInfo>(item.PropertyType.Name, true),                 ValidationAttributes = item.GetCustomAttributes().Select(item2 => new ValidationAttributeInfo()                 {                     Attribute = item2                 }).ToList()             }             )                 .ToList();         }     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p><a class=\"anchor\" name=\"IdReflexy\" id=\"IdReflexy\"><\/a><\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c (\u043a\u0440\u043e\u043c\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 GetRuntimeFields() GetRuntimeProperties()) \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f 3 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<ol>\n<li>\n<p>\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <strong>is\/as<\/strong><\/p>\n<p>\u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>IsAssignableFrom()<\/strong>. \u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 <strong>true<\/strong> \u0435\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a<strong> <\/strong>\u0431\u0430\u0437\u043e\u0432\u043e\u043c\u0443 \u0442\u0438\u043f\u0443.<\/p>\n<p><code>typeof(baseClassType).IsAssignableFrom(DerivedClassType)<\/code><\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0447\u0442\u043e <strong>\u0442\u0438\u043f \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d \u043e\u0442 Generic<\/strong>-\u0430<\/p>\n<p>\u0422\u043e\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u043a <strong>GetGenericTypeDefinition()<\/strong>. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 true \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 <strong>DbSet&lt;T><\/strong>.<\/p>\n<p><code>item.PropertyType.GetGenericTypeDefinition() != typeof(DbSet&lt;object>).GetGenericTypeDefinition()<\/code><\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <strong>\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b Generic \u0442\u0438\u043f\u043e\u0432 (string \u0438\u0437 List&lt;string>)<\/strong><\/p>\n<p>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f <strong>GenericTypeArguments <\/strong>\u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u0442\u0438\u043f\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/p>\n<p>GenericTypeArguments[0] &#8212; \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 DbSet<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0443 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0441\u0430\u043c DbSetParser. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0432\u0441\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0438\u043b\u0435 SOLID \u0438 \u043c\u043d\u0435 \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 1 \u043a N \u043b\u0438\u0431\u043e \u043d\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u043f\u043e\u043b\u044f \u0432 ModelInfo \u0438 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 process1toNReferences \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043a\u043e\u0434\u0430.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a, \u0437\u0430 \u0447\u0430\u0441-\u0434\u0432\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044e \u043f\u043e\u0447\u0442\u0438 \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0411\u0414, \u0438\u0445 \u043f\u043e\u043b\u044f\u0445, \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u043f\u043e\u043b\u0435\u0439, \u0441\u0432\u044f\u0437\u044f\u0445 \u0438 \u0432\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c.<\/p>\n<p>\u0410\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 cshtml.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0447\u0435\u043c \u043f\u043e\u0445\u043e\u0436\u0438 \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u043d\u0430 \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0430\u0440\u0443 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 (Controller\/CrudViews (Index, Add, Edit, Delete).<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/734520\/\"> https:\/\/habr.com\/ru\/articles\/734520\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\">\n<div><figcaption>\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u043f\u0440\u044f\u0442\u043d\u043e\u043c \u0434\u0438\u0437\u0430\u0439\u043d\u0435<\/figcaption><\/div>\n<\/figure>\n<h2>\u0412\u043e \u0438\u043c\u044f \u0447\u0435\u0433\u043e?<\/h2>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c CRUD \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 5 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0435\u0439 3 (\u0442\u0430\u0431\u043b\u0438\u0446\u0430 1->\u0442\u0430\u0431\u043b\u0438\u0446\u0430 2->\u0442\u0430\u0431\u043b\u0438\u0446\u0430 3).<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u044d\u0442\u043e \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433 \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0444\u043e\u0440\u0443\u043c\u0430 (users, files, themes, groups, messages). \u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u043d\u0430\u043c \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430 phphbb :). \u0418 \u0441\u043b\u044b\u0448\u0430\u0442\u044c &#171;\u041e\u0439, \u0430 \u0432\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043b\u043e\u0445\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f&#187; \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0442\u0440\u0443\u0434 \u0431\u043e\u043b\u0435\u0435 \u0434\u0432\u0443\u0445 \u0434\u043d\u0435\u0439 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 <strong>VisualStudio<\/strong> \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 CRUD \u043f\u043e <strong>EntityFramework<\/strong> \u0442\u043e\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u0431\u0435\u0441\u0441\u0438\u043b\u0435\u043d.<\/p>\n<p>\u041f\u043b\u044e\u0441, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 CRUD <strong>EasyData<\/strong>(<a href=\"https:\/\/github.com\/KorzhCom\/EasyData\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>) \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 <a href=\"https:\/\/github.com\/KorzhCom\/EasyData\/issues\/117\" rel=\"noopener noreferrer nofollow\">\u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/a>).<\/p>\n<p>(<a href=\"#IdReflexy\" rel=\"noopener noreferrer nofollow\">\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/a>)<\/p>\n<h2>\u0427\u0430\u0441\u0442\u044c 1 &#8212; \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0438\u0437 DbContext \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>DbSetInfo.cs &#8212; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445      \/\/\/ &lt;\/summary>     internal class DbSetInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0411\u0414         \/\/\/ &lt;\/summary>         public string Name;         \/\/\/ &lt;summary>         \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0411\u0414         \/\/\/ &lt;\/summary>         public List&lt;ModelInfo> Models = new List&lt;ModelInfo>();     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>ModelInfo.cs &#8212; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\"> \/\/\/ &lt;summary>     \/\/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0411\u0414     \/\/\/ &lt;\/summary>     internal class ModelInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string ClassName;          \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string TableName         {             get             {                 if (ClassName.EndsWith(\"Model\"))                     return ClassName.Substring(0, ClassName.Length - 5);                 else                     return ClassName;             }         }          \/\/\/ &lt;summary>         \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public List&lt;ItemInfo> Items = new List&lt;ItemInfo>();          \/\/\/ &lt;summary>         \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public List&lt;SingleRelativeElementInfo> RelativeElements = new List&lt;SingleRelativeElementInfo>();     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>ItemInfo.cs &#8212; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u043b\u044f\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\"> \/\/\/ &lt;summary>     \/\/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u043b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435     \/\/\/ &lt;\/summary>     internal class ItemInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043f\u043e\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string Name { get; set; }          \/\/\/ &lt;summary>         \/\/\/ \u0422\u0438\u043f \u043f\u043e\u043b\u044f         \/\/\/ &lt;\/summary>         public eItemTypeInfo Type { get; set; }          \/\/\/ &lt;summary>         \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432         \/\/\/ &lt;\/summary>         public List&lt;ValidationAttributeInfo> ValidationAttributes { get; set; }     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>eItemTypeInfo.cs &#8212; \u0422\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u043e\u043b\u044f\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0442\u0438\u043f\u043e\u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435     \/\/\/ &lt;\/summary>     internal enum eItemTypeInfo     {         \/\/\u0421\u0442\u0440\u043e\u043a\u0430         @string,         \/\/GUID         Guid     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>ValidationAttributeInfo.cs &#8212; \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u043f\u043e\u043b\u0435\u0439 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432)<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0435     \/\/\/ &lt;\/summary>     public class ValidationAttributeInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u041e\u0431\u044c\u0435\u043a\u0442 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430         \/\/\/ &lt;\/summary>         public Attribute Attribute;     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>RelativeElementInfo.cs &#8212; \u0441\u0441\u044b\u043b\u043a\u0430 1 \u043a 1 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443     \/\/\/ &lt;\/summary>     internal class SingleRelativeElementInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043f\u043e\u043b\u044f         \/\/\/ &lt;\/summary>         public string PropertyName;          \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string TableName         {             get             {                 if (@Type.Name.EndsWith(\"Model\"))                     return @Type.Name.Substring(0, @Type.Name.Length - 5);                 else                     return @Type.Name;             }         }          \/\/\/ &lt;summary>         \/\/\/ \u0422\u0438\u043f, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f         \/\/\/ &lt;\/summary>         public Type @Type;     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e, \u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044f, \u0443 \u043f\u043e\u043b\u0435\u0439 \u0435\u0441\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b. \u0415\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044f (\u0441\u0441\u044b\u043b\u043a\u0430 1 \u043a 1).<\/p>\n<h2>\u0427\u0430\u0441\u0442\u044c 2 &#8212; \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0430\u0440\u0441\u0435\u0440\u0430 <\/h2>\n<figure class=\"full-width\">\n<div><figcaption>\u0422\u0438\u043f\u044b \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430, \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u043a\u043b\u0430\u0441\u0441\u044b Helper-\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442 Helper-\u0430 \u0442\u043e\u0436\u0435 \u0437\u0430\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<details class=\"spoiler\">\n<summary>RawTableInfo.cs &#8212; \u041a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0441\u0435\u0440\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \"\u0441\u044b\u0440\u0430\u044f\" \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435     \/\/\/ &lt;\/summary>     internal class RawTableInfo     {         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string ClassName;         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string TableName;         \/\/\/ &lt;summary>         \/\/\/ \u0418\u043c\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public string FieldName;         \/\/\/ &lt;summary>         \/\/\/ \u0422\u0438\u043f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public Type TableType;         \/\/\/ &lt;summary>         \/\/\/ \u0422\u0438\u043f \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b         \/\/\/ &lt;\/summary>         public Type ModelType;     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 Extention-\u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f object, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043f\u043e\u0447\u0442\u0438 \u043b\u044e\u0431\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0438\u043f\u0435 (\u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f typeof\\GetType).<\/p>\n<details class=\"spoiler\">\n<summary>ObjectExtentions.cs &#8212; \u041c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">    \/\/\/ &lt;summary>     \/\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u043b\u044f\u0445, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445, \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u0447\u0435\u0440\u0435\u0437 Extention-\u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043e\u0431\u044c\u0435\u043a\u0442\u043e\u0432     \/\/\/ &lt;\/summary>     internal static class ObjectExtentions     {         public static List&lt;PropertyInfo> GetProperties(this object obj)         {             var t = obj.GetType();              return t.GetRuntimeProperties().ToList();         }          public static List&lt;FieldInfo> GetFields(this object obj)         {             var t = obj.GetType();              return t.GetRuntimeFields().ToList();         }          public static List&lt;Attribute> GetAttributes(this object obj)         {             var t = obj.GetType();              return t.GetCustomAttributes().ToList();         }           public static List&lt;PropertyInfo> GetProperties(this Type obj)         {             return obj.GetRuntimeProperties().ToList();         }          public static List&lt;FieldInfo> GetFields(this Type obj)         {             return obj.GetRuntimeFields().ToList();         }          public static List&lt;Attribute> GetAttributes(this Type obj)         {             return obj.GetCustomAttributes().ToList();         }     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e <strong>DbContext<\/strong> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 DbSetInfo.<\/p>\n<details class=\"spoiler\">\n<summary>DbSetParser.cs &#8212; \u041f\u0430\u0440\u0441\u0435\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 DbContext<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">internal class DbSetParser     {         \/\/\/ &lt;summary>         \/\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445, \u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445 \u0438 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"dbcontext\">\u041e\u0431\u044c\u0435\u043a\u0442 \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438&lt;\/param>         \/\/\/ &lt;returns>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445&lt;\/returns>         public DbSetInfo ParseDefinition(Type dbcontextType)         {              \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u043c \u0447\u0442\u043e dbcontextType \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f DbContext             if (!typeof(DbContext).IsAssignableFrom(dbcontextType))                 throw new Exception(\"\u041d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0411\u0414\");              var tables = dbcontextType.GetTables();              var tableReferences = tables.Select(item => item.ModelType).ToList();              var res = new DbSetInfo();              foreach (var table in tables)             {                 ProcessTable(res, table, tableReferences);             }              return res;         }           \/\/\/ &lt;summary>         \/\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445, \u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445 \u0438 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"dbcontext\">\u041e\u0431\u044c\u0435\u043a\u0442 \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438&lt;\/param>         \/\/\/ &lt;returns>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445&lt;\/returns>         public DbSetInfo ParseDefinition(DbContext dbcontext)         {             var tables = dbcontext.GetTables();              var tableReferences = tables.Select(item => item.ModelType).ToList();              var res = new DbSetInfo();              foreach (var table in tables)             {                 ProcessTable(res, table, tableReferences);             }              return res;         }          \/\/\/ &lt;summary>         \/\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044f\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u0418\u043c\u044f, \u0442\u0438\u043f - \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u043e\u043b\u0435\u0439)         \/\/\/ \u0422\u0438\u043f - \u0434\u043b\u044f \u0441\u0441\u044b\u043b\u043e\u043a         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"res\">\u041e\u0431\u044c\u0435\u043a\u0442 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0430&lt;\/param>         \/\/\/ &lt;param name=\"table\">\u041f\u043e\u043b\u0435 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443&lt;\/param>         \/\/\/ &lt;param name=\"tableReferences\">\u0421\u043f\u0438\u0441\u043e\u043a \u0442\u0438\u043f\u043e\u0432 \u0441 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438&lt;\/param>         private void ProcessTable(DbSetInfo res, RawTableInfo table, List&lt;Type> tableReferences)         {              var model = new ModelInfo()             {                 ClassName = table.ModelType.Name             };              processDataFields(model, table, tableReferences);              process1to1References(model, table, tableReferences);              res.Models.Add(model);         }          \/\/\/ &lt;summary>         \/\/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0441\u044b\u043b\u043a\u0430\u0445 1 \u043a 1 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 table         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"model\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b&lt;\/param>         \/\/\/ &lt;param name=\"table\">\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430&lt;\/param>         \/\/\/ &lt;param name=\"tableReferences\">\u041e\u0431\u044c\u0435\u043a\u0442\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446&lt;\/param>         private void process1to1References(ModelInfo model, RawTableInfo table, List&lt;Type> tableReferences)         {             var relFields = table.GetReferenceFields(tableReferences);              model.RelativeElements = relFields.Select(item =>             new SingleRelativeElementInfo()             {                 PropertyName = item.Name,                 Type = item.PropertyType             })                 .ToList();         }          \/\/\/ &lt;summary>         \/\/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044f\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 table         \/\/\/ &lt;\/summary>         \/\/\/ &lt;param name=\"model\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b&lt;\/param>         \/\/\/ &lt;param name=\"table\">\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430&lt;\/param>         \/\/\/ &lt;param<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-415022","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415022","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=415022"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415022\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=415022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=415022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=415022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}