{"id":256190,"date":"2015-04-28T12:39:02","date_gmt":"2015-04-28T08:39:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=256190"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=256190","title":{"rendered":"\u041f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b IQueryable \u0438 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445"},"content":{"rendered":"<p> \t\t\t\u0421\u0440\u0435\u0434\u0441\u0442\u0432\u0430 LINQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 .Net-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0430\u043a \u0438 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u043c\u0438\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u0435\u0441\u044f\u0442\u0438 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u044f\u0431\u043b\u043e\u043a \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0438\u0437 \u0411\u0414 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Entity Framework \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434: <\/p>\n<pre><code class=\"cs\">List&lt;Apple&gt; appleList;  DbSet&lt;Apple&gt; appleDbSet; var applesFromList = appleList.Where(apple =&gt; apple.Color == \u201cred\u201d).Take(10); var applesFromDb = appleDbSet.Where(apple =&gt; apple.Color == \u201cred\u201d).Take(10); <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e foreach \u044f\u0431\u043b\u043e\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0432\u0437\u044f\u0442\u044b \u043f\u0435\u0440\u0432\u044b\u0435 10 \u0438\u0437 \u043d\u0438\u0445. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0434\u043b\u044f 10 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0421# \u0438 \u0432\u0435\u0440\u043d\u0435\u0442 \u0438\u0445. \u041e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IQueryable&lt;T&gt;, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0438\u0436\u0435 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b IEnumerable&lt;T&gt; \u0438 IQueryable&lt;T&gt;<\/h2>\n<p>  \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 LINQ \u043b\u0435\u0436\u0438\u0442 \u043d\u0430\u0431\u043e\u0440 \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0432\u0440\u043e\u0434\u0435 Where(), Select(), First(), Count() \u0438 \u0442.\u0434. \u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 IEnumerable&lt;T&gt;, \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0434\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a\u0430\u043a \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 (LINQ to Objects), \u0442\u0430\u043a \u0438 \u043a \u0431\u0430\u0437\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, LINQ to SQL, LINQ to Entities) \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, LINQ to OData Services). \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043a IEnumerable&lt;T&gt; \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0422\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0442\u043e\u0434 First&lt;TSource&gt;(Func&lt;TSource, bool&gt; predicate) \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 .Net Framework 4.5.2, \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b <a href=\"http:\/\/referencesource.microsoft.com\/#System.Core\/System\/Linq\/Enumerable.cs\">\u0437\u0434\u0435\u0441\u044c<\/a>, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <\/p>\n<pre><code class=\"cs\">public static TSource First&lt;TSource&gt;(this IEnumerable&lt;TSource&gt; source, Func&lt;TSource, bool&gt; predicate) {     if (source == null) throw Error.ArgumentNull(&quot;source&quot;);     if (predicate == null) throw Error.ArgumentNull(&quot;predicate&quot;);     foreach (TSource element in source) {           if (predicate(element)) return element;     }     throw Error.NoMatch(); } <\/code><\/pre>\n<p>  \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043d\u0430\u0434 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0411\u0414 \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0435. \u0414\u043b\u044f \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IQueryable&lt;T&gt; (\u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a \u043e\u0442 IEnumerable&lt;T&gt;) \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439, \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0445 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u043b\u044f IEnumerable&lt;T&gt;. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e List&lt;T&gt; \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 IEnumerable&lt;T&gt;, \u0430 DbSet&lt;T&gt; \u0438\u0437 Entity Framework \u2013 IQueryable&lt;T&gt;, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u044f\u0431\u043b\u043e\u043a\u0430\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443.<\/p>\n<p>  \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043a IQueryable&lt;T&gt; \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043b\u043e\u0433\u0438\u043a\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u00ab\u043d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u044f\u00bb \u0435\u0435 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u043e\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435. \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0436\u0435 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 (Count() \u0438 \u0442.\u043f.) \u0438\u043b\u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e foreach \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 IQueryable&lt;T&gt;, \u0430 \u0442\u043e\u0442 \u0443\u0436\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u044f\u0437\u044b\u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0435\u0433\u043e. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 Entity Framework \u0442\u0430\u043a\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f SQL, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 .Net-\u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c \u0434\u043b\u044f MongoDb \u2013 \u044d\u0442\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 json-\u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0442.\u0434.<\/p>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438 \u0433\u043e\u0432\u043e\u0440\u044f, \u0438\u0437 \u044d\u0442\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0442\u0435\u043a\u0430\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u00ab\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435\u00bb \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432:  <\/p>\n<ul>\n<li>\u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u043c, \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c; \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0443\u0437\u043d\u0430\u0435\u043c \u043c\u044b \u043e\u0431 \u044d\u0442\u043e\u043c \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u043c; <\/li>\n<li>\u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e \u0432\u0441\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0438 \u0442.\u0434. <\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0414\u0435\u043b\u0430\u0435\u043c LINQ \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438: ISimpleQueryable&lt;T&gt; <\/h2>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 IQueryable&lt;T&gt;, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 \u2013 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ISimpleQueryable&lt;T&gt;, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043a \u043d\u0435\u043c\u0443 \u0432 \u0441\u0442\u0438\u043b\u0435 LINQ. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 IQueryable&lt;T&gt;, \u043d\u0435 \u0432\u0434\u0430\u0432\u0430\u044f\u0441\u044c \u043f\u043e\u043a\u0430 \u0432 \u043d\u044e\u0430\u043d\u0441\u044b \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.  <\/p>\n<pre><code class=\"cs\">public interface ISimpleQueryable&lt;TSource&gt; : IEnumerable&lt;TSource&gt; {     string QueryDescription { get; }     ISimpleQueryable&lt;TSource&gt; CreateNewQueryable(string queryDescription);     TResult Execute&lt;TResult&gt;(); } <\/code><\/pre>\n<p>  \u0412 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e QueryDescription, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u0435\u0442\u043e\u0434 Execute&lt;TResult&gt;(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c. \u042d\u0442\u043e generic-\u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u043a Count(). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 CreateNewQueryable(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e LINQ-\u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 ISimpleQueryable&lt;T&gt;, \u043d\u043e \u0443\u0436\u0435 \u0441 \u043d\u043e\u0432\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0417\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0430 \u0432 LINQ \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 (Expression Trees), \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/msdn.microsoft.com\/ru-ru\/library\/bb397951.aspx\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/83169\/\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c:<\/p>\n<pre><code class=\"cs\">public static class SimpleQueryableExtentions  {     public static ISimpleQueryable&lt;TSource&gt; Where&lt;TSource&gt;(this ISimpleQueryable&lt;TSource&gt; queryable,                                                             Expression&lt;Func&lt;TSource, bool&gt;&gt; predicate) {         string newQueryDescription = queryable.QueryDescription + &quot;.Where(&quot; + predicate.ToString() + &quot;)&quot;;         return queryable.CreateNewQueryable(newQueryDescription);     }        public static int Count&lt;TSource&gt;(this ISimpleQueryable&lt;TSource&gt; queryable) {         string newQueryDescription = queryable.QueryDescription + &quot;.Count()&quot;;         ISimpleQueryable&lt;TSource&gt; newQueryable = queryable.CreateNewQueryable(newQueryDescription);         return newQueryable.Execute&lt;int&gt;();     } } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u0431\u0435 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 ISimpleQueryable&lt;T&gt;. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u0435\u0442\u043e\u0434 Where(), \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 \u0434\u043b\u044f IEnumerable&lt;T&gt;, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435 \u0441\u0430\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 Func&lt;TSource, bool&gt;, \u0430 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0435 \u0440\u0430\u043d\u0435\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f (expression tree) \u0441 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c Expression&lt;Func&lt;TSource, bool&gt;&gt;. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043a\u043e\u0434\u043e\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c LINQ \u2013 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e ISimpleQueryable&lt;T&gt;, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f LINQ-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043f\u0440\u0438\u0434\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0443\u0434\u0430 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 (_dataSource), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u043c Execute().<\/p>\n<pre><code class=\"cs\">public class FakeSimpleQueryable&lt;TSource&gt; : ISimpleQueryable&lt;TSource&gt; {     private readonly object _dataSource;     public string QueryDescription { get; private set; }      public FakeSimpleQueryable(string queryDescription, object dataSource) {         _dataSource = dataSource;         QueryDescription = queryDescription;     }          public ISimpleQueryable&lt;TSource&gt; CreateNewQueryable(string queryDescription) {         return new FakeSimpleQueryable&lt;TSource&gt;(queryDescription, _dataSource);     }      public TResult Execute&lt;TResult&gt;() {         \/\/\u0417\u0434\u0435\u0441\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 QueryDescription \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a dataSource         throw new NotImplementedException();     }          public IEnumerator&lt;TSource&gt; GetEnumerator() {         return Execute&lt;IEnumerator&lt;TSource&gt;&gt;();     }      IEnumerator IEnumerable.GetEnumerator() {         return GetEnumerator();     } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a FakeSimpleQueryable: <\/p>\n<pre><code class=\"cs\">var provider = new FakeSimpleQueryable&lt;string&gt;(&quot;&quot;, null); int result = provider.Where(s =&gt; s.Contains(&quot;substring&quot;)).Where(s =&gt; s != &quot;some string&quot;).Count(); <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c, \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0430 (\u0441\u043c. \u0442\u0430\u043a\u0436\u0435 \u0440\u0438\u0441\u0443\u043d\u043e\u043a \u043d\u0438\u0436\u0435):  <\/p>\n<ul>\n<li>\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 Where() \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 FakeSimpleQueryable \u043f\u0443\u0441\u0442\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043a \u043d\u0435\u043c\u0443 &quot;.Where(s =&gt; s.Contains(\u00absubstring\u00bb))&quot; \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 FakeSimpleQueryable \u0441 \u043d\u043e\u0432\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c;<\/li>\n<li>\u0437\u0430\u0442\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 Where() \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0435\u0435 FakeSimpleQueryable \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043a \u043d\u0435\u043c\u0443 &quot;.Where(s =&gt; s != \u00absome string\u00bb)&quot;, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043e\u043f\u044f\u0442\u044c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439, \u0442\u0440\u0435\u0442\u0438\u0439 \u043f\u043e \u0441\u0447\u0435\u0442\u0443, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 FakeSimpleQueryable \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 &quot;.Where(s =&gt; s.Contains(\u00absubstring\u00bb)).Where(s =&gt; s != \u00absome string\u00bb)&quot;;<\/li>\n<li>\u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b\u0437\u043e\u0432 Count() \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 FakeSimpleQueryable \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043a \u043d\u0435\u043c\u0443 &quot; .Count()&quot; \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 FakeSimpleQueryable, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0443 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 Execute&lt;int&gt;, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e;<\/li>\n<li>\u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 Execute() \u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 QueryDescription, \u0440\u0430\u0432\u043d\u043e\u0435 &quot;.Where(s =&gt; s.Contains(\u00absubstring\u00bb)).Where(s =&gt; s != \u00absome string\u00bb).Count()&quot;, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/160\/2d9\/5d9\/1602d95d966d458f8cd7b727208cbf0e.png\"\/><\/p>\n<h2>\u041d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 IQueryable&lt;T&gt;\u2026 \u0438 IQueryProvider&lt;T&gt;<\/h2>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043f\u0435\u0440\u044c, \u0447\u0442\u043e \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IQueryable&lt;T&gt;, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 .Net:  <\/p>\n<pre><code class=\"cs\">public interface IQueryable : IEnumerable {     Expression Expression { get; }     Type ElementType { get; }     IQueryProvider Provider { get; } }   public interface IQueryable&lt;out T&gt; : IEnumerable&lt;T&gt;, IQueryable {}   public interface IQueryProvider {     IQueryable CreateQuery(Expression expression);     IQueryable&lt;TElement&gt; CreateQuery&lt;TElement&gt;(Expression expression);     object Execute(Expression expression);     TResult Execute&lt;TResult&gt;(Expression expression); } <\/code><\/pre>\n<p>  \u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e:  <\/p>\n<ul>\n<li>\u0432 .Net \u0435\u0441\u0442\u044c generic- \u0438 \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f IQueryable;<\/li>\n<li>\u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c LINQ-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e Expression (\u0432 \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0441\u0442\u0440\u043e\u0447\u043d\u043e\u0435 QueryDescription); <\/li>\n<li>\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e ElementType \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0438\u043f\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0442\u0438\u043f\u043e\u0432;<\/li>\n<li>\u043f\u0430\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 IQueryable (CreateQuery() \u0438 CreateQuery&lt;TElement&gt;()), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (Execute() \u0438 Execute&lt;TResult&gt;()) \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IQueryProvider&lt;T&gt;; \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u043e\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043e\u0442 \u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u00ab\u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u044b\u043c\u00bb \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f;<\/li>\n<li>\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e IQueryable.Provider \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 IQueryProvider.<\/li>\n<\/ul>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043a IQueryable&lt;T&gt; \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 Where():  <\/p>\n<pre><code class=\"cs\">public static IQueryable&lt;TSource&gt; Where&lt;TSource&gt;(this IQueryable&lt;TSource&gt; source, Expression&lt;Func&lt;TSource, int, bool&gt;&gt; predicate) {     if (source == null) throw Error.ArgumentNull(&quot;source&quot;);     if (predicate == null) throw Error.ArgumentNull(&quot;predicate&quot;);     return source.Provider.CreateQuery&lt;TSource&gt;(          Expression.Call(            null,             ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),             new Expression[] { source.Expression, Expression.Quote(predicate) }            )); } <\/code><\/pre>\n<p>  \u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 IQueryable&lt;TSource&gt;, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432 CreateQuery&lt;TSource&gt;() \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0438\u0437 source.Expression \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432\u044b\u0437\u043e\u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0435\u0442\u043e\u0434\u0430 Where() \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. <\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 IQueryable&lt;T&gt; \u0438 IQueryProvider&lt;T&gt; \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438 \u0440\u0430\u043d\u0435\u0435 ISimpleQueryable&lt;T&gt;, \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 LINQ \u0442\u0435 \u0436\u0435: \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0442\u043e\u0434-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443, \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0441\u0435\u0431\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 IQueryable&lt;T&gt; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 CreateQuery&lt;T&gt;(), \u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u044e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434 Execute&lt;T&gt;().<\/p>\n<h2>\u041f\u0430\u0440\u0430 \u0441\u043b\u043e\u0432 \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432<\/h2>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f LINQ-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 .Net \u0437\u0430 \u043d\u0430\u0441, \u0442\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u0432\u043e\u0435\u043c \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 Execute() \u0438 Execute&lt;TResult&gt;(). \u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0435\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 expression tree, \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u044f\u0437\u044b\u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 C#-\u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0445. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0435\u043c\u0430\u043b\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043d\u044e\u0430\u043d\u0441\u043e\u0432. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u0430\u043b\u043e. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0435, \u043f\u043e \u043c\u043d\u0435\u043d\u0438\u044e \u0430\u0432\u0442\u043e\u0440\u0430, \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443:   <\/p>\n<ul>\n<li><a href=\"http:\/\/blogs.msdn.com\/b\/mattwar\/archive\/2008\/11\/18\/linq-links.aspx\">LINQ: Building an IQueryable provider series,<\/a><\/li>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/vstudio\/bb546158(v=vs.110).aspx\">Walkthrough: Creating an IQueryable LINQ Provider<\/a><\/li>\n<\/ul>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043f\u043e\u0434\u0441\u0442\u0443\u043f\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0440\u0435\u0448\u0430\u043b\u0441\u044f. \t\t\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\/256821\/\"> http:\/\/habrahabr.ru\/post\/256821\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t\u0421\u0440\u0435\u0434\u0441\u0442\u0432\u0430 LINQ \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 .Net-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0430\u043a \u0438 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u043c\u0438\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u0435\u0441\u044f\u0442\u0438 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u044f\u0431\u043b\u043e\u043a \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0438\u0437 \u0411\u0414 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Entity Framework \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434: <\/p>\n<pre><code class=\"cs\">List&lt;Apple&gt; appleList;  DbSet&lt;Apple&gt; appleDbSet; var applesFromList = appleList.Where(apple =&gt; apple.Color == \u201cred\u201d).Take(10); var applesFromDb = appleDbSet.Where(apple =&gt; apple.Color == \u201cred\u201d).Take(10); <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e foreach \u044f\u0431\u043b\u043e\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0432\u0437\u044f\u0442\u044b \u043f\u0435\u0440\u0432\u044b\u0435 10 \u0438\u0437 \u043d\u0438\u0445. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 SQL-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0434\u043b\u044f 10 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0421# \u0438 \u0432\u0435\u0440\u043d\u0435\u0442 \u0438\u0445. \u041e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IQueryable&lt;T&gt;, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f LINQ-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0438\u0436\u0435 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.  <\/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-256190","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256190","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=256190"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256190\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}