{"id":266216,"date":"2015-09-23T12:23:05","date_gmt":"2015-09-23T08:23:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=266216"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=266216","title":{"rendered":"\u041e\u0441\u043d\u043e\u0432\u044b NHibernate (\u043b\u0435\u0433\u043a\u0438\u0439 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b)"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/49d\/9df\/686\/49d9df686ffc47ddb001bb595b54f3d2.JPG\"\/><\/p>\n<p>  <b>\u0412\u0435\u0434\u0435\u043d\u0438\u0435<\/b><br \/>  Nhibernate \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e \u0420\u0435\u0430\u043b\u0438\u0446\u043e\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u043f\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b .NET. \u042d\u0442\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u043f\u0438\u043d\u0433 \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043a \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0411\u0414. \u0415\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043c\u0430\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 .Net \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u0411\u0414 \u0438 \u043e\u0442 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 CLR \u0432 \u0442\u0438\u043f\u044b SQL.<\/p>\n<p>  \u041a\u0430\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c: \u041a\u0430\u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u0437 \u0411\u0414 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u0411\u0414.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  <b>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430.<\/b><br \/>  \u0414\u0435\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u043d\u0430\u043c \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c NHibernate. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 Employee \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Employee. \u041e\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 Employee. \u042d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e NHibernate 3.2.0, VS 2010 \u0438 SQL Server 2008.<\/p>\n<p>  <b>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/b><\/p>\n<p>  <b>\u0411\u0430\u0437\u0430 \u0414\u0430\u043d\u043d\u044b\u0445<\/b><br \/>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 SQL Server Managment Strudio \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439. \u041a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u0411\u0414, \u0438 \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u0435\u0435 NHibernateBasics.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1c2\/2bc\/05a\/1c22bc05aab445d7a7082fe49532f98f.JPG\"\/><\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Employee \u0441 \u0434\u0432\u0443\u043c\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438;ID \u0438 NAME.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/01f\/2db\/53c\/01f2db53c1674d7e931ff1adaa9704a7.JPG\"\/><\/p>\n<p>  \u0421\u0442\u043e\u043b\u0431\u0435\u0446 ID \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u043c. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c Identity Specification \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d17\/1e4\/8fd\/d171e48fd963408d97933b39b4048872.JPG\"\/><\/p>\n<p>  <b>\u0411\u0438\u0437\u043d\u0435\u0441 \u041e\u0431\u044a\u0435\u043a\u0442\u044b<\/b><\/p>\n<p>  \u0411\u0414 \u0433\u043e\u0442\u043e\u0432\u0430 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0421\u0442\u0443\u0434\u0438\u044e \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 WindowsFormApplication, \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430\u0437\u043e\u0432\u0435\u043c NhibernateBasics. <br \/>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e Employee.cs \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<pre><code>namespace NHibernateBasics {     public class Employee     {         public virtual int ID { get; set; }         public virtual string Name { get; set; }     } } <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0441\u0442\u043e\u0440\u043e\u043d Nhibernate \u044d\u0442\u043e \u0442\u043e \u0447\u0442\u043e \u0435\u043c\u0443 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u042d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u044b\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u0430\u043a \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c Proxi.<\/p>\n<p>  <b>\u041c\u0430\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 XML \u0444\u0430\u0439\u043b\u0430.<\/b><\/p>\n<p>  \u0418\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0433\u0438\u0431\u0435\u0440\u043d\u0430\u0446\u0438\u0438, \u043a\u0442\u043e \u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0437\u044f\u0442\u044c \u043d\u0430 \u0441\u0435\u0431\u044f \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044e \u0438\u0437 \u0411\u0414 \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u042d\u0442\u0430 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 XML \u0444\u0430\u0439\u043b \u0438\u043b\u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<br \/>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0434\u0435\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0444\u0430\u0439\u043b \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0445\u043b\u0430\u043c\u043b\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0431\u0438\u0437\u043d\u0435\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 XML \u0444\u0430\u0439\u043b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. XML \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0444\u0430\u0439\u043b. \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c Employee.hbm.xml. \u0424\u0430\u0439\u043b \u043a\u043b\u0430\u0441\u0441\u0430 <code> &lt;name&gt;.cs <\/code> \u0438 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0444\u0430\u0439\u043b <code> &lt;name&gt;.hbm.xml <\/code> \u0434\u043e\u043b\u0436\u043d\u044b \u043b\u0435\u0436\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u0438 <code> &lt;name&gt; <\/code> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e. <br \/>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt; &lt;hibernate-mapping xmlns=&quot;urn:nhibernate-mapping-2.2&quot;  \tnamespace=&quot;NHibernateBasics&quot; assembly=&quot;NHibernateBasics&quot;&gt;   &lt;class name=&quot;Employee&quot; table=&quot;Employee&quot;&gt;     &lt;id name=&quot;ID&quot; column=&quot;ID&quot;&gt;       &lt;generator class=&quot;identity&quot;\/&gt;     &lt;\/id&gt;     &lt;property name=&quot;Name&quot; column=&quot;Name&quot;  \/&gt;   &lt;\/class&gt; &lt;\/hibernate-mapping&gt; <\/code><\/pre>\n<p>  \u0412 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 XML \u0444\u0430\u0439\u043b\u0430 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e Build Action = Embedded Resource.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/78d\/09d\/e13\/78d09de1302a424994880b8e898870d4.JPG\"\/><\/p>\n<p>  <b>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/b><\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (app.config).<br \/>  \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt; &lt;configuration&gt;   &lt;configSections&gt;     &lt;section name=&quot;hibernate-configuration&quot;  \ttype=&quot;NHibernate.Cfg.ConfigurationSectionHandler, NHibernate&quot; \/&gt;   &lt;\/configSections&gt;   &lt;hibernate-configuration xmlns=&quot;urn:nhibernate-configuration-2.2&quot;&gt;     &lt;session-factory&gt;       &lt;property name=&quot;connection.provider&quot;&gt; \tNHibernate.Connection.DriverConnectionProvider&lt;\/property&gt;       &lt;property name=&quot;dialect&quot;&gt;NHibernate.Dialect.MsSql2005Dialect&lt;\/property&gt;       &lt;property name=&quot;query.substitutions&quot;&gt;hqlFunction=SQLFUNC&lt;\/property&gt;       &lt;property name=&quot;connection.driver_class&quot;&gt; \tNHibernate.Driver.SqlClientDriver&lt;\/property&gt;       &lt;property name=&quot;connection.connection_string&quot;&gt; \tData Source=(Local)\\SQL2008;Initial Catalog=NHibernateBasics; \tIntegrated Security=True&lt;\/property&gt;       &lt;property name=&quot;show_sql&quot;&gt;true&lt;\/property&gt;       &lt;mapping assembly=&quot;NHibernateBasics&quot; \/&gt;     &lt;\/session-factory&gt;   &lt;\/hibernate-configuration&gt; &lt;\/configuration&gt; <\/code><\/pre>\n<p>  \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e Connection-string \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0432\u0430\u0448\u0435\u0439 \u0411\u0414.\u0412\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code> CATALOG=&lt;Dabase name&gt; <\/code>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c NHibernateBasics. \u0412\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code> mapping assembly=&lt;Class DLL name&gt; <\/code>, \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c NHibernateBasics.<\/p>\n<p>  <b>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f.<\/b><\/p>\n<p>  \u0418\u0442\u0430\u043a \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0438\u0437\u043d\u0435\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438.<\/p>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435<\/p>\n<pre><code>using(mySession.BeginTransaction()) {     \/\/ Insert two employees in Database     mySession.Save(myInitialObjects[0]);      mySession.Save(myInitialObjects[1]);      mySession.Transaction.Commit();  }   <\/code><\/pre>\n<p>  \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/p>\n<pre><code>using(mySession.BeginTransaction()) {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044e \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435     ICriteria criteria = mySession.CreateCriteria&lt;employee&gt;();     IList&lt;employee&gt; list = criteria.List&lt;employee&gt;();     for (int i = 0; i &lt; myFinalObjects.Length; i++)     {         myFinalObjects[i] = list[i];         MessageBox.Show(&quot;ID: &quot; + myFinalObjects[i].ID + &quot;  \t\t\tName: &quot; + myFinalObjects[i].Name);     }     mySession.Transaction.Commit();  } <\/code><\/pre>\n<p>  \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/p>\n<pre><code>StringBuilder messageString = new StringBuilder(); \/\/ \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0434\u0432\u0430 \u043e\u0431\u044c\u0435\u043a\u0442\u0430 for (int i = 0; i &lt; 2; i++) {     messageString.AppendLine(&quot;Comparing Class Object &quot; +  \tmyInitialObjects[i].Name + &quot; and DB Object &quot; +  \tmyFinalObjects[i].Name + &quot;. Result = &quot; +  \tmyInitialObjects[i].Equals(myFinalObjects[i]).ToString()); } MessageBox.Show(messageString.ToString()); <\/code><\/pre>\n<p>  \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435<\/p>\n<pre><code>using (mySession.BeginTransaction()) {     \/\/ Delete one object from Database     mySession.Delete(myInitialObjects[0]);     mySession.Transaction.Commit(); }  <\/code><\/pre>\n<p>  \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435<\/p>\n<pre><code>using (mySession.BeginTransaction()) {      ICriteria criteria = mySession.CreateCriteria&lt;employee&gt;();      IList&lt;employee&gt; list = criteria.List&lt;employee&gt;();      StringBuilder messageString = new StringBuilder();      \/\/ Load and display the data      foreach (Employee employee in list)      {          messageString.AppendLine(&quot;ID: &quot; + employee.ID + &quot; Name: &quot; + employee.Name);      }      MessageBox.Show(messageString.ToString()); } <\/code><\/pre>\n<p>  NHibernte \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u043c \u0447\u0442\u043e \u0434\u0432\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0443\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0435\u0441\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438. \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439, \u0442\u043e \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043d\u044b\u043c\u0438.<br \/>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u043c\u043e\u0433\u043b\u0430 \u0432\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b Nhibernate. Happy coding \/\/\/\/\/<\/p>\n<p>  \u0424\u0430\u0439\u043b \u043f\u0440\u043e\u0435\u043a\u0442\u0430<br \/>  <a href=\"https:\/\/yadi.sk\/d\/ojPBcTbzjGJGN\">NHibernateBasics.zip<\/a><br \/>  \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e <a href=\"http:\/\/www.codeproject.com\/Articles\/222279\/NHibernate-Basics\">\u0422\u0443\u0442<\/a><\/p>\n<p>  \u041e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430, \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e Nhiberante. <br \/>  \u0425\u0430\u0431\u0440\u0430\u0436\u0438\u0442\u0435\u043b\u0438 \u043a\u0430\u043a\u0438\u0435 \u0435\u0449\u0435 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u043e Nhibernate \u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435??               <\/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\/267505\/\"> http:\/\/habrahabr.ru\/post\/267505\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/49d\/9df\/686\/49d9df686ffc47ddb001bb595b54f3d2.JPG\"\/><\/p>\n<p>  <b>\u0412\u0435\u0434\u0435\u043d\u0438\u0435<\/b><br \/>  Nhibernate \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e \u0420\u0435\u0430\u043b\u0438\u0446\u043e\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u043f\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b .NET. \u042d\u0442\u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u043f\u0438\u043d\u0433 \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043a \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0411\u0414. \u0415\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043c\u0430\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 .Net \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u0411\u0414 \u0438 \u043e\u0442 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 CLR \u0432 \u0442\u0438\u043f\u044b SQL.<\/p>\n<p>  \u041a\u0430\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c: \u041a\u0430\u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u0437 \u0411\u0414 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u0411\u0414.  <\/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-266216","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266216","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=266216"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266216\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}