{"id":174531,"date":"2013-03-28T11:19:04","date_gmt":"2013-03-28T07:19:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=174531"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=174531","title":{"rendered":"<span class=\"post_title\">ASP.NET MVC 4 RAZOR \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0435 \u043c\u0435\u043d\u044e \u0438\u0437 \u0411\u0414<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/174455\/\">DropDownList, \u0417\u0430\u0434\u0430\u0442\u044c \u00abvalue\u00bb \u0434\u043b\u044f default option \u0432 MVC 4<\/a>, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0433\u043e \u043c\u0435\u043d\u044e \u0441 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0435\u0441\u044f \u0432 \u0411\u0414 MsSQL. \u041f\u043e\u043c\u043d\u044e \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u041f\u0425\u041f \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0430\u0447\u043a\u043e\u0439 \u043d\u0430 \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439. \u041d\u043e \u0434\u043b\u044f MVC 4 \u0441 \u0434\u0432\u0438\u0436\u043a\u043e\u043c RAZOR \u2014 \u0435\u043b\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f, \u0445\u043e\u0442\u044f \u0432 \u0438\u0442\u043e\u0433\u0435 \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u0441\u0432\u0435\u0440\u0445\u044a\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<p>  \u0421\u0435\u0439 \u043c\u0430\u043d\u0443\u0430\u043b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0412\u044b \u0443\u0436\u0435 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u0438 \u0441 \u044d\u0442\u0438\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u044f\u043c\u0438: <a href=\"http:\/\/habrahabr.ru\/post\/136155\/\">Entity Framework \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 ASP.NET MVC<\/a>. \u0418\u043b\u0438 \u044d\u0442\u0438\u043c\u0438: <a href=\"http:\/\/www.asp.net\/mvc\/tutorials\">ASP.NET MVC 4 Tutorials<\/a><\/p>\n<p>  1) \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0411\u0414. \u042d\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435. \u0421 \u0442\u0435\u043e\u0440\u0438\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"http:\/\/www.rsdn.ru\/article\/db\/Hierarchy.xml\">\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0411\u0414<\/a>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u00ab\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u043f\u0440\u0435\u0434\u043a\u0430\u00bb.<br \/>  <a name=\"habracut\"><\/a><br \/>  SQL \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0430\u043a \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"sql\">CREATE TABLE &quot;CATALOG&quot; (   &quot;ID&quot; INTEGER NOT NULL PRIMARY KEY,   &quot;NAME&quot; VARCHAR(200) CHARACTER SET WIN1251 NOT NULL,   &quot;PARENT_ID&quot; INTEGER ); <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 VS 2012:  <\/p>\n<pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web;  namespace zf2.Models {     public class NewsM     {         public int NewsMID { get; set; }         public int ParentID { get; set; }         public string Title { get; set; }         public string AddTitle { get; set; }         public string Description { get; set; }         public string Content { get; set; }         public DateTime ModDate { get; set; }     } } <\/code><\/pre>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u043f\u043e\u043b\u044f. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u044f \u043f\u0440\u0438\u0432\u0435\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0443 \u043c\u0435\u043d\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435.<\/p>\n<p>  2) \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440.   <\/p>\n<pre><code>        public ActionResult NewsA(int id = 1) \/\/id \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f         {             ViewBag.Menu = db.NewsMs.ToList(); \/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0435\u043d\u044e.             ViewBag.Id = id;              return View();         } <\/code><\/pre>\n<p>  3) Partial Views (\u0427\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432\u0438\u0434\u0430)<br \/>  \u0415\u0441\u043b\u0438 \u0412\u044b \u0441 \u043d\u0438\u043c\u0438 \u0435\u0449\u0435 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u2014 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e. \u041e\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043e\u043d\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u042d\u0442\u043e \u0432\u044c\u044e\u0448\u043a\u0438 \u0434\u043b\u044f \u0432\u044c\u044e\u0448\u0435\u043a \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c.<\/p>\n<p>  \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043e\u0447\u043a\u0443 Views-Shared-\u041f\u0440\u0430\u0432\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 \u043c\u044b\u0448\u0438-\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c-\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435: \u0441\u0442\u0430\u0432\u0438\u043c \u0433\u0430\u043b\u043e\u0447\u043a\u0443 \u00ab\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u00bb. \u0412\u0432\u043e\u0434\u0438\u043c \u0438\u043c\u044f &quot;_Menu&quot;. \u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0438\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435? \u0414\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u0438\u043c\u0435\u043d. \u0422\u0430\u043a \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438\u0449\u0443\u0442\u0441\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0445 \u0432\u0438\u0434\u0430 Shared \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438. \u0412\u043e\u0442 \u0447\u0442\u043e \u0432\u044b\u0434\u0430\u0435\u0442 \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430:  <\/p>\n<pre><code>\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 &quot;_gMenu&quot; \u0438\u043b\u0438 \u043d\u0438 \u043e\u0434\u0438\u043d \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u0430 \u043f\u043e\u0438\u0441\u043a\u0430. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445: ~\/Views\/Home\/_gMenu.aspx ~\/Views\/Home\/_gMenu.ascx ~\/Views\/Shared\/_gMenu.aspx ~\/Views\/Shared\/_gMenu.ascx ~\/Views\/Home\/_gMenu.cshtml ~\/Views\/Home\/_gMenu.vbhtml ~\/Views\/Shared\/_gMenu.cshtml ~\/Views\/Shared\/_gMenu.vbhtml <\/code><\/pre>\n<p>  \u0414\u0443\u043c\u0430\u044e \u043f\u043e\u043d\u044f\u0442\u043d\u043e.<br \/>  \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<br \/>  \u0412 &quot;_Menu.cshtml&quot; \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:   <\/p>\n<pre><code>@{     List&lt;zf2.Models.NewsM&gt; menuList = ViewBag.Menu; }  &lt;ul class=&quot;menu&quot;&gt;        @foreach (var mp in menuList.Where(p =&gt; p.ParentID == 0)){      &lt;li&gt;         @Html.ActionLink(mp.Title, ViewContext.RouteData.GetRequiredString(&quot;action&quot;), new { id=mp.NewsMID })         @if( menuList.Count(p=&gt;p.ParentID == mp.NewsMID ) &gt; 0){             @:&lt;ul&gt;         }                    @RenderMenuItem(menuList,mp)                 @if( menuList.Count(p=&gt;p.ParentID == mp.NewsMID ) &gt; 0){             @:&lt;\/ul&gt;         }          &lt;\/li&gt; } &lt;\/ul&gt;   @helper RenderMenuItem(List&lt;zf2.Models.NewsM&gt; menuList, zf2.Models.NewsM mi) {     foreach (var cp in menuList.Where(p =&gt; p.ParentID == mi.NewsMID))     {                         @:&lt;li&gt;                  @Html.ActionLink(cp.Title, ViewContext.RouteData.GetRequiredString(&quot;action&quot;), new { id=cp.NewsMID })            if(menuList.Count(p=&gt;p.ParentID == cp.NewsMID) &gt; 0)         {            @:&lt;ul&gt;           }                  @RenderMenuItem(menuList,cp)        if(menuList.Count(p=&gt;p.ParentID == cp.NewsMID) &gt; 0)       {           @:&lt;\/ul&gt;       }       else       {           @:&lt;\/li&gt;       }     } } <\/code><\/pre>\n<p>   \u0422\u0443\u0442 \u0438 \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432\u0441\u044f \u043c\u0430\u0433\u0438\u044f. <\/p>\n<p>  <code>@foreach (var mp in menuList.Where(p =&gt; p.ParentID == 0))<\/code> \u2014 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u0430 \u0441 ParentID = 0.<\/p>\n<p>  <code>@RenderMenuItem(menuList,mp)<\/code> \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0430 \u0432\u0438\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0434\u043e\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u00ab\u0440\u0443\u0442\u043e\u0432\u0441\u043a\u043e\u0433\u043e\u00bb \u043f\u0443\u043d\u043a\u0442\u0430.<\/p>\n<p>  <code>@helper RenderMenuItem(List&lt;zf2.Models.NewsM&gt; menuList, zf2.Models.NewsM mi)<\/code> \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0441\u0430\u043c \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a \u0432\u0438\u0434\u0430, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f.<\/p>\n<p>  <code>@Html.ActionLink(mp.Title, ViewContext.RouteData.GetRequiredString(&quot;action&quot;), new { id=mp.NewsMID })<\/code> \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438. \u0423 \u043c\u0435\u043d\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f.\u0418\u043c\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0418\u043c\u044f \u044d\u043a\u0448\u0435\u043d\u0430 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 Id \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u00ab\u0432\u0440\u0443\u0447\u043d\u0443\u044e\u00bb. <br \/>  \u0422\u043e\u0435\u0441\u0442\u044c <code>ViewContext.RouteData.GetRequiredString(&quot;action&quot;)<\/code> \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043c\u044f \u044d\u043a\u0448\u0435\u043d\u0430. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<br \/>  <code>new { id=mp.NewsMID }<\/code> \u2014 \u0437\u0430\u0434\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 Id.<br \/>  <code>mp.Title<\/code> \u2014 \u0418\u043c\u044f \u0441\u0441\u044b\u043b\u043a\u0438<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0427\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0438\u0434\u0430 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c &quot;_Content&quot;. <br \/>  \u0412 \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u043c\u0443 Id.<br \/>  \u041a\u043e\u0434 \u0442\u0430\u043a\u043e\u0439:  <\/p>\n<pre><code>@{     List&lt;zf2.Models.NewsM&gt; menuList = ViewBag.Menu; } @ViewBag.Id @foreach (var mp in menuList.Where(p =&gt; p.NewsMID == ViewBag.Id)) {     @mp.Content     @mp.AddTitle     @mp.Description } <\/code><\/pre>\n<p>  4) \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0438\u0434\u0430. \u0423 \u043c\u0435\u043d\u044f \u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0438 \u0438\u043c\u044f \u044d\u043a\u0448\u0435\u043d\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u2014 NewsA.cshtml<br \/>  \u0412 \u043d\u0435\u043c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432\u0438\u0434\u0430 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a.  <\/p>\n<pre><code>@{     ViewBag.Title = &quot;NewsA&quot;; } @{     List&lt;zf2.Models.NewsM&gt; menuList = ViewBag.Menu; }  &lt;div class=&quot;row&quot;&gt;   &lt;div class=&quot;span3&quot;style=&quot;background-color: #e6e6e6;&quot;&gt;       @Html.Partial(&quot;_Menu&quot;)   &lt;\/div&gt;   &lt;div class=&quot;span6&quot; style=&quot;background-color: #e6e6e6;&quot;&gt;       @Html.Partial(&quot;_Content&quot;)   &lt;\/div&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  <code>&lt;div class=&quot;row&quot;&gt;, &lt;div class=&quot;span3&quot;style=&quot;background-color: #e6e6e6;&quot;&gt;<\/code> \u2014 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Bootstrap \u2014 \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f CSS \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"http:\/\/twitter.github.com\/bootstrap\/\">\u0442\u0443\u0442<\/a>: <\/p>\n<p>  \u0412\u0441\u0435. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c. \u0418 \u0432\u0438\u0434\u0438\u043c \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<br \/>  <img decoding=\"async\" src=\"http:\/\/i.piccy.info\/i7\/4c0ba34d752bff4c7ce9e4aa3bcd4afc\/4-57-418\/45030254\/Bezymiannyi.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0421:<br \/>  \u041d\u0443\u0436\u043d\u043e \u0435\u0449\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e.<br \/>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414<br \/>  \u041a\u043b\u0430\u0441\u0441 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Entity Framework<br \/>  \u0418 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<br \/>  \u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u043f\u0443\u043d\u043a\u0442\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043c\u0430\u043d\u0443\u0430\u043b\u0430\u0445, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<br \/>  \u041a\u043e\u0434 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:  <\/p>\n<pre><code>using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using System.Web; using zf2.Models;  namespace zf2.DAL {     public class ZfInitializer : DropCreateDatabaseIfModelChanges&lt;ZfContext&gt;     {         protected override void Seed(ZfContext context)         {             var newsMs = new List&lt;NewsM&gt;             {                 new NewsM { NewsMID = 1, ParentID = 0, Title = &quot;Carson&quot;, AddTitle = &quot;Carson&quot;, Description = &quot;Carson&quot;, Content = &quot;Carson&quot; , ModDate = DateTime.Parse(&quot;2005-09-01&quot;) },                 new NewsM { NewsMID = 2, ParentID = 0, Title = &quot;Carson&quot;, AddTitle = &quot;Carson&quot;, Description = &quot;Carson&quot;, Content = &quot;Carson&quot; , ModDate = DateTime.Parse(&quot;2005-09-01&quot;) },                 new NewsM { NewsMID = 3, ParentID = 1, Title = &quot;Carson&quot;, AddTitle = &quot;Carson&quot;, Description = &quot;Carson&quot;, Content = &quot;Carson&quot; , ModDate = DateTime.Parse(&quot;2005-09-01&quot;) },                 new NewsM { NewsMID = 4, ParentID = 1, Title = &quot;Carson&quot;, AddTitle = &quot;Carson&quot;, Description = &quot;Carson&quot;, Content = &quot;Carson&quot; , ModDate = DateTime.Parse(&quot;2005-09-01&quot;) },                 new NewsM { NewsMID = 5, ParentID = 2, Title = &quot;Carson&quot;, AddTitle = &quot;Carson&quot;, Description = &quot;Carson&quot;, Content = &quot;Carson&quot; , ModDate = DateTime.Parse(&quot;2005-09-01&quot;) },                 new NewsM { NewsMID = 6, ParentID = 3, Title = &quot;Carson&quot;, AddTitle = &quot;Carson&quot;, Description = &quot;Carson&quot;, Content = &quot;Carson&quot; , ModDate = DateTime.Parse(&quot;2005-09-01&quot;) },                 new NewsM { NewsMID = 7, ParentID = 2, Title = &quot;Carson&quot;, AddTitle = &quot;Carson&quot;, Description = &quot;Carson&quot;, Content = &quot;Carson&quot; , ModDate = DateTime.Parse(&quot;2005-09-01&quot;) },             };             newsMs.ForEach(s =&gt; context.NewsMs.Add(s));             context.SaveChanges();         }     } } <\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f\u2026    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/174531\/\"> http:\/\/habrahabr.ru\/post\/174531\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/174455\/\">DropDownList, \u0417\u0430\u0434\u0430\u0442\u044c \u00abvalue\u00bb \u0434\u043b\u044f default option \u0432 MVC 4<\/a>, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0433\u043e \u043c\u0435\u043d\u044e \u0441 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0435\u0441\u044f \u0432 \u0411\u0414 MsSQL. \u041f\u043e\u043c\u043d\u044e \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u041f\u0425\u041f \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0430\u0447\u043a\u043e\u0439 \u043d\u0430 \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439. \u041d\u043e \u0434\u043b\u044f MVC 4 \u0441 \u0434\u0432\u0438\u0436\u043a\u043e\u043c RAZOR \u2014 \u0435\u043b\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f, \u0445\u043e\u0442\u044f \u0432 \u0438\u0442\u043e\u0433\u0435 \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u0441\u0432\u0435\u0440\u0445\u044a\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<p>  \u0421\u0435\u0439 \u043c\u0430\u043d\u0443\u0430\u043b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0412\u044b \u0443\u0436\u0435 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u0438 \u0441 \u044d\u0442\u0438\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u044f\u043c\u0438: <a href=\"http:\/\/habrahabr.ru\/post\/136155\/\">Entity Framework \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 ASP.NET MVC<\/a>. \u0418\u043b\u0438 \u044d\u0442\u0438\u043c\u0438: <a href=\"http:\/\/www.asp.net\/mvc\/tutorials\">ASP.NET MVC 4 Tutorials<\/a><\/p>\n<p>  1) \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0411\u0414. \u042d\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435. \u0421 \u0442\u0435\u043e\u0440\u0438\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"http:\/\/www.rsdn.ru\/article\/db\/Hierarchy.xml\">\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0411\u0414<\/a>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u00ab\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u043f\u0440\u0435\u0434\u043a\u0430\u00bb.  <\/p>\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-174531","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/174531","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=174531"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/174531\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=174531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=174531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=174531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}