{"id":263926,"date":"2015-08-20T09:00:02","date_gmt":"2015-08-20T05:00:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=263926"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=263926","title":{"rendered":"\u0427\u0430\u0441\u0442\u044c 3. \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f LIST)"},"content":{"rendered":"<p>     \t\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438.<br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/264907\/\"><i>\u0423\u0440\u043e\u043a\u0438 \u043f\u043e FluentNHibernate c ASP.NET MVC \u0438 SQL Server. \u0427\u0430\u0441\u0442\u044c 1<\/i><\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/264961\/\"><i>\u0427\u0430\u0441\u0442\u044c 2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u0432 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0411\u0414<\/i><\/a><\/p>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433-\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a \u043d\u0438\u043c. \u0412 3 \u043a\u0440\u0430\u0442\u043a\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0438 \u0441\u0432\u044f\u0437\u0435\u0439 \u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443, \u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c, \u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c. \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 sql server&#8217;e \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0411\u0414 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 View. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. <br \/>  <a name=\"habracut\"><\/a><br \/>  <b>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/b><br \/>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 Content \u043f\u0430\u043f\u043a\u0443 img.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4cf\/9b2\/47c\/4cf9b247cb4d4ff5a11a846fcf8dad40.png\"\/><\/p>\n<p>  \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0443\u0434\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043e\u0431\u043b\u043e\u0436\u043a\u0438 \u044d\u0442\u0438\u0445 \u043a\u043d\u0438\u0433. <br \/>  <a href=\"https:\/\/yadi.sk\/a\/OZVgEhJ1iXukT\">yadi.sk\/a\/OZVgEhJ1iXukT<\/a><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u043b <b>\u0432\u0441\u0435 <\/b>\u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043d\u0438\u0433\u043e\u0439.  <\/p>\n<pre><code> public ActionResult Index() {        using (ISession session = NHibernateHelper.OpenSession()) {              \/\/var book = session.Query&lt;Book&gt;().ToList(); \/\/\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Book              \/\/\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043a\u043d\u0438\u0433              var criteria = session.CreateCriteria&lt;Book&gt;();              \/\/Left Join \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 Genres               criteria.CreateAlias(&quot;Genres&quot;, &quot;genre&quot;, JoinType.LeftOuterJoin);              criteria.CreateAlias(&quot;Series&quot;, &quot;series&quot;, JoinType.LeftOuterJoin);              criteria.CreateAlias(&quot;Mind&quot;, &quot;mind&quot;, JoinType.LeftOuterJoin);              criteria.CreateAlias(&quot;Authors&quot;, &quot;author&quot;, JoinType.LeftOuterJoin);              \/\/\u0423\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f id \u043d\u043e\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b Book.              criteria.SetResultTransformer(new DistinctRootEntityResultTransformer());             \/\/\u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u043a \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 list&lt;Book&gt;              var books = criteria.List&lt;Book&gt;();              return View(books);        } } <\/code><\/pre>\n<p>  <b>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/b>  <\/p>\n<ol>\n<li><i>var criteria = session.CreateCriteria&lt;Book&gt;(); <\/i> \u2014 \u043f\u043e\u0434\u043e\u0431\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 SQL: <i>Select * From Book<\/i>;<\/li>\n<li><i>criteria.CreateAlias(\u00abGenres\u00bb, \u00abgenre\u00bb, JoinType.LeftOuterJoin); <\/i> \u2014 \u043f\u043e\u0434\u043e\u0431\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 SQL:<br \/>   <i>SELECT *FROM Book<br \/>   inner JOIN Book_Genre ON book.id = Book_Genre.Book_id<br \/>   LEFT JOIN Genre ON Book_Genre.Genre_id = Genre.id<\/i><\/li>\n<li><i>criteria.SetResultTransformer(new DistinctRootEntityResultTransformer());<\/i> \u2014 \u041f\u043e\u0434\u043e\u0431\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 SQL: <i>SELECT distinct Book.Id&#8230;<\/i>, (\u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 id)<\/li>\n<\/ol>\n<p>  <i>criteria.CreateAlias(\u00abGenres\u00bb, \u00abgenre\u00bb, JoinType.LeftOuterJoin); <\/i> \u2014 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <b>\u00abGenres\u00bb<\/b> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Book: public virtual ISet&lt;Genre&gt; <b>Genres<\/b>{ get; set; }.<br \/>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u00abgenre\u00bb \u2014 \u044d\u0442\u043e \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u0445.<\/p>\n<p>  <b>\u0412\u0438\u0434\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439<\/b><br \/>  <i>criteria.CreateAlias(\u00abGenres\u00bb, \u00abgenre\u00bb, JoinType.LeftOuterJoin); <\/i>  <\/p>\n<ol>\n<li>LeftOuterJoin \u2014 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u043b\u0435\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (<b>Book<\/b>), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043a \u043d\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (<b>Genre<\/b>). \u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0435\u0451 \u043a\u0430\u043a Null<\/li>\n<li>RightOuterJoin \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c LEFT JOIN \u2014 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (<b>Genre<\/b>), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043a \u043d\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u043b\u0435\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (<b>Book<\/b>)<\/li>\n<li>InnerJoin \u2014 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u043b\u0435\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446 (<b>Book<\/b>) \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0437 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (<b>Genre<\/b>), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043a \u043d\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/li>\n<\/ol>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 <i>Index.cshtml<\/i> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"html\"> @model IEnumerable&lt;BibliotecaTutor.Models.Book&gt; @{    Layout = null; } &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot; \/&gt;       &lt;title&gt;Index&lt;\/title&gt;        &lt;style&gt; th,td {border: 1px solid; } &lt;\/style&gt; &lt;\/head&gt; &lt;body&gt;     &lt;p&gt;@Html.ActionLink(&quot;Create New&quot;, &quot;Create&quot;)&lt;\/p&gt;        &lt;table&gt;              &lt;tr&gt;                     &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Image)&lt;\/th&gt;                     &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Name)&lt;\/th&gt;                     &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.MfRaiting)&lt;\/th&gt;                     &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Mind)&lt;\/th&gt;                     &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Series)&lt;\/th&gt;                     &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Genres)&lt;\/th&gt;                     &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Authors)&lt;\/th&gt;                     &lt;th&gt;\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438&lt;\/th&gt;              &lt;\/tr&gt;               @foreach (var item in Model) {              &lt;tr&gt;                      &lt;td&gt; &lt;img src=&quot;~\/Content\/img\/@item.Image&quot; \/&gt;&lt;\/td&gt;\/\/\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0438                     &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.Name)&lt;\/td&gt;                     &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.MfRaiting)&lt;\/td&gt;                     &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.Mind.MyMind)&lt;\/td&gt;                     &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.Series.Name)&lt;\/td&gt;                     &lt;td&gt;                     @foreach (var genre in item.Genres) {                            @Html.DisplayFor(modelItem =&gt; genre.Name) &lt;br \/&gt;                     }                     &lt;\/td&gt;                     &lt;td&gt;                     @foreach (var author in item.Authors) {                            @Html.DisplayFor(modelItem =&gt; author.Name) &lt;br \/&gt;                     }                     &lt;\/td&gt;                  &lt;td&gt;                  @Html.ActionLink(&quot;Edit&quot;, &quot;Edit&quot;, new { id = item.Id }) |                  @Html.ActionLink(&quot;Details&quot;, &quot;Details&quot;, new { id = item.Id }) |                  @Html.ActionLink(&quot;Delete&quot;, &quot;Delete&quot;, new { id = item.Id })                  &lt;\/td&gt;              &lt;\/tr&gt;              }        &lt;\/table&gt; &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u0432\u0441\u0435\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0432\u0438\u0434\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e26\/eae\/77e\/e26eae77e15949aa8d3a85e856961e42.jpg\"\/><\/p>\n<p>  <b>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b. <\/b><br \/>  \u0417\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u0441 Nhibernate, \u0443\u0432\u0438\u0434\u0435\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438  <\/p>\n<pre><code>             \/\/\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043a\u043d\u0438\u0433              var criteria = session.CreateCriteria&lt;Book&gt;();              \/\/Left Join \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 Genres              criteria.CreateAlias(&quot;Genres&quot;, &quot;genre&quot;, JoinType.LeftOuterJoin);              ******              DistinctRootEntityResultTransformer());              var books = criteria.List&lt;Book&gt;(); <\/code><\/pre>\n<p>  \u043c\u043e\u0433\u0443\u0442 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c: \u00ab\u041d\u0443 \u0438 \u0433\u0434\u0435 \u0442\u0443\u0442 FluentNhibernate, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 intellisense?\u00bb \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0430\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f fluentNhibernate, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0430\u043d\u0430\u043b\u043e\u0447\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044e \u043a\u043e\u0434\u0443 \u0432\u044b\u0448\u0435.  <\/p>\n<pre><code>             \/\/\u041c\u0435\u0442\u043e\u0434\u044b \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 intellisense              Book bookAl = null; Genre genreAl = null;              IQueryOver&lt;Book, Book&gt; bookQuery =              session.QueryOver&lt;Book&gt;(() =&gt; bookAl)              .JoinAlias(() =&gt; bookAl.Genres, () =&gt; genreAl, JoinType.LeftOuterJoin)              .TransformUsing(Transformers.DistinctRootEntity);               var books = bookQuery.List&lt;Book&gt;(); <\/code><\/pre>\n<p>  \u041c\u043d\u0435 \u043e\u043d \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0435 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435) \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0434\u0430\u043b\u0435\u0435 \u0432 \u043a\u043e\u0434\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e, \u0434\u0430 \u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u00abIQueryOver&lt;Book, Book&gt;\u00bb \u0438 &quot;()&quot; \u2014 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u2026 \u041a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0443.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043b\u044e\u0431\u0438\u0442 \u043f\u0438\u0441\u0430\u0442\u044c SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u0443 Nhibernate \u043d\u0430\u0439\u0434\u0435\u0442\u0441\u044f \u0438 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442:  <\/p>\n<pre><code>\/\/SQl-\u0437\u0430\u043f\u0440\u043e\u0441 var queryBook = string.Format(@&quot;select Id, Name, Description, MfRaiting, PageNumber, Image, IncomeDate from Book&quot;); \/\/\u0412\u044b\u0432\u043e\u0434 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u0441\u0435\u0445 \u043a\u043d\u0438\u0433 var books = session.CreateSQLQuery(queryBook) \/\/SQl-\u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c .SetResultTransformer(Transformers.AliasToBean(typeof(Book))) .List&lt;Book&gt;().ToList(); <\/code><\/pre>\n<p>  *\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435\u2026 \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0442\u0443\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0431\u0443\u043a\u0432, \u0442\u043e \u0435\u0441\u0442\u044c Id \u0438 id \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430. <br \/>  **\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0412\u0421\u0415 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Book, \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0442\u043e\u043b\u044c\u043a\u043e Id \u0438 Name. \u0415\u0441\u043b\u0438 \u0436 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, \u0442\u043e \u043f\u043e\u0434 \u043d\u0438\u0445 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. <br \/>  ***\u041f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u043b\u0438 \u0432\u0441\u0435 \u043f\u043e\u043b\u044f, \u0430 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 Select * from Book? \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Book \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 Series_Id, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Book<\/p>\n<p>  <b> \u041c\u0430\u043f\u043f\u0438\u043d\u0433 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435.<\/b><br \/>  \u0410 \u043a\u0430\u043a \u043c\u0430\u043f\u043f\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435? \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0438\u043c\u0435\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code> \/\/\u041a\u043b\u0430\u0441\u0441 \u0414\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0445 \u0444\u0438\u0433\u0443\u0440 public class TwoDShape {     \/\/\u0428\u0438\u0440\u0438\u043d\u0430     public virtual int Width { get; set; }     \/\/\u0412\u044b\u0441\u043e\u0442\u0430     public virtual int Height { get; set; } } \/\/\u041a\u043b\u0430\u0441\u0441 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a public class Triangle : TwoDShape {     \/\/\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440     public virtual int Id { get; set; }     \/\/\u0412\u0438\u0434 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430     public virtual string Style { get; set; } } <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u043c \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0435 \u043d\u0435\u0442, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0434\u0438\u043d \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b Triangle.  <\/p>\n<pre><code> \/\/\u041c\u0430\u043f\u043f\u0438\u043d\u0433 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 public class TriangleMap : ClassMap&lt;Triangle&gt; {        public TriangleMap() {              Id(x =&gt; x.Id);              Map(x =&gt; x.Style);              Map(x =&gt; x.Height);              Map(x =&gt; x.Width);        } } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432 \u0411\u0414 Biblioteca \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f (\u043f\u0443\u0441\u0442\u0430\u044f) \u0442\u0430\u0431\u043b\u0438\u0446\u0430<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f39\/540\/21a\/f3954021af9d4fc7b172d6fcc939564f.png\"\/>     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/265087\/\"> http:\/\/habrahabr.ru\/post\/265087\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438.<br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/264907\/\"><i>\u0423\u0440\u043e\u043a\u0438 \u043f\u043e FluentNHibernate c ASP.NET MVC \u0438 SQL Server. \u0427\u0430\u0441\u0442\u044c 1<\/i><\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/264961\/\"><i>\u0427\u0430\u0441\u0442\u044c 2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u043e\u0432 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0411\u0414<\/i><\/a><\/p>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433-\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a \u043d\u0438\u043c. \u0412 3 \u043a\u0440\u0430\u0442\u043a\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0438 \u0441\u0432\u044f\u0437\u0435\u0439 \u043e\u0434\u0438\u043d-\u043a-\u043e\u0434\u043d\u043e\u043c\u0443, \u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c, \u043c\u043d\u043e\u0433\u0438\u0435-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c. \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 sql server&#8217;e \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0411\u0414 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 View. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442.   <\/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-263926","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263926","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=263926"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263926\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}