{"id":200100,"date":"2013-11-01T00:35:02","date_gmt":"2013-10-31T20:35:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=200100"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=200100","title":{"rendered":"<span class=\"post_title\">\u0423\u0441\u0438\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0442\u0438\u043f\u043e\u0432: \u0433\u0434\u0435 \u0432 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u043c C#-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u043f\u0440\u043e\u0448\u0435\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043b\u0430\u0431\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438?<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h4>\n<p>  \u041c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u0440\u043e\u0434\u0435 C# \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u0433\u043e \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430, \u0438 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0442\u0438\u043f, <b>\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 <\/b>\u043d\u0430\u043c\u0438 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 <b>\u043d\u0430\u0448\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/b> \u043e \u0435\u0435 \u0442\u0438\u043f\u0435. \u041d\u043e \u0435\u0441\u0442\u044c \u0448\u0438\u0440\u043e\u043a\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0435 (\u00ab\u0438 \u0432\u0441\u0435 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u044e\u0442\u00bb) \u043c\u0438\u0440\u0438\u043c\u0441\u044f \u0441 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0432\u0435\u0440\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u00ab\u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430\u00bb \u0432 \u00ab\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u0442\u0438\u043f\u0435\u00bb. \u0421\u0430\u043c\u044b\u0439 \u044f\u0440\u043a\u0438\u0439 \u2014 \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0431\u0435\u0437\u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u0441\u043d\u0430\u0449\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u00abnull\u00bb.   <\/p>\n<blockquote><p>\u0412 \u043c\u043e\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0430 \u0433\u043e\u0434 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e NullReferenceException. \u041c\u043e\u0433\u0443 \u043d\u0435 \u0431\u0435\u0437 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0438\u0436\u0435 \u0442\u0435\u0445\u043d\u0438\u043a.<\/p><\/blockquote>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430: <\/p>\n<pre><code class=\"cs\">public interface IUserRepo  { \tUser Get(int id); \tUser Find(int id); } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f: \u00abGet \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435 null, \u043d\u043e \u043a\u0438\u0434\u0430\u0435\u0442 Exception \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430; \u0430 Find, \u043d\u0435 \u043d\u0430\u0439\u0434\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 null\u00bb. \u00ab\u0416\u0435\u043b\u0430\u0435\u043c\u044b\u0435\u00bb, \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u043c\u044b\u0435 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u0442\u0438\u043f\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0443 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0435: \u00ab\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e User\u00bb \u0438 \u00ab\u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, User\u00bb. \u0410 \u00ab\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439\u00bb \u0442\u0438\u043f \u2014 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435. \u0415\u0441\u043b\u0438 \u044f\u0437\u044b\u043a \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u044f\u0432\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u0442\u044c \u044d\u0442\u0443 \u0440\u0430\u0437\u043d\u0438\u0446\u0443, \u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u0442\u0438\u0432\u0435.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 F#, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0442\u0438\u043f FSharpOption&lt;T&gt;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u043b\u0438\u0431\u043e \u0431\u044b\u0442\u044c \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 T, \u043b\u0438\u0431\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0438\u043c\u0435\u0442\u044c \u043e\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0447\u0442\u043e\u0431\u044b \u0438\u043c \u0431\u044b\u043b\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043f\u0440\u0438\u0432\u0435\u0440\u0436\u0435\u043d\u0446\u0430\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0438\u043b\u0435\u0439 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0440\u0430\u0437\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u044f\u0437\u044b\u043a\u0430\u043c\u0438.<br \/>  \u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u0433\u0438\u043f\u043e\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435: <\/p>\n<pre><code class=\"cs\">public interface IUserRepo  { \tUser Get(int id); \tMaybe&lt;User&gt; Find(int id); } <\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0421\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c null. \u041f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u044f\u0437\u044b\u043a\u0430 \u2014 \u043d\u0435\u0442. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0423\u0441\u043f\u0435\u0445 \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043b\u044e\u0434\u0435\u0439; \u0432 \u043c\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0442\u0430\u043a\u043e\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f. <br \/>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 null \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 (\u0441 \u043e\u0433\u043e\u0432\u043e\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430). \u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u044b. <br \/>  \u0410 \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u0438 \u0435\u0449\u0435 \u0434\u0430\u043b\u044c\u0448\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0432\u043e \u0432\u0441\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b Contract.Ensure(Contract.Result&lt;T&gt;() != null) \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c AOP-\u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, PostSharp, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0430\u0436\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441 \u043d\u0438\u0437\u043a\u043e\u0439 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u043e\u0439 \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0437\u043b\u043e\u0441\u0447\u0430\u0441\u0442\u043d\u044b\u0439 null.  <\/p><\/blockquote>\n<p>  \u0412 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u044f\u0432\u043d\u043e \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e Find \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u043d\u0430\u0439\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442, \u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0435\u0440\u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Maybe&lt;User&gt;.Nothing. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e \u0437\u0430\u0431\u044b\u0432\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 null. \u041f\u043e\u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043b\u0435\u0435 \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f:<\/p>\n<pre><code class=\"cs\">\/\/ \u0437\u0430\u0431\u044b\u0432\u0447\u0438\u0432\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u0431\u044b\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 null var user = repo.Find(userId); \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 User, \u0430 Maybe&lt;User&gt; var userName = user.Name; \/\/ \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0443 Maybe \u043d\u0435\u0442 Name  var maybeUser = repo.Find(userId); \/\/ \u0437\u0430\u0442\u043e \u043a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, string userName; if (maybeUser.HasValue) \/\/ \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0441 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u041d\u0415 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 { \tvar user = maybeUser.Value; \tuserName = user.Name; } else  \tuserName = &quot;unknown&quot;; <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 null, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432 if \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0430\u0447\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0437\u0430\u0445\u043b\u0430\u043c\u043b\u044f\u0435\u0442 \u043a\u043e\u0434, \u0434\u0435\u043b\u0430\u044f \u0441\u0443\u0442\u044c \u0435\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u0435\u043d\u0435\u0435 \u044f\u0432\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0439, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0443\u0442\u043e\u043c\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0431\u044b \u043a\u0440\u0430\u0439\u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0412\u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 fluent-\u0441\u0442\u0438\u043b\u0435:<\/p>\n<pre><code class=\"cs\">string userName = repo.Find(userId).Select(u =&gt; u.Name).OrElse(&quot;unknown&quot;); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445 \u0436\u0435, \u043a\u043e\u043c\u0443 \u0431\u043b\u0438\u0437\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u044f\u0437\u044b\u043a\u0438 \u0438 do-\u043d\u043e\u0442\u0430\u0446\u0438\u044f, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d \u0441\u043e\u0432\u0441\u0435\u043c \u00ab\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439\u00bb \u0441\u0442\u0438\u043b\u044c: <\/p>\n<pre><code class=\"cs\">string userName = (from user in repo.Find(userId) select user.Name).OrElse(&quot;unknown&quot;); <\/code><\/pre>\n<p>  \u0418\u043b\u0438, \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435: <\/p>\n<pre><code class=\"cs\">(  from roleAProfile in provider.FindProfile(userId, type: &quot;A&quot;)  from roleBProfile in provider.FindProfile(userId, type: &quot;B&quot;)  from roleCProfile in provider.FindProfile(userId, type: &quot;C&quot;)  where roleAProfile.IsActive() && roleCProfile.IsPremium()  let user = repo.GetUser(userId)  select user ).Do(HonorAsActiveUser); <\/code><\/pre>\n<p>  \u0441 \u0435\u0433\u043e \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043e\u043c: <\/p>\n<pre><code class=\"cs\">var maybeProfileA = provider.FindProfile(userId, type: &quot;A&quot;); if (maybeProfileA.HasValue) { \tvar profileA = maybeProfileA.Value; \tvar maybeProfileB = provider.FindProfile(userId, type: &quot;B&quot;); \tif (maybeProfileB.HasValue) \t{ \t\tvar profileB = maybeProfileB.Value; \t\tvar maybeProfileC = provider.FindProfile(userId, type: &quot;C&quot;); \t\tif (maybeProfileC.HasValue) \t\t{ \t\t\tvar profileC = maybeProfileC.Value; \t\t\tif (profileA.IsActive() && profileC.IsPremium()) \t\t\t{ \t\t\t\tvar user = repo.GetUser(userId); \t\t\t\tHonorAsActiveUser(user); \t\t\t} \t\t} \t} } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Maybe&lt;T&gt; \u0441 \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u0438\u043c \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u043c \u2014 IEnumerable&lt;T&gt;, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435: <\/p>\n<pre><code class=\"cs\">var admin = users.MaybeFirst(u =&gt; u.IsAdmin); \/\/ \u0432\u043c\u0435\u0441\u0442\u043e FirstOrDefault(u =&gt; u.IsAdmin); Console.WriteLine(&quot;Admin is {0}&quot;, admin.Select(a =&gt; a.Name).OrElse(&quot;not found&quot;)); <\/code><\/pre>\n<p>  \u0418\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u00ab\u043c\u0435\u0447\u0442\u0430\u043d\u0438\u0439\u00bb \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0432 \u0442\u0438\u043f\u0435 Maybe   <\/p>\n<ul>\n<li>\u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <\/li>\n<li>\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e<\/li>\n<li>\u043d\u0430\u0431\u043e\u0440 \u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (\u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439) \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 LINQ-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/li>\n<li>\u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 IEnumerable&lt;T&gt; \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/li>\n<\/ul>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430\u043c Nuget \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0438\u0445 \u043f\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c:<\/p>\n<table>\n<tr>\n<th>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 Nuget \u0438 \u0442\u0438\u043f \u0442\u0438\u043f\u0430<\/th>\n<th>HasValue<\/th>\n<th>Value<\/th>\n<th>FluentAPI<\/th>\n<th>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 LINQ<\/th>\n<th>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 IEnumerable <\/th>\n<th>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/th>\n<\/tr>\n<tr>\n<td>Option, class<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u043d\u0435\u0442, \u0442\u043e\u043b\u044c\u043a\u043e pattern-matching<\/td>\n<td>\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435<\/td>\n<td>\u043d\u0435\u0442<\/td>\n<td>\u043d\u0435\u0442<\/td>\n<td><a href=\"https:\/\/github.com\/tejacques\/Option\/\">github.com\/tejacques\/Option\/<\/a><\/td>\n<\/tr>\n<tr>\n<td>Strilanc.Value.May, struct<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u043d\u0435\u0442, \u0442\u043e\u043b\u044c\u043a\u043e pattern-matching<\/td>\n<td>\u0431\u043e\u0433\u0430\u0442\u043e\u0435<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 null \u043a\u0430\u043a \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 May <br \/>  <a href=\"https:\/\/github.com\/Strilanc\/May\">github.com\/Strilanc\/May<\/a><\/td>\n<\/tr>\n<tr>\n<td>Options, struct<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0441\u0440\u0435\u0434\u043d\u0435\u0435<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0442\u0438\u043f Either<br \/>  <a href=\"https:\/\/github.com\/davidsidlinger\/options\">github.com\/davidsidlinger\/options<\/a><\/td>\n<\/tr>\n<tr>\n<td>NeverNull, class<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0441\u0440\u0435\u0434\u043d\u0435\u0435<\/td>\n<td>\u043d\u0435\u0442<\/td>\n<td>\u043d\u0435\u0442<\/td>\n<td><a href=\"https:\/\/github.com\/Bomret\/NeverNull\">github.com\/Bomret\/NeverNull<\/a><\/td>\n<\/tr>\n<tr>\n<td>Functional.Maybe, struct<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0431\u043e\u0433\u0430\u0442\u043e\u0435<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td><a href=\"https:\/\/github.com\/AndreyTsvetkov\/Functional.Maybe\">github.com\/AndreyTsvetkov\/Functional.Maybe<\/a><\/td>\n<\/tr>\n<tr>\n<td>Maybe, \u043d\u0435\u0442 \u0442\u0438\u043f\u0430<\/td>\n<td>\u2014<\/td>\n<td>\u2014<\/td>\n<td>\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435<\/td>\n<td>\u043d\u0435\u0442<\/td>\n<td>\u2014<\/td>\n<td>\u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c null<br \/>  <a href=\"https:\/\/github.com\/hazzik\/Maybe\">github.com\/hazzik\/Maybe<\/a><\/td>\n<\/tr>\n<tr>\n<td>WeeGems.Options, struct<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u0435\u0441\u0442\u044c<\/td>\n<td>\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435<\/td>\n<td>\u043d\u0435\u0442<\/td>\n<td>\u043d\u0435\u0442<\/td>\n<td>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438: \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u044f, \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<br \/>  <a href=\"https:\/\/bitbucket.org\/MattDavey\/weegems\">bitbucket.org\/MattDavey\/weegems<\/a><\/td>\n<\/tr>\n<\/table>\n<p>  \u0422\u0430\u043a \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u044b\u0440\u043e\u0441 \u0441\u0432\u043e\u0439 \u043f\u0430\u043a\u0435\u0442, \u043e\u043d \u0435\u0441\u0442\u044c \u0441\u0440\u0435\u0434\u0438 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445. <\/p>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u00ab\u043b\u0435\u0433\u043a\u043e\u0435\u00bb, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u043d\u0432\u0430\u0437\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e Maybe \u043e\u0442 <a href=\"http:\/\/habrahabr.ru\/users\/hazzik\/\" class=\"user_link\">hazzik<\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0438\u043a\u0430\u043a \u043c\u0435\u043d\u044f\u0442\u044c API, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 if-\u043e\u0432. \u041d\u043e, \u0443\u0432\u044b, \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u0437\u0430\u0431\u044b\u0432\u0447\u0438\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f NullReferenceException. <\/p>\n<p>  \u0421\u0430\u043c\u044b\u0435 \u0431\u043e\u0433\u0430\u0442\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u2014 Strilanc.Value.Maybe (<a href=\"http:\/\/twistedoakstudios.com\/blog\/Post1130_when-null-is-not-enough-an-option-type-for-c\">\u0442\u0443\u0442<\/a> \u0430\u0432\u0442\u043e\u0440 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d \u0440\u0435\u0448\u0438\u043b \u0447\u0442\u043e (null).ToMaybe() \u043d\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e Maybe.Nothing), Functional.Maybe, Options. <\/p>\n<p>  \u0412\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u043d\u0430 \u0432\u043a\u0443\u0441. \u0410 \u0432\u043e\u043e\u0431\u0449\u0435, \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0442 Microsoft<s>, \u0430 \u0435\u0449\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0432 C#, \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u0438 \u0442.\u043f \ud83d\ude42<\/s>. \u041f\u043e\u0436\u0438\u0432\u0435\u043c \u2014 \u0443\u0432\u0438\u0434\u0438\u043c.    \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\/200100\/\"> http:\/\/habrahabr.ru\/post\/200100\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h4>\n<p>  \u041c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u0440\u043e\u0434\u0435 C# \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u0433\u043e \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430, \u0438 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0442\u0438\u043f, <b>\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 <\/b>\u043d\u0430\u043c\u0438 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 <b>\u043d\u0430\u0448\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/b> \u043e \u0435\u0435 \u0442\u0438\u043f\u0435. \u041d\u043e \u0435\u0441\u0442\u044c \u0448\u0438\u0440\u043e\u043a\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0435 (\u00ab\u0438 \u0432\u0441\u0435 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u044e\u0442\u00bb) \u043c\u0438\u0440\u0438\u043c\u0441\u044f \u0441 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0432\u0435\u0440\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u00ab\u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430\u00bb \u0432 \u00ab\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u0442\u0438\u043f\u0435\u00bb. \u0421\u0430\u043c\u044b\u0439 \u044f\u0440\u043a\u0438\u0439 \u2014 \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0431\u0435\u0437\u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u0441\u043d\u0430\u0449\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u00abnull\u00bb.   <\/p>\n<blockquote><p>\u0412 \u043c\u043e\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0430 \u0433\u043e\u0434 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e NullReferenceException. \u041c\u043e\u0433\u0443 \u043d\u0435 \u0431\u0435\u0437 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0438\u0436\u0435 \u0442\u0435\u0445\u043d\u0438\u043a.<\/p><\/blockquote>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430: <\/p>\n<pre><code class=\"cs\">public interface IUserRepo  { \tUser Get(int id); \tUser Find(int id); } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f: \u00abGet \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435 null, \u043d\u043e \u043a\u0438\u0434\u0430\u0435\u0442 Exception \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430; \u0430 Find, \u043d\u0435 \u043d\u0430\u0439\u0434\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 null\u00bb. \u00ab\u0416\u0435\u043b\u0430\u0435\u043c\u044b\u0435\u00bb, \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u043c\u044b\u0435 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u0442\u0438\u043f\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0443 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0435: \u00ab\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e User\u00bb \u0438 \u00ab\u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, User\u00bb. \u0410 \u00ab\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439\u00bb \u0442\u0438\u043f \u2014 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435. \u0415\u0441\u043b\u0438 \u044f\u0437\u044b\u043a \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u044f\u0432\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u0442\u044c \u044d\u0442\u0443 \u0440\u0430\u0437\u043d\u0438\u0446\u0443, \u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u0442\u0438\u0432\u0435.  <\/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-200100","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/200100","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=200100"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/200100\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}