{"id":253603,"date":"2015-03-23T17:27:02","date_gmt":"2015-03-23T13:27:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=253603"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=253603","title":{"rendered":"\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b LINQ to SQL. \u041e\u043f\u044f\u0442\u044c"},"content":{"rendered":"<p>     \t\u0421 <a href=\"http:\/\/habrahabr.ru\/post\/250759\">\u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430<\/a> \u043f\u0440\u043e\u0448\u0451\u043b \u043c\u0435\u0441\u044f\u0446, \u043f\u043e-\u043c\u043e\u0435\u043c\u0443 \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 Inheritance Mapping\u2019\u0435, \u043d\u0443 \u0430 \u043e\u0441\u043e\u0431\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0436\u0434\u0451\u0442 \u0441\u044e\u0440\u043f\u0440\u0438\u0437. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0451\u043c. <\/p>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u043c<\/h3>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0432 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c CustomerOperation, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043d\u0430\u0434 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u043c. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a CustomerServiceOperation, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c WebTracking\u2019\u0430, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c WebTrackingOperation. \u041d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0432, \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u043e\u0434:<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<pre><code class=\"cs\">[Table(Name = &quot;directcrm.CustomerOperations&quot;)] [InheritanceMapping(Code = &quot;&quot;, Type = typeof(CustomerOperation), IsDefault = true)] [InheritanceMapping(Code = &quot;Service&quot;, Type = typeof(CustomerServiceOperation))] [InheritanceMapping(Code = &quot;WebTracking&quot;, Type = typeof(WebTrackingOperation))] public class CustomerOperation : CampaignItemBase, ICampaignItem { \t\/\/ \u0442\u0443\u0442 \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442  \t[Column(Storage = &quot;discriminator&quot;, CanBeNull = false, IsDiscriminator = true)] \tpublic string Discriminator \t{ \t\tget \t\t{ \t\t\treturn discriminator; \t\t} \t\tprivate set \t\t{ \t\t\tif (discriminator != value) \t\t\t{ \t\t\t\tSendPropertyChanging(); \t\t\t\tdiscriminator = value; \t\t\t\tSendPropertyChanged(); \t\t\t} \t\t} \t} \t \t\/\/ \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435 } <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c WebTracking-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u0410 \u0432\u043e\u0442 \u0438 \u043a\u043e\u0434:  <\/p>\n<pre><code class=\"cs\">modelContext.Repositories.Get&lt;CustomerOperationRepository&gt;() \t\t\t\t.FixedItems.OfType&lt;WebTrackingOperation&gt;() \t\t\t\t.FirstOrDefault(); <\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e. \u041d\u043e \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0434\u0440\u0443\u0433 \u0437\u0430\u0431\u044b\u043b\u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f WebTrackingOperation \u0432 Inheritance Mapping \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445? \u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0431\u044b\u043b\u0438 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u043d \u0432 <\/p>\n<pre><code class=\"sql\">SELECT TOP (1) NULL AS [EMPTY] FROM [directcrm].[CustomerOperations] AS [t0] WHERE 0 = 1 <\/code><\/pre>\n<p>  \u0423\u043c\u043d\u044b\u0439 LINQ to SQL! \u041d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u043b\u0443\u0447\u0448\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043c, \u043d\u0430 \u043c\u043e\u0439 \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u0425\u043e\u0440\u043e\u0448\u043e, \u0430 \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0431\u044b\u043b\u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f, \u043d\u043e \u043f\u0440\u043e\u0448\u043b\u0438\u0441\u044c \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0442\u0438\u043f \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 \u0431\u0430\u0437\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u043d\u044c\u0448\u0435 \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0438 CustomerService, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c WebTracking, \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0430\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c). \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u043d\u0435\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u043c \u0438\u0437 \u0431\u0430\u0437\u044b:<\/p>\n<pre><code class=\"cs\">var test = modelContext.Repositories.Get&lt;CustomerOperationRepository&gt;().GetBySystemName(&quot;Webtrackingtest&quot;); <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/42e\/a4d\/2b0\/42ea4d2b0e95612531bf0b6ad066b30b.png\" alt=\"image\"\/><\/p>\n<p>  \u041e\u0436\u0438\u0434\u0430\u0435\u043c\u043e \u0432\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0447\u0443\u0434\u043e?<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">var test = mc.Repositories.Get&lt;CustomerOperationRepository&gt;().GetBySystemName(&quot;Webtrackingtest&quot;); \t\t\t test.NormalizeAndSetName(&quot;SomeOperationName&quot;); \t\t\t mc.SubmitChanges(); <\/code><\/pre>\n<p>  \u041d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e. \u0418\u043c\u044f \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/c2f\/c74\/b06\/c2fc74b06baa50854f36769ff19c1191.png\" alt=\"image\"\/><\/p>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e WebTrackingOperation \u0432 \u0431\u0430\u0437\u0443 (\u043f\u0440\u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u0432\u044b\u0448\u0435, \u043a\u043e\u0434, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u043a\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f). \u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u044d\u0442\u0430 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u0441\u044f \u0441 \u0437\u0430\u0431\u0430\u0432\u043d\u044b\u043c NullReference, \u043f\u0440\u0443\u0444:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/6c5\/e21\/7f1\/6c5e217f14f77212207f517715290a24.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0439\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u043e\u0439 Mindbox.Data.Linq.dll, \u043e\u043d\u0430 \u043f\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c LINQ to SQL. \u0418\u0437 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438 \u0440\u0430\u0437\u0443 \u043d\u0435 \u0432\u0438\u0434\u043d\u043e, \u0433\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0442\u0430\u043a \u0447\u0442\u043e \u0431\u0430\u0433 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439. \u0411\u0443\u0434\u044c\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 Inheritance Mapping\u2019\u0430.<\/p>\n<p>  \u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043e \u0437\u0430\u0431\u0430\u0432\u043d\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 CustomerOperation, \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c:<\/p>\n<pre><code class=\"cs\">var newOp = new CustomerOperation();  newOp.NormalizeAndSetName(&quot;TestForHabr&quot;); newOp.NormalizeAndSetSystemName(&quot;TestForHabr&quot;); newOp.NormalizeAndSetDescription(&quot;TestForHabr&quot;); newOp.Discriminator = &quot;WebTracking&quot;; newOp.Campaign = test.Campaign; mc.Repositories.Get&lt;CustomerOperationRepository&gt;().Add(newOp);  mc.SubmitChanges(); <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d insert \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u044f Discriminator = WebTracking, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 LINQ to SQL \u043f\u0435\u0440\u0435\u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440 \u0441\u0430\u043c \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0435\u0433\u043e setter \u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0431\u044b\u043b\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432 Inheritance Mapping \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435):<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/38b\/968\/150\/38b9681504d5a5cec47fad02ead08492.png\" alt=\"image\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u0430\u0441 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 workaround: \u0432 setter\u2019\u0435 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<h3>\u041d\u0435\u043f\u0440\u043e\u0448\u0435\u043d\u0430\u044f \u044d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>  \u0423 LINQ to SQL \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d (\u043d\u0435\u0442, \u043d\u0443 \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0438 \u0440\u0430\u0437\u0443 \u043d\u0435 \u043e\u0434\u0438\u043d, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0447\u044c \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c) \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 linq \u0431\u044b\u043b \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0435\u0433\u043e \u043d\u0435 \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u043c\u0430\u043f\u043f\u0438\u0442\u044c \u043d\u0430 sql, linq \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u044d\u043d\u0443\u043c\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043a\u0438\u0434\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u0422\u0435\u043a\u0441\u0442 \u0442\u0430\u043a\u0438\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 (\u0432\u044b\u0442\u0430\u0449\u0438\u043b \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0438\u0437 \u0431\u0430\u0433\u0442\u0440\u0435\u043a\u0435\u0440\u0430): \u201cMember access &#8216;System.DateTime DateTimeUtc&#8217; of &#8216;Itc.DirectCrm.Model.CustomerAction&#8217; not legal on type &#8216;System.Linq.IQueryable`1[Itc.DirectCrm.Model.CustomerAction]\u201d \u0438\u043b\u0438 \u201cMethod &#8216;Boolean Evaluate[CustomerLotteryTicket,Boolean](System.Linq.Expressions.Expression`1[System.Func`2[Itc.DirectCrm.Promo.CustomerLotteryTicket,System.Boolean]], Itc.DirectCrm.Promo.CustomerLotteryTicket)&#8217; has no supported translation to SQL\u201d. \u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0442\u0443\u0442 <b>\u043f\u043e\u0447\u0442\u0438<\/b>. \u0418\u043d\u043e\u0433\u0434\u0430 LINQ to SQL \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u0438\u043d\u0443\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c, \u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0443\u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c: \u044d\u0442\u043e \u043d\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043d\u0438\u043a\u0430\u043a (\u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e), \u0438\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0430\u0434\u0430\u044e\u0442 OutOfMemory (\u0442\u0430\u043a \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0443\u0436\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u043e\u043a\u0438\u043d\u0443\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0445\u043e\u0442\u044f \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0442\u044b \u0432\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0448\u044c \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f GC), \u0430 \u0442\u0430\u043a \u0436\u0435 \u0438\u0437-\u0437\u0430 \u0431\u0430\u0433\u043e\u0432 \u0441 Inheritance Mapping. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u0430\u043a\u043e\u0439 \u0431\u0430\u0433.<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u201c\u0428\u0430\u0431\u043b\u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u201d, \u043e\u043d\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043b\u044e\u0434\u0435\u0439 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0415\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b: \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u043b \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e, \u0437\u0430\u0448\u0451\u043b \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u0441\u0430\u0439\u0442\u0430, \u0432\u044b\u0438\u0433\u0440\u0430\u043b \u043f\u0440\u0438\u0437. \u0422\u0430\u043a \u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u0441\u044f\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0435\u0440\u0435\u0437 inheritance mapping. \u041a\u0443\u0441\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u043e:<\/p>\n<pre><code class=\"cs\">[Table(Name = &quot;directcrm.ActionTemplates&quot;)] [InheritanceMapping(Code = &quot;&quot;, Type = typeof(ActionTemplate), IsDefault = true)] [InheritanceMapping(Code = &quot;Hierarchical&quot;, Type = typeof(HierarchicalActionTemplate))] [InheritanceMapping(Code = &quot;CustomerToCustomer&quot;, Type = typeof(CustomerToCustomerActionTemplate))] [InheritanceMapping(Code = &quot;EmailMailing&quot;, Type = typeof(EmailMailingActionTemplate))] [InheritanceMapping(Code = &quot;SmsMailing&quot;, Type = typeof(SmsMailingActionTemplate))] [InheritanceMapping(Code = &quot;BannerCampaign&quot;, Type = typeof(BannerCampaignActionTemplate))] public class ActionTemplate : INotifyPropertyChanging, INotifyPropertyChanged, IValidatable, IEntityWithSystemName { \t\/\/ \u0442\u0443\u0442 \u0447\u0442\u043e-\u0442\u043e \u0435\u0441\u0442\u044c } <\/code><\/pre>\n<p>  \u0428\u0430\u0431\u043b\u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 id = 20 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f EmailMailingActionTemplate \u2014 Email-\u0440\u0430\u0441\u0441\u044b\u043b\u043a\u043e\u0439 (\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b), \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"cs\">var actualTemplate = modelContext.Repositories.Get&lt;ActionTemplateRepository&gt;().GetById(20); <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/fa0\/f18\/97d\/fa0f1897dd848811884d4fe12a2f9160.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0434\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u044d\u0442\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u0431\u0430\u0433\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"cs\">var test = modelContext.Repositories.Get&lt;ActionTemplateRepository&gt;() \t\t\t\t\t.Items \t\t\t\t\t.Where(at =&gt; at.Id == 20) \t\t\t\t\t.Select(at =&gt; at.EffectiveEndDateTimeUtc) \t\t\t\t\t.FirstOrDefault(); <\/code><\/pre>\n<p>  Id \u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435. EffectiveEndDateTimeUtc \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435, \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c Select \u043d\u0435 \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d AsEnumerable, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u043e \u0438\u0434\u0435\u0435 linq \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0431\u044b \u043a\u0438\u043d\u0443\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u0442\u0435\u0445 \u0441\u0430\u043c\u044b\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b \u0432\u044b\u0448\u0435. \u041d\u043e \u043d\u0435\u0442. \u0417\u0430\u043f\u0440\u043e\u0441 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 sql (\u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438):<\/p>\n<pre><code class=\"sql\">SELECT TOP (1) [t0].[Id], [t0].[CategoryId], [t0].[Name], [t0].[Type], [t0].[Discriminator], [t0].[RowVersion], [t0].[SystemName], [t0].[CreationCondition], [t0].[UsageDescription], [t0].[StartDateTimeUtcOverride], [t0].[EndDateTimeUtcOverride], [t0].[DateCreatedUtc], [t0].[DateChangedUtc], [t0].[CreatedById], [t0].[LastChangedById], [t0].[CampaignId] FROM [directcrm].[ActionTemplates] AS [t0] WHERE [t0].[Id] = @p0 <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 (\u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e Id) \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/3dc\/e59\/57c\/3dce5957c1557e1aaf9deb141cd9ef89.png\" alt=\"image\"\/><br \/>  \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u044d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043d\u0430 Inheritance Mapping, \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0411\u043e\u0439\u0442\u0435\u0441\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u044d\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0438!<\/p>\n<p>  <b>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043e\u0442 <a href=\"http:\/\/habrahabr.ru\/users\/IharBury\">IharBury<\/a>:<\/b>  <\/p>\n<blockquote><p>\u0411\u043e\u044e\u0441\u044c, \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442, \u0442\u043e \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. LINQ \u043d\u0435 \u0442\u0440\u0430\u043a\u0442\u0443\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a AsEnumerable. \u041e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u0430\u043f\u0438\u0442\u0441\u044f, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0442\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u0448\u044c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e Select \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0430 Select \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0443 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<br \/>  \u0425\u043e\u0440\u043e\u0448\u0438\u043c \u0441\u043e\u0432\u0435\u0442\u043e\u043c \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043c\u0430\u043f\u044f\u0442\u0441\u044f \u043d\u0430 SQL \u2014 \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0437\u0443 \u0431\u044b\u043b\u0430 \u0432\u0438\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<\/p><\/blockquote>\n<h3>FixedItems<\/h3>\n<p>  \u0412\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0447\u0430\u0441\u0442\u0438, \u0433\u0434\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043f\u0440\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u043c, \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">modelContext.Repositories.Get&lt;CustomerOperationRepository&gt;() \t\t\t\t.FixedItems.OfType&lt;WebTrackingOperation&gt;() \t\t\t\t.FirstOrDefault();  <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0432\u0435\u0441\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0421\u0423\u0411\u0414 \u0438\u0437 \u043a\u043e\u0434\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b-\u0445\u0435\u043b\u043f\u0435\u0440\u044b \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c (\u0443 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439 \u043c\u0435\u0442\u043e\u0434 GetByName \u0438 \u0442.\u043f.), \u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0447\u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0435\u0442\u043e\u0434, \u0442\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e Items \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e IQueryable \u043d\u0443\u0436\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041d\u043e \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0435 FixedItems \u043d\u0430 CustomerOperationRepository? \u0421\u0430\u043c\u043e\u0435 \u0437\u0430\u0431\u0430\u0432\u043d\u043e\u0435 \u2014 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e FixedItems \u0432 \u043a\u043e\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">public IQueryable&lt;TCampaignItem&gt; FixedItems { \tget \t{ \t\treturn base.Items.Select(item =&gt; item); \t} } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 LINQ to SQL. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e.<\/p>\n<p>  CustomerOperationRepository \u0434\u0430\u0451\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c CustomerOperation, \u043d\u043e \u0441\u0430\u043c\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c CustomerOperation \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 (\u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439). \u0423 \u044d\u0442\u0438\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0449\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438\u0445 \u0442\u043e\u0436\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f. \u0422\u0430\u043a \u0436\u0435 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 ICampaignItem, \u0430 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 generic\u2019\u0430:<\/p>\n<pre><code class=\"cs\">public abstract class CampaignItemRepositoryBase&lt;TCampaignItem, TInitialState&gt; \t: ChangeRestrictedExtensionSubsetRepository&lt;TCampaignItem, int, Campaign&gt;,  \t\tICampaignItemRepository, \t\tICampaignRelatedItemRepository&lt;TCampaignItem&gt;  \t\twhere TCampaignItem : class, ICampaignItem, new() \t\twhere TInitialState : CampaignItemInitialState <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043f\u043e\u043b\u044f\u043c TCampaignItem \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 ICampaignItem, \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0441\u0442\u044c <a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/5691e0ad-ad67-47ea-ae2c-9432e4e4bd46\/l2s-doesnt-like-it-when-you-wrap-column-properties-with-properties-in-an-interface?forum=linqtosql\">\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/a>, \u0447\u0442\u043e LINQ to SQL \u043d\u0435 \u043c\u0430\u043f\u043f\u0438\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0441\u0435\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0435\u0439 (Where(item =&gt; item.CampaignId == campaign.Id)), \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 InvalidOperationException: MappingOfInterfacesMemberIsNotSupported: ICampaignItem, CampaignId. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 IQueryable, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e Select(item =&gt; item) \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 object.Equals \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 ==: Where(item =&gt; Equals(item.CampaignId, campaign.Id)), \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f FixedItems.<\/p>\n<h3>Null\/Not null \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u0445<\/h3>\n<p>  \u041a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0431\u0430\u0433. LINQ to SQL \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 null \u0438 not null \u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cs\">[Table(Name = &quot;directcrm.CustomerOperations&quot;)] [InheritanceMapping(Code = &quot;&quot;, Type = typeof(CustomerOperation), IsDefault = true)] [InheritanceMapping(Code = &quot;Service&quot;, Type = typeof(CustomerServiceOperation))] [InheritanceMapping(Code = &quot;Custom&quot;, Type = typeof(CustomCustomerServiceOperation))] [InheritanceMapping(Code = &quot;PerformAction&quot;, Type = typeof(PerformActionCustomerServiceOperation))] [InheritanceMapping(Code = &quot;WebTracking&quot;, Type = typeof(WebTrackingOperation))] [InheritanceMapping(Code = &quot;IdentificationTracking&quot;, Type = typeof(IdentificationTrackingOperation))] [InheritanceMapping(Code = &quot;CustomerOperationByStaff&quot;, Type = typeof(CustomerOperationByStaff))] public class CustomerOperation : CampaignItemBase, ICampaignItem <\/code><\/pre>\n<p>  PerformActionCustomerServiceOperation \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 operationStepGroupId \u0431\u044b\u043b\u043e \u0432\u0441\u0435\u0433\u0434\u0430 (\u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c), \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u043e\u043b\u0435 operationStepGroupId \u0432 IdentificationTrackingOperation \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u2014 CustomerOperation, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e operationStepGroupId \u043d\u0435\u0442, \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0438 \u0432 PerformActionCustomerServiceOperation, \u0438 \u0432 IdentificationTrackingOperation.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f CanBeNull \u0438 \u0442\u0438\u043f \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445:<\/p>\n<pre><code class=\"cs\">public class IdentificationTrackingOperation : CustomerOperation { \tprivate int? operationStepGroupId;  \t[Column(Storage = &quot;operationStepGroupId&quot;, CanBeNull = true)] \tpublic int? OperationStepGroupId \t{ \t\tget { return operationStepGroupId; } \t\tset \t\t{ \t\t\tif (operationStepGroupId != value) \t\t\t{ \t\t\t\tSendPropertyChanging(); \t\t\t\toperationStepGroupId = value; \t\t\t\tSendPropertyChanged(); \t\t\t} \t\t} \t} }  public class PerformActionCustomerServiceOperation : CustomerServiceOperation, IPerformActionCustomerServiceOperation { \tprivate int operationStepGroupId; \tprivate EntityRef&lt;OperationStepGroup&gt; operationStepGroup;  \t[Column(Storage = &quot;operationStepGroupId&quot;, CanBeNull = false)] \tpublic int OperationStepGroupId \t{ \t\tget { return operationStepGroupId; } \t\tset \t\t{ \t\t\tif (operationStepGroupId != value) \t\t\t{ \t\t\t\tSendPropertyChanging(); \t\t\t\toperationStepGroupId = value; \t\t\t\tSendPropertyChanged(); \t\t\t} \t\t} \t} } <\/code><\/pre>\n<p>  \u041d\u0443, \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0431\u0430\u0437\u044b \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041e\u0434\u043d\u0430 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u2014 IdentificationTrackingOperation, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 OperationStepGroupId.<\/p>\n<p>  \u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c InvalidOperationException: CannotAssignNull: System.Int32.<\/p>\n<p>  \u041a\u0430\u043a \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f? \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0434\u043b\u044f LINQ \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b\u0438 \u0432 PerformActionCustomerServiceOperation \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f OperationStepGroupId, \u0438 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c.<\/p>\n<h3>\u0422\u0435\u043c, \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b, \u0441\u044e\u0440\u043f\u0440\u0438\u0437<\/h3>\n<p>  \u0412\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 LINQ \u0443 \u043c\u0435\u043d\u044f \u043d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0430\u0445 \u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u0441\u0431\u043e\u0440\u043a\u0435 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Mindbox.Data.Linq.dll. \u0414\u0430, \u043c\u044b \u0444\u043e\u0440\u043a\u043d\u0443\u043b\u0438 LINQ to SQL. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e InheritanceMappingAttribute, \u043d\u043e \u0438 \u043c\u0435\u0442\u043e\u0434 void AddInheritance&lt;TRoot, T&gt;(object code) \u043d\u0430 Mindbox.Data.Linq.Mapping.MindboxMappingConfiguration, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0431\u043e\u0440\u043a\u0430\u0445.<\/p>\n<p>  \u041d\u0430\u0448 \u0444\u043e\u0440\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Nuget: <a href=\"https:\/\/www.nuget.org\/packages\/Mindbox.Data.Linq\">Mindbox.Data.Linq<\/a>. <\/p>\n<p>  \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0447\u0435\u043c-\u0442\u043e \u043f\u043e\u043c\u043e\u0447\u044c \u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u2014 \u0443\u0434\u0430\u0447\u0438 \u0441 \u044d\u0442\u0438\u043c.      \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\/253779\/\"> http:\/\/habrahabr.ru\/post\/253779\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u0421 <a href=\"http:\/\/habrahabr.ru\/post\/250759\">\u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430<\/a> \u043f\u0440\u043e\u0448\u0451\u043b \u043c\u0435\u0441\u044f\u0446, \u043f\u043e-\u043c\u043e\u0435\u043c\u0443 \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 Inheritance Mapping\u2019\u0435, \u043d\u0443 \u0430 \u043e\u0441\u043e\u0431\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0436\u0434\u0451\u0442 \u0441\u044e\u0440\u043f\u0440\u0438\u0437. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0451\u043c. <\/p>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u043c<\/h3>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0432 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c CustomerOperation, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043d\u0430\u0434 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u043c. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a CustomerServiceOperation, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c WebTracking\u2019\u0430, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0435\u0441\u0442\u044c WebTrackingOperation. \u041d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0432, \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u043e\u0434:  <\/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-253603","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253603","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=253603"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253603\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=253603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=253603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=253603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}