1
0

AsyncQueryable.Generated.cs 165 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using System.Reflection;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace System.Linq
  8. {
  9. public static partial class AsyncQueryable
  10. {
  11. public static Task<TSource> Aggregate<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  12. {
  13. if (source == null)
  14. throw new ArgumentNullException("source");
  15. if (accumulator == null)
  16. throw new ArgumentNullException("accumulator");
  17. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None);
  18. }
  19. public static Task<TSource> Aggregate<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator, CancellationToken cancellationToken)
  20. {
  21. if (source == null)
  22. throw new ArgumentNullException("source");
  23. if (accumulator == null)
  24. throw new ArgumentNullException("accumulator");
  25. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  26. }
  27. public static Task<TAccumulate> Aggregate<TSource, TAccumulate>(this IAsyncQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  28. {
  29. if (source == null)
  30. throw new ArgumentNullException("source");
  31. if (accumulator == null)
  32. throw new ArgumentNullException("accumulator");
  33. return source.Provider.ExecuteAsync<TAccumulate>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None);
  34. }
  35. public static Task<TAccumulate> Aggregate<TSource, TAccumulate>(this IAsyncQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator, CancellationToken cancellationToken)
  36. {
  37. if (source == null)
  38. throw new ArgumentNullException("source");
  39. if (accumulator == null)
  40. throw new ArgumentNullException("accumulator");
  41. return source.Provider.ExecuteAsync<TAccumulate>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  42. }
  43. public static Task<TResult> Aggregate<TSource, TAccumulate, TResult>(this IAsyncQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator, Expression<Func<TAccumulate, TResult>> resultSelector)
  44. {
  45. if (source == null)
  46. throw new ArgumentNullException("source");
  47. if (accumulator == null)
  48. throw new ArgumentNullException("accumulator");
  49. if (resultSelector == null)
  50. throw new ArgumentNullException("resultSelector");
  51. return source.Provider.ExecuteAsync<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None);
  52. }
  53. public static Task<TResult> Aggregate<TSource, TAccumulate, TResult>(this IAsyncQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator, Expression<Func<TAccumulate, TResult>> resultSelector, CancellationToken cancellationToken)
  54. {
  55. if (source == null)
  56. throw new ArgumentNullException("source");
  57. if (accumulator == null)
  58. throw new ArgumentNullException("accumulator");
  59. if (resultSelector == null)
  60. throw new ArgumentNullException("resultSelector");
  61. return source.Provider.ExecuteAsync<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  62. }
  63. public static Task<bool> All<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  64. {
  65. if (source == null)
  66. throw new ArgumentNullException("source");
  67. if (predicate == null)
  68. throw new ArgumentNullException("predicate");
  69. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  70. }
  71. public static Task<bool> All<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  72. {
  73. if (source == null)
  74. throw new ArgumentNullException("source");
  75. if (predicate == null)
  76. throw new ArgumentNullException("predicate");
  77. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  78. }
  79. public static Task<bool> Any<TSource>(this IAsyncQueryable<TSource> source)
  80. {
  81. if (source == null)
  82. throw new ArgumentNullException("source");
  83. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  84. }
  85. public static Task<bool> Any<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  86. {
  87. if (source == null)
  88. throw new ArgumentNullException("source");
  89. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  90. }
  91. public static Task<bool> Any<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  92. {
  93. if (source == null)
  94. throw new ArgumentNullException("source");
  95. if (predicate == null)
  96. throw new ArgumentNullException("predicate");
  97. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  98. }
  99. public static Task<bool> Any<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  100. {
  101. if (source == null)
  102. throw new ArgumentNullException("source");
  103. if (predicate == null)
  104. throw new ArgumentNullException("predicate");
  105. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  106. }
  107. public static Task<double> Average(this IAsyncQueryable<int> source)
  108. {
  109. if (source == null)
  110. throw new ArgumentNullException("source");
  111. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  112. }
  113. public static Task<double?> Average(this IAsyncQueryable<int?> source)
  114. {
  115. if (source == null)
  116. throw new ArgumentNullException("source");
  117. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  118. }
  119. public static Task<double> Average(this IAsyncQueryable<long> source)
  120. {
  121. if (source == null)
  122. throw new ArgumentNullException("source");
  123. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  124. }
  125. public static Task<double?> Average(this IAsyncQueryable<long?> source)
  126. {
  127. if (source == null)
  128. throw new ArgumentNullException("source");
  129. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  130. }
  131. public static Task<double> Average(this IAsyncQueryable<double> source)
  132. {
  133. if (source == null)
  134. throw new ArgumentNullException("source");
  135. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  136. }
  137. public static Task<double?> Average(this IAsyncQueryable<double?> source)
  138. {
  139. if (source == null)
  140. throw new ArgumentNullException("source");
  141. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  142. }
  143. public static Task<float> Average(this IAsyncQueryable<float> source)
  144. {
  145. if (source == null)
  146. throw new ArgumentNullException("source");
  147. return source.Provider.ExecuteAsync<float>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  148. }
  149. public static Task<float?> Average(this IAsyncQueryable<float?> source)
  150. {
  151. if (source == null)
  152. throw new ArgumentNullException("source");
  153. return source.Provider.ExecuteAsync<float?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  154. }
  155. public static Task<decimal> Average(this IAsyncQueryable<decimal> source)
  156. {
  157. if (source == null)
  158. throw new ArgumentNullException("source");
  159. return source.Provider.ExecuteAsync<decimal>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  160. }
  161. public static Task<decimal?> Average(this IAsyncQueryable<decimal?> source)
  162. {
  163. if (source == null)
  164. throw new ArgumentNullException("source");
  165. return source.Provider.ExecuteAsync<decimal?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  166. }
  167. public static Task<double> Average(this IAsyncQueryable<int> source, CancellationToken cancellationToken)
  168. {
  169. if (source == null)
  170. throw new ArgumentNullException("source");
  171. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  172. }
  173. public static Task<double?> Average(this IAsyncQueryable<int?> source, CancellationToken cancellationToken)
  174. {
  175. if (source == null)
  176. throw new ArgumentNullException("source");
  177. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  178. }
  179. public static Task<double> Average(this IAsyncQueryable<long> source, CancellationToken cancellationToken)
  180. {
  181. if (source == null)
  182. throw new ArgumentNullException("source");
  183. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  184. }
  185. public static Task<double?> Average(this IAsyncQueryable<long?> source, CancellationToken cancellationToken)
  186. {
  187. if (source == null)
  188. throw new ArgumentNullException("source");
  189. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  190. }
  191. public static Task<double> Average(this IAsyncQueryable<double> source, CancellationToken cancellationToken)
  192. {
  193. if (source == null)
  194. throw new ArgumentNullException("source");
  195. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  196. }
  197. public static Task<double?> Average(this IAsyncQueryable<double?> source, CancellationToken cancellationToken)
  198. {
  199. if (source == null)
  200. throw new ArgumentNullException("source");
  201. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  202. }
  203. public static Task<float> Average(this IAsyncQueryable<float> source, CancellationToken cancellationToken)
  204. {
  205. if (source == null)
  206. throw new ArgumentNullException("source");
  207. return source.Provider.ExecuteAsync<float>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  208. }
  209. public static Task<float?> Average(this IAsyncQueryable<float?> source, CancellationToken cancellationToken)
  210. {
  211. if (source == null)
  212. throw new ArgumentNullException("source");
  213. return source.Provider.ExecuteAsync<float?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  214. }
  215. public static Task<decimal> Average(this IAsyncQueryable<decimal> source, CancellationToken cancellationToken)
  216. {
  217. if (source == null)
  218. throw new ArgumentNullException("source");
  219. return source.Provider.ExecuteAsync<decimal>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  220. }
  221. public static Task<decimal?> Average(this IAsyncQueryable<decimal?> source, CancellationToken cancellationToken)
  222. {
  223. if (source == null)
  224. throw new ArgumentNullException("source");
  225. return source.Provider.ExecuteAsync<decimal?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  226. }
  227. public static Task<double?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int?>> selector)
  228. {
  229. if (source == null)
  230. throw new ArgumentNullException("source");
  231. if (selector == null)
  232. throw new ArgumentNullException("selector");
  233. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  234. }
  235. public static Task<double> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int>> selector)
  236. {
  237. if (source == null)
  238. throw new ArgumentNullException("source");
  239. if (selector == null)
  240. throw new ArgumentNullException("selector");
  241. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  242. }
  243. public static Task<double> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long>> selector)
  244. {
  245. if (source == null)
  246. throw new ArgumentNullException("source");
  247. if (selector == null)
  248. throw new ArgumentNullException("selector");
  249. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  250. }
  251. public static Task<double?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long?>> selector)
  252. {
  253. if (source == null)
  254. throw new ArgumentNullException("source");
  255. if (selector == null)
  256. throw new ArgumentNullException("selector");
  257. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  258. }
  259. public static Task<double> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double>> selector)
  260. {
  261. if (source == null)
  262. throw new ArgumentNullException("source");
  263. if (selector == null)
  264. throw new ArgumentNullException("selector");
  265. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  266. }
  267. public static Task<double?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double?>> selector)
  268. {
  269. if (source == null)
  270. throw new ArgumentNullException("source");
  271. if (selector == null)
  272. throw new ArgumentNullException("selector");
  273. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  274. }
  275. public static Task<float> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float>> selector)
  276. {
  277. if (source == null)
  278. throw new ArgumentNullException("source");
  279. if (selector == null)
  280. throw new ArgumentNullException("selector");
  281. return source.Provider.ExecuteAsync<float>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  282. }
  283. public static Task<float?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float?>> selector)
  284. {
  285. if (source == null)
  286. throw new ArgumentNullException("source");
  287. if (selector == null)
  288. throw new ArgumentNullException("selector");
  289. return source.Provider.ExecuteAsync<float?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  290. }
  291. public static Task<decimal> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal>> selector)
  292. {
  293. if (source == null)
  294. throw new ArgumentNullException("source");
  295. if (selector == null)
  296. throw new ArgumentNullException("selector");
  297. return source.Provider.ExecuteAsync<decimal>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  298. }
  299. public static Task<decimal?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  300. {
  301. if (source == null)
  302. throw new ArgumentNullException("source");
  303. if (selector == null)
  304. throw new ArgumentNullException("selector");
  305. return source.Provider.ExecuteAsync<decimal?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  306. }
  307. public static Task<double?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int?>> selector, CancellationToken cancellationToken)
  308. {
  309. if (source == null)
  310. throw new ArgumentNullException("source");
  311. if (selector == null)
  312. throw new ArgumentNullException("selector");
  313. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  314. }
  315. public static Task<double> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken cancellationToken)
  316. {
  317. if (source == null)
  318. throw new ArgumentNullException("source");
  319. if (selector == null)
  320. throw new ArgumentNullException("selector");
  321. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  322. }
  323. public static Task<double> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken cancellationToken)
  324. {
  325. if (source == null)
  326. throw new ArgumentNullException("source");
  327. if (selector == null)
  328. throw new ArgumentNullException("selector");
  329. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  330. }
  331. public static Task<double?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long?>> selector, CancellationToken cancellationToken)
  332. {
  333. if (source == null)
  334. throw new ArgumentNullException("source");
  335. if (selector == null)
  336. throw new ArgumentNullException("selector");
  337. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  338. }
  339. public static Task<double> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken cancellationToken)
  340. {
  341. if (source == null)
  342. throw new ArgumentNullException("source");
  343. if (selector == null)
  344. throw new ArgumentNullException("selector");
  345. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  346. }
  347. public static Task<double?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double?>> selector, CancellationToken cancellationToken)
  348. {
  349. if (source == null)
  350. throw new ArgumentNullException("source");
  351. if (selector == null)
  352. throw new ArgumentNullException("selector");
  353. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  354. }
  355. public static Task<float> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken cancellationToken)
  356. {
  357. if (source == null)
  358. throw new ArgumentNullException("source");
  359. if (selector == null)
  360. throw new ArgumentNullException("selector");
  361. return source.Provider.ExecuteAsync<float>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  362. }
  363. public static Task<float?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float?>> selector, CancellationToken cancellationToken)
  364. {
  365. if (source == null)
  366. throw new ArgumentNullException("source");
  367. if (selector == null)
  368. throw new ArgumentNullException("selector");
  369. return source.Provider.ExecuteAsync<float?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  370. }
  371. public static Task<decimal> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken cancellationToken)
  372. {
  373. if (source == null)
  374. throw new ArgumentNullException("source");
  375. if (selector == null)
  376. throw new ArgumentNullException("selector");
  377. return source.Provider.ExecuteAsync<decimal>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  378. }
  379. public static Task<decimal?> Average<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector, CancellationToken cancellationToken)
  380. {
  381. if (source == null)
  382. throw new ArgumentNullException("source");
  383. if (selector == null)
  384. throw new ArgumentNullException("selector");
  385. return source.Provider.ExecuteAsync<decimal?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  386. }
  387. public static IAsyncQueryable<IList<TSource>> Buffer<TSource>(this IAsyncQueryable<TSource> source, int count)
  388. {
  389. if (source == null)
  390. throw new ArgumentNullException("source");
  391. return source.Provider.CreateQuery<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int))));
  392. }
  393. public static IAsyncQueryable<IList<TSource>> Buffer<TSource>(this IAsyncQueryable<TSource> source, int count, int skip)
  394. {
  395. if (source == null)
  396. throw new ArgumentNullException("source");
  397. return source.Provider.CreateQuery<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int))));
  398. }
  399. public static IAsyncQueryable<TResult> Cast<TResult>(this IAsyncQueryable<object> source)
  400. {
  401. if (source == null)
  402. throw new ArgumentNullException("source");
  403. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression));
  404. }
  405. public static IAsyncQueryable<TSource> Catch<TSource, TException>(this IAsyncQueryable<TSource> source, Expression<Func<TException, IAsyncEnumerable<TSource>>> handler)
  406. {
  407. if (source == null)
  408. throw new ArgumentNullException("source");
  409. if (handler == null)
  410. throw new ArgumentNullException("handler");
  411. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler));
  412. }
  413. public static IAsyncQueryable<TSource> Catch<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  414. {
  415. if (first == null)
  416. throw new ArgumentNullException("first");
  417. if (second == null)
  418. throw new ArgumentNullException("second");
  419. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)));
  420. }
  421. public static IAsyncQueryable<TSource> Concat<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  422. {
  423. if (first == null)
  424. throw new ArgumentNullException("first");
  425. if (second == null)
  426. throw new ArgumentNullException("second");
  427. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)));
  428. }
  429. public static Task<bool> Contains<TSource>(this IAsyncQueryable<TSource> source, TSource value)
  430. {
  431. if (source == null)
  432. throw new ArgumentNullException("source");
  433. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None);
  434. }
  435. public static Task<bool> Contains<TSource>(this IAsyncQueryable<TSource> source, TSource value, CancellationToken cancellationToken)
  436. {
  437. if (source == null)
  438. throw new ArgumentNullException("source");
  439. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  440. }
  441. public static Task<bool> Contains<TSource>(this IAsyncQueryable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
  442. {
  443. if (source == null)
  444. throw new ArgumentNullException("source");
  445. if (comparer == null)
  446. throw new ArgumentNullException("comparer");
  447. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))), CancellationToken.None);
  448. }
  449. public static Task<bool> Contains<TSource>(this IAsyncQueryable<TSource> source, TSource value, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
  450. {
  451. if (source == null)
  452. throw new ArgumentNullException("source");
  453. if (comparer == null)
  454. throw new ArgumentNullException("comparer");
  455. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer<TSource>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  456. }
  457. public static Task<int> Count<TSource>(this IAsyncQueryable<TSource> source)
  458. {
  459. if (source == null)
  460. throw new ArgumentNullException("source");
  461. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  462. }
  463. public static Task<int> Count<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  464. {
  465. if (source == null)
  466. throw new ArgumentNullException("source");
  467. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  468. }
  469. public static Task<int> Count<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  470. {
  471. if (source == null)
  472. throw new ArgumentNullException("source");
  473. if (predicate == null)
  474. throw new ArgumentNullException("predicate");
  475. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  476. }
  477. public static Task<int> Count<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  478. {
  479. if (source == null)
  480. throw new ArgumentNullException("source");
  481. if (predicate == null)
  482. throw new ArgumentNullException("predicate");
  483. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  484. }
  485. public static IAsyncQueryable<TSource> DefaultIfEmpty<TSource>(this IAsyncQueryable<TSource> source)
  486. {
  487. if (source == null)
  488. throw new ArgumentNullException("source");
  489. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  490. }
  491. public static IAsyncQueryable<TSource> DefaultIfEmpty<TSource>(this IAsyncQueryable<TSource> source, TSource defaultValue)
  492. {
  493. if (source == null)
  494. throw new ArgumentNullException("source");
  495. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(defaultValue, typeof(TSource))));
  496. }
  497. public static IAsyncQueryable<TSource> Distinct<TSource>(this IAsyncQueryable<TSource> source)
  498. {
  499. if (source == null)
  500. throw new ArgumentNullException("source");
  501. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  502. }
  503. public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  504. {
  505. if (source == null)
  506. throw new ArgumentNullException("source");
  507. if (keySelector == null)
  508. throw new ArgumentNullException("keySelector");
  509. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  510. }
  511. public static IAsyncQueryable<TSource> Distinct<TSource>(this IAsyncQueryable<TSource> source, IEqualityComparer<TSource> comparer)
  512. {
  513. if (source == null)
  514. throw new ArgumentNullException("source");
  515. if (comparer == null)
  516. throw new ArgumentNullException("comparer");
  517. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))));
  518. }
  519. public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  520. {
  521. if (source == null)
  522. throw new ArgumentNullException("source");
  523. if (keySelector == null)
  524. throw new ArgumentNullException("keySelector");
  525. if (comparer == null)
  526. throw new ArgumentNullException("comparer");
  527. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  528. }
  529. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource>(this IAsyncQueryable<TSource> source)
  530. {
  531. if (source == null)
  532. throw new ArgumentNullException("source");
  533. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  534. }
  535. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource>(this IAsyncQueryable<TSource> source, IEqualityComparer<TSource> comparer)
  536. {
  537. if (source == null)
  538. throw new ArgumentNullException("source");
  539. if (comparer == null)
  540. throw new ArgumentNullException("comparer");
  541. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))));
  542. }
  543. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  544. {
  545. if (source == null)
  546. throw new ArgumentNullException("source");
  547. if (keySelector == null)
  548. throw new ArgumentNullException("keySelector");
  549. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  550. }
  551. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  552. {
  553. if (source == null)
  554. throw new ArgumentNullException("source");
  555. if (keySelector == null)
  556. throw new ArgumentNullException("keySelector");
  557. if (comparer == null)
  558. throw new ArgumentNullException("comparer");
  559. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  560. }
  561. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Action<TSource>> onNext)
  562. {
  563. if (source == null)
  564. throw new ArgumentNullException("source");
  565. if (onNext == null)
  566. throw new ArgumentNullException("onNext");
  567. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext));
  568. }
  569. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, IObserver<TSource> observer)
  570. {
  571. if (source == null)
  572. throw new ArgumentNullException("source");
  573. if (observer == null)
  574. throw new ArgumentNullException("observer");
  575. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver<TSource>))));
  576. }
  577. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Action<TSource>> onNext, Action onCompleted)
  578. {
  579. if (source == null)
  580. throw new ArgumentNullException("source");
  581. if (onNext == null)
  582. throw new ArgumentNullException("onNext");
  583. if (onCompleted == null)
  584. throw new ArgumentNullException("onCompleted");
  585. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action))));
  586. }
  587. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError)
  588. {
  589. if (source == null)
  590. throw new ArgumentNullException("source");
  591. if (onNext == null)
  592. throw new ArgumentNullException("onNext");
  593. if (onError == null)
  594. throw new ArgumentNullException("onError");
  595. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError));
  596. }
  597. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError, Action onCompleted)
  598. {
  599. if (source == null)
  600. throw new ArgumentNullException("source");
  601. if (onNext == null)
  602. throw new ArgumentNullException("onNext");
  603. if (onError == null)
  604. throw new ArgumentNullException("onError");
  605. if (onCompleted == null)
  606. throw new ArgumentNullException("onCompleted");
  607. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action))));
  608. }
  609. public static Task<TSource> ElementAt<TSource>(this IAsyncQueryable<TSource> source, int index)
  610. {
  611. if (source == null)
  612. throw new ArgumentNullException("source");
  613. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None);
  614. }
  615. public static Task<TSource> ElementAt<TSource>(this IAsyncQueryable<TSource> source, int index, CancellationToken cancellationToken)
  616. {
  617. if (source == null)
  618. throw new ArgumentNullException("source");
  619. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  620. }
  621. public static Task<TSource> ElementAtOrDefault<TSource>(this IAsyncQueryable<TSource> source, int index)
  622. {
  623. if (source == null)
  624. throw new ArgumentNullException("source");
  625. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None);
  626. }
  627. public static Task<TSource> ElementAtOrDefault<TSource>(this IAsyncQueryable<TSource> source, int index, CancellationToken cancellationToken)
  628. {
  629. if (source == null)
  630. throw new ArgumentNullException("source");
  631. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  632. }
  633. public static IAsyncQueryable<TSource> Except<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  634. {
  635. if (first == null)
  636. throw new ArgumentNullException("first");
  637. if (second == null)
  638. throw new ArgumentNullException("second");
  639. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)));
  640. }
  641. public static IAsyncQueryable<TSource> Except<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  642. {
  643. if (first == null)
  644. throw new ArgumentNullException("first");
  645. if (second == null)
  646. throw new ArgumentNullException("second");
  647. if (comparer == null)
  648. throw new ArgumentNullException("comparer");
  649. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))));
  650. }
  651. public static IAsyncQueryable<TSource> Expand<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, IAsyncEnumerable<TSource>>> selector)
  652. {
  653. if (source == null)
  654. throw new ArgumentNullException("source");
  655. if (selector == null)
  656. throw new ArgumentNullException("selector");
  657. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector));
  658. }
  659. public static IAsyncQueryable<TSource> Finally<TSource>(this IAsyncQueryable<TSource> source, Action finallyAction)
  660. {
  661. if (source == null)
  662. throw new ArgumentNullException("source");
  663. if (finallyAction == null)
  664. throw new ArgumentNullException("finallyAction");
  665. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action))));
  666. }
  667. public static Task<TSource> First<TSource>(this IAsyncQueryable<TSource> source)
  668. {
  669. if (source == null)
  670. throw new ArgumentNullException("source");
  671. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  672. }
  673. public static Task<TSource> First<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  674. {
  675. if (source == null)
  676. throw new ArgumentNullException("source");
  677. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  678. }
  679. public static Task<TSource> First<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  680. {
  681. if (source == null)
  682. throw new ArgumentNullException("source");
  683. if (predicate == null)
  684. throw new ArgumentNullException("predicate");
  685. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  686. }
  687. public static Task<TSource> First<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  688. {
  689. if (source == null)
  690. throw new ArgumentNullException("source");
  691. if (predicate == null)
  692. throw new ArgumentNullException("predicate");
  693. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  694. }
  695. public static Task<TSource> FirstOrDefault<TSource>(this IAsyncQueryable<TSource> source)
  696. {
  697. if (source == null)
  698. throw new ArgumentNullException("source");
  699. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  700. }
  701. public static Task<TSource> FirstOrDefault<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  702. {
  703. if (source == null)
  704. throw new ArgumentNullException("source");
  705. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  706. }
  707. public static Task<TSource> FirstOrDefault<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  708. {
  709. if (source == null)
  710. throw new ArgumentNullException("source");
  711. if (predicate == null)
  712. throw new ArgumentNullException("predicate");
  713. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  714. }
  715. public static Task<TSource> FirstOrDefault<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  716. {
  717. if (source == null)
  718. throw new ArgumentNullException("source");
  719. if (predicate == null)
  720. throw new ArgumentNullException("predicate");
  721. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  722. }
  723. public static IAsyncQueryable<IAsyncGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  724. {
  725. if (source == null)
  726. throw new ArgumentNullException("source");
  727. if (keySelector == null)
  728. throw new ArgumentNullException("keySelector");
  729. return source.Provider.CreateQuery<IAsyncGrouping<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  730. }
  731. public static IAsyncQueryable<IAsyncGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  732. {
  733. if (source == null)
  734. throw new ArgumentNullException("source");
  735. if (keySelector == null)
  736. throw new ArgumentNullException("keySelector");
  737. if (elementSelector == null)
  738. throw new ArgumentNullException("elementSelector");
  739. return source.Provider.CreateQuery<IAsyncGrouping<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector));
  740. }
  741. public static IAsyncQueryable<IAsyncGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  742. {
  743. if (source == null)
  744. throw new ArgumentNullException("source");
  745. if (keySelector == null)
  746. throw new ArgumentNullException("keySelector");
  747. if (comparer == null)
  748. throw new ArgumentNullException("comparer");
  749. return source.Provider.CreateQuery<IAsyncGrouping<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  750. }
  751. public static IAsyncQueryable<TResult> GroupBy<TSource, TKey, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TKey, IAsyncEnumerable<TSource>, TResult>> resultSelector)
  752. {
  753. if (source == null)
  754. throw new ArgumentNullException("source");
  755. if (keySelector == null)
  756. throw new ArgumentNullException("keySelector");
  757. if (resultSelector == null)
  758. throw new ArgumentNullException("resultSelector");
  759. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector));
  760. }
  761. public static IAsyncQueryable<IAsyncGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer)
  762. {
  763. if (source == null)
  764. throw new ArgumentNullException("source");
  765. if (keySelector == null)
  766. throw new ArgumentNullException("keySelector");
  767. if (elementSelector == null)
  768. throw new ArgumentNullException("elementSelector");
  769. if (comparer == null)
  770. throw new ArgumentNullException("comparer");
  771. return source.Provider.CreateQuery<IAsyncGrouping<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  772. }
  773. public static IAsyncQueryable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<TKey, IAsyncEnumerable<TElement>, TResult>> resultSelector)
  774. {
  775. if (source == null)
  776. throw new ArgumentNullException("source");
  777. if (keySelector == null)
  778. throw new ArgumentNullException("keySelector");
  779. if (elementSelector == null)
  780. throw new ArgumentNullException("elementSelector");
  781. if (resultSelector == null)
  782. throw new ArgumentNullException("resultSelector");
  783. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector));
  784. }
  785. public static IAsyncQueryable<TResult> GroupBy<TSource, TKey, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TKey, IAsyncEnumerable<TSource>, TResult>> resultSelector, IEqualityComparer<TKey> comparer)
  786. {
  787. if (source == null)
  788. throw new ArgumentNullException("source");
  789. if (keySelector == null)
  790. throw new ArgumentNullException("keySelector");
  791. if (resultSelector == null)
  792. throw new ArgumentNullException("resultSelector");
  793. if (comparer == null)
  794. throw new ArgumentNullException("comparer");
  795. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  796. }
  797. public static IAsyncQueryable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<TKey, IAsyncEnumerable<TElement>, TResult>> resultSelector, IEqualityComparer<TKey> comparer)
  798. {
  799. if (source == null)
  800. throw new ArgumentNullException("source");
  801. if (keySelector == null)
  802. throw new ArgumentNullException("keySelector");
  803. if (elementSelector == null)
  804. throw new ArgumentNullException("elementSelector");
  805. if (resultSelector == null)
  806. throw new ArgumentNullException("resultSelector");
  807. if (comparer == null)
  808. throw new ArgumentNullException("comparer");
  809. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  810. }
  811. public static IAsyncQueryable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IAsyncQueryable<TOuter> outer, IAsyncEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, IAsyncEnumerable<TInner>, TResult>> resultSelector)
  812. {
  813. if (outer == null)
  814. throw new ArgumentNullException("outer");
  815. if (inner == null)
  816. throw new ArgumentNullException("inner");
  817. if (outerKeySelector == null)
  818. throw new ArgumentNullException("outerKeySelector");
  819. if (innerKeySelector == null)
  820. throw new ArgumentNullException("innerKeySelector");
  821. if (resultSelector == null)
  822. throw new ArgumentNullException("resultSelector");
  823. return outer.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector));
  824. }
  825. public static IAsyncQueryable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IAsyncQueryable<TOuter> outer, IAsyncEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, IAsyncEnumerable<TInner>, TResult>> resultSelector, IEqualityComparer<TKey> comparer)
  826. {
  827. if (outer == null)
  828. throw new ArgumentNullException("outer");
  829. if (inner == null)
  830. throw new ArgumentNullException("inner");
  831. if (outerKeySelector == null)
  832. throw new ArgumentNullException("outerKeySelector");
  833. if (innerKeySelector == null)
  834. throw new ArgumentNullException("innerKeySelector");
  835. if (resultSelector == null)
  836. throw new ArgumentNullException("resultSelector");
  837. if (comparer == null)
  838. throw new ArgumentNullException("comparer");
  839. return outer.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  840. }
  841. public static IAsyncQueryable<TSource> IgnoreElements<TSource>(this IAsyncQueryable<TSource> source)
  842. {
  843. if (source == null)
  844. throw new ArgumentNullException("source");
  845. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  846. }
  847. public static IAsyncQueryable<TSource> Intersect<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  848. {
  849. if (first == null)
  850. throw new ArgumentNullException("first");
  851. if (second == null)
  852. throw new ArgumentNullException("second");
  853. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)));
  854. }
  855. public static IAsyncQueryable<TSource> Intersect<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  856. {
  857. if (first == null)
  858. throw new ArgumentNullException("first");
  859. if (second == null)
  860. throw new ArgumentNullException("second");
  861. if (comparer == null)
  862. throw new ArgumentNullException("comparer");
  863. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))));
  864. }
  865. public static Task<bool> IsEmpty<TSource>(this IAsyncQueryable<TSource> source)
  866. {
  867. if (source == null)
  868. throw new ArgumentNullException("source");
  869. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  870. }
  871. public static Task<bool> IsEmpty<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  872. {
  873. if (source == null)
  874. throw new ArgumentNullException("source");
  875. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  876. }
  877. public static IAsyncQueryable<TResult> Join<TOuter, TInner, TKey, TResult>(this IAsyncQueryable<TOuter> outer, IAsyncEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, TInner, TResult>> resultSelector)
  878. {
  879. if (outer == null)
  880. throw new ArgumentNullException("outer");
  881. if (inner == null)
  882. throw new ArgumentNullException("inner");
  883. if (outerKeySelector == null)
  884. throw new ArgumentNullException("outerKeySelector");
  885. if (innerKeySelector == null)
  886. throw new ArgumentNullException("innerKeySelector");
  887. if (resultSelector == null)
  888. throw new ArgumentNullException("resultSelector");
  889. return outer.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector));
  890. }
  891. public static IAsyncQueryable<TResult> Join<TOuter, TInner, TKey, TResult>(this IAsyncQueryable<TOuter> outer, IAsyncEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, TInner, TResult>> resultSelector, IEqualityComparer<TKey> comparer)
  892. {
  893. if (outer == null)
  894. throw new ArgumentNullException("outer");
  895. if (inner == null)
  896. throw new ArgumentNullException("inner");
  897. if (outerKeySelector == null)
  898. throw new ArgumentNullException("outerKeySelector");
  899. if (innerKeySelector == null)
  900. throw new ArgumentNullException("innerKeySelector");
  901. if (resultSelector == null)
  902. throw new ArgumentNullException("resultSelector");
  903. if (comparer == null)
  904. throw new ArgumentNullException("comparer");
  905. return outer.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  906. }
  907. public static Task<TSource> Last<TSource>(this IAsyncQueryable<TSource> source)
  908. {
  909. if (source == null)
  910. throw new ArgumentNullException("source");
  911. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  912. }
  913. public static Task<TSource> Last<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  914. {
  915. if (source == null)
  916. throw new ArgumentNullException("source");
  917. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  918. }
  919. public static Task<TSource> Last<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  920. {
  921. if (source == null)
  922. throw new ArgumentNullException("source");
  923. if (predicate == null)
  924. throw new ArgumentNullException("predicate");
  925. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  926. }
  927. public static Task<TSource> Last<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  928. {
  929. if (source == null)
  930. throw new ArgumentNullException("source");
  931. if (predicate == null)
  932. throw new ArgumentNullException("predicate");
  933. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  934. }
  935. public static Task<TSource> LastOrDefault<TSource>(this IAsyncQueryable<TSource> source)
  936. {
  937. if (source == null)
  938. throw new ArgumentNullException("source");
  939. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  940. }
  941. public static Task<TSource> LastOrDefault<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  942. {
  943. if (source == null)
  944. throw new ArgumentNullException("source");
  945. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  946. }
  947. public static Task<TSource> LastOrDefault<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  948. {
  949. if (source == null)
  950. throw new ArgumentNullException("source");
  951. if (predicate == null)
  952. throw new ArgumentNullException("predicate");
  953. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  954. }
  955. public static Task<TSource> LastOrDefault<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  956. {
  957. if (source == null)
  958. throw new ArgumentNullException("source");
  959. if (predicate == null)
  960. throw new ArgumentNullException("predicate");
  961. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  962. }
  963. public static Task<long> LongCount<TSource>(this IAsyncQueryable<TSource> source)
  964. {
  965. if (source == null)
  966. throw new ArgumentNullException("source");
  967. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  968. }
  969. public static Task<long> LongCount<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  970. {
  971. if (source == null)
  972. throw new ArgumentNullException("source");
  973. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  974. }
  975. public static Task<long> LongCount<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  976. {
  977. if (source == null)
  978. throw new ArgumentNullException("source");
  979. if (predicate == null)
  980. throw new ArgumentNullException("predicate");
  981. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  982. }
  983. public static Task<long> LongCount<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  984. {
  985. if (source == null)
  986. throw new ArgumentNullException("source");
  987. if (predicate == null)
  988. throw new ArgumentNullException("predicate");
  989. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  990. }
  991. public static Task<int> Max(this IAsyncQueryable<int> source)
  992. {
  993. if (source == null)
  994. throw new ArgumentNullException("source");
  995. return source.Provider.ExecuteAsync<int>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  996. }
  997. public static Task<long> Max(this IAsyncQueryable<long> source)
  998. {
  999. if (source == null)
  1000. throw new ArgumentNullException("source");
  1001. return source.Provider.ExecuteAsync<long>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1002. }
  1003. public static Task<double> Max(this IAsyncQueryable<double> source)
  1004. {
  1005. if (source == null)
  1006. throw new ArgumentNullException("source");
  1007. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1008. }
  1009. public static Task<float> Max(this IAsyncQueryable<float> source)
  1010. {
  1011. if (source == null)
  1012. throw new ArgumentNullException("source");
  1013. return source.Provider.ExecuteAsync<float>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1014. }
  1015. public static Task<decimal> Max(this IAsyncQueryable<decimal> source)
  1016. {
  1017. if (source == null)
  1018. throw new ArgumentNullException("source");
  1019. return source.Provider.ExecuteAsync<decimal>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1020. }
  1021. public static Task<int?> Max(this IAsyncQueryable<int?> source)
  1022. {
  1023. if (source == null)
  1024. throw new ArgumentNullException("source");
  1025. return source.Provider.ExecuteAsync<int?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1026. }
  1027. public static Task<long?> Max(this IAsyncQueryable<long?> source)
  1028. {
  1029. if (source == null)
  1030. throw new ArgumentNullException("source");
  1031. return source.Provider.ExecuteAsync<long?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1032. }
  1033. public static Task<double?> Max(this IAsyncQueryable<double?> source)
  1034. {
  1035. if (source == null)
  1036. throw new ArgumentNullException("source");
  1037. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1038. }
  1039. public static Task<float?> Max(this IAsyncQueryable<float?> source)
  1040. {
  1041. if (source == null)
  1042. throw new ArgumentNullException("source");
  1043. return source.Provider.ExecuteAsync<float?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1044. }
  1045. public static Task<decimal?> Max(this IAsyncQueryable<decimal?> source)
  1046. {
  1047. if (source == null)
  1048. throw new ArgumentNullException("source");
  1049. return source.Provider.ExecuteAsync<decimal?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1050. }
  1051. public static Task<TSource> Max<TSource>(this IAsyncQueryable<TSource> source)
  1052. {
  1053. if (source == null)
  1054. throw new ArgumentNullException("source");
  1055. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  1056. }
  1057. public static Task<int> Max(this IAsyncQueryable<int> source, CancellationToken cancellationToken)
  1058. {
  1059. if (source == null)
  1060. throw new ArgumentNullException("source");
  1061. return source.Provider.ExecuteAsync<int>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1062. }
  1063. public static Task<long> Max(this IAsyncQueryable<long> source, CancellationToken cancellationToken)
  1064. {
  1065. if (source == null)
  1066. throw new ArgumentNullException("source");
  1067. return source.Provider.ExecuteAsync<long>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1068. }
  1069. public static Task<double> Max(this IAsyncQueryable<double> source, CancellationToken cancellationToken)
  1070. {
  1071. if (source == null)
  1072. throw new ArgumentNullException("source");
  1073. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1074. }
  1075. public static Task<float> Max(this IAsyncQueryable<float> source, CancellationToken cancellationToken)
  1076. {
  1077. if (source == null)
  1078. throw new ArgumentNullException("source");
  1079. return source.Provider.ExecuteAsync<float>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1080. }
  1081. public static Task<decimal> Max(this IAsyncQueryable<decimal> source, CancellationToken cancellationToken)
  1082. {
  1083. if (source == null)
  1084. throw new ArgumentNullException("source");
  1085. return source.Provider.ExecuteAsync<decimal>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1086. }
  1087. public static Task<int?> Max(this IAsyncQueryable<int?> source, CancellationToken cancellationToken)
  1088. {
  1089. if (source == null)
  1090. throw new ArgumentNullException("source");
  1091. return source.Provider.ExecuteAsync<int?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1092. }
  1093. public static Task<long?> Max(this IAsyncQueryable<long?> source, CancellationToken cancellationToken)
  1094. {
  1095. if (source == null)
  1096. throw new ArgumentNullException("source");
  1097. return source.Provider.ExecuteAsync<long?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1098. }
  1099. public static Task<double?> Max(this IAsyncQueryable<double?> source, CancellationToken cancellationToken)
  1100. {
  1101. if (source == null)
  1102. throw new ArgumentNullException("source");
  1103. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1104. }
  1105. public static Task<float?> Max(this IAsyncQueryable<float?> source, CancellationToken cancellationToken)
  1106. {
  1107. if (source == null)
  1108. throw new ArgumentNullException("source");
  1109. return source.Provider.ExecuteAsync<float?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1110. }
  1111. public static Task<decimal?> Max(this IAsyncQueryable<decimal?> source, CancellationToken cancellationToken)
  1112. {
  1113. if (source == null)
  1114. throw new ArgumentNullException("source");
  1115. return source.Provider.ExecuteAsync<decimal?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1116. }
  1117. public static Task<TSource> Max<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  1118. {
  1119. if (source == null)
  1120. throw new ArgumentNullException("source");
  1121. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1122. }
  1123. public static Task<TSource> Max<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer)
  1124. {
  1125. if (source == null)
  1126. throw new ArgumentNullException("source");
  1127. if (comparer == null)
  1128. throw new ArgumentNullException("comparer");
  1129. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>))), CancellationToken.None);
  1130. }
  1131. public static Task<int> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int>> selector)
  1132. {
  1133. if (source == null)
  1134. throw new ArgumentNullException("source");
  1135. if (selector == null)
  1136. throw new ArgumentNullException("selector");
  1137. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1138. }
  1139. public static Task<long> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long>> selector)
  1140. {
  1141. if (source == null)
  1142. throw new ArgumentNullException("source");
  1143. if (selector == null)
  1144. throw new ArgumentNullException("selector");
  1145. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1146. }
  1147. public static Task<double> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double>> selector)
  1148. {
  1149. if (source == null)
  1150. throw new ArgumentNullException("source");
  1151. if (selector == null)
  1152. throw new ArgumentNullException("selector");
  1153. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1154. }
  1155. public static Task<float> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float>> selector)
  1156. {
  1157. if (source == null)
  1158. throw new ArgumentNullException("source");
  1159. if (selector == null)
  1160. throw new ArgumentNullException("selector");
  1161. return source.Provider.ExecuteAsync<float>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1162. }
  1163. public static Task<decimal> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal>> selector)
  1164. {
  1165. if (source == null)
  1166. throw new ArgumentNullException("source");
  1167. if (selector == null)
  1168. throw new ArgumentNullException("selector");
  1169. return source.Provider.ExecuteAsync<decimal>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1170. }
  1171. public static Task<int?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int?>> selector)
  1172. {
  1173. if (source == null)
  1174. throw new ArgumentNullException("source");
  1175. if (selector == null)
  1176. throw new ArgumentNullException("selector");
  1177. return source.Provider.ExecuteAsync<int?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1178. }
  1179. public static Task<long?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long?>> selector)
  1180. {
  1181. if (source == null)
  1182. throw new ArgumentNullException("source");
  1183. if (selector == null)
  1184. throw new ArgumentNullException("selector");
  1185. return source.Provider.ExecuteAsync<long?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1186. }
  1187. public static Task<double?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double?>> selector)
  1188. {
  1189. if (source == null)
  1190. throw new ArgumentNullException("source");
  1191. if (selector == null)
  1192. throw new ArgumentNullException("selector");
  1193. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1194. }
  1195. public static Task<float?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float?>> selector)
  1196. {
  1197. if (source == null)
  1198. throw new ArgumentNullException("source");
  1199. if (selector == null)
  1200. throw new ArgumentNullException("selector");
  1201. return source.Provider.ExecuteAsync<float?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1202. }
  1203. public static Task<decimal?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  1204. {
  1205. if (source == null)
  1206. throw new ArgumentNullException("source");
  1207. if (selector == null)
  1208. throw new ArgumentNullException("selector");
  1209. return source.Provider.ExecuteAsync<decimal?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1210. }
  1211. public static Task<TResult> Max<TSource, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TResult>> selector)
  1212. {
  1213. if (source == null)
  1214. throw new ArgumentNullException("source");
  1215. if (selector == null)
  1216. throw new ArgumentNullException("selector");
  1217. return source.Provider.ExecuteAsync<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None);
  1218. }
  1219. public static Task<TResult> Max<TSource, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TResult>> selector, CancellationToken cancellationToken)
  1220. {
  1221. if (source == null)
  1222. throw new ArgumentNullException("source");
  1223. if (selector == null)
  1224. throw new ArgumentNullException("selector");
  1225. return source.Provider.ExecuteAsync<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1226. }
  1227. public static Task<TSource> Max<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
  1228. {
  1229. if (source == null)
  1230. throw new ArgumentNullException("source");
  1231. if (comparer == null)
  1232. throw new ArgumentNullException("comparer");
  1233. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1234. }
  1235. public static Task<int> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken cancellationToken)
  1236. {
  1237. if (source == null)
  1238. throw new ArgumentNullException("source");
  1239. if (selector == null)
  1240. throw new ArgumentNullException("selector");
  1241. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1242. }
  1243. public static Task<long> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken cancellationToken)
  1244. {
  1245. if (source == null)
  1246. throw new ArgumentNullException("source");
  1247. if (selector == null)
  1248. throw new ArgumentNullException("selector");
  1249. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1250. }
  1251. public static Task<double> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken cancellationToken)
  1252. {
  1253. if (source == null)
  1254. throw new ArgumentNullException("source");
  1255. if (selector == null)
  1256. throw new ArgumentNullException("selector");
  1257. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1258. }
  1259. public static Task<float> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken cancellationToken)
  1260. {
  1261. if (source == null)
  1262. throw new ArgumentNullException("source");
  1263. if (selector == null)
  1264. throw new ArgumentNullException("selector");
  1265. return source.Provider.ExecuteAsync<float>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1266. }
  1267. public static Task<decimal> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken cancellationToken)
  1268. {
  1269. if (source == null)
  1270. throw new ArgumentNullException("source");
  1271. if (selector == null)
  1272. throw new ArgumentNullException("selector");
  1273. return source.Provider.ExecuteAsync<decimal>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1274. }
  1275. public static Task<int?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int?>> selector, CancellationToken cancellationToken)
  1276. {
  1277. if (source == null)
  1278. throw new ArgumentNullException("source");
  1279. if (selector == null)
  1280. throw new ArgumentNullException("selector");
  1281. return source.Provider.ExecuteAsync<int?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1282. }
  1283. public static Task<long?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long?>> selector, CancellationToken cancellationToken)
  1284. {
  1285. if (source == null)
  1286. throw new ArgumentNullException("source");
  1287. if (selector == null)
  1288. throw new ArgumentNullException("selector");
  1289. return source.Provider.ExecuteAsync<long?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1290. }
  1291. public static Task<double?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double?>> selector, CancellationToken cancellationToken)
  1292. {
  1293. if (source == null)
  1294. throw new ArgumentNullException("source");
  1295. if (selector == null)
  1296. throw new ArgumentNullException("selector");
  1297. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1298. }
  1299. public static Task<float?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float?>> selector, CancellationToken cancellationToken)
  1300. {
  1301. if (source == null)
  1302. throw new ArgumentNullException("source");
  1303. if (selector == null)
  1304. throw new ArgumentNullException("selector");
  1305. return source.Provider.ExecuteAsync<float?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1306. }
  1307. public static Task<decimal?> Max<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector, CancellationToken cancellationToken)
  1308. {
  1309. if (source == null)
  1310. throw new ArgumentNullException("source");
  1311. if (selector == null)
  1312. throw new ArgumentNullException("selector");
  1313. return source.Provider.ExecuteAsync<decimal?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1314. }
  1315. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  1316. {
  1317. if (source == null)
  1318. throw new ArgumentNullException("source");
  1319. if (keySelector == null)
  1320. throw new ArgumentNullException("keySelector");
  1321. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None);
  1322. }
  1323. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, CancellationToken cancellationToken)
  1324. {
  1325. if (source == null)
  1326. throw new ArgumentNullException("source");
  1327. if (keySelector == null)
  1328. throw new ArgumentNullException("keySelector");
  1329. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1330. }
  1331. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  1332. {
  1333. if (source == null)
  1334. throw new ArgumentNullException("source");
  1335. if (keySelector == null)
  1336. throw new ArgumentNullException("keySelector");
  1337. if (comparer == null)
  1338. throw new ArgumentNullException("comparer");
  1339. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  1340. }
  1341. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
  1342. {
  1343. if (source == null)
  1344. throw new ArgumentNullException("source");
  1345. if (keySelector == null)
  1346. throw new ArgumentNullException("keySelector");
  1347. if (comparer == null)
  1348. throw new ArgumentNullException("comparer");
  1349. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1350. }
  1351. public static Task<int> Min(this IAsyncQueryable<int> source)
  1352. {
  1353. if (source == null)
  1354. throw new ArgumentNullException("source");
  1355. return source.Provider.ExecuteAsync<int>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1356. }
  1357. public static Task<long> Min(this IAsyncQueryable<long> source)
  1358. {
  1359. if (source == null)
  1360. throw new ArgumentNullException("source");
  1361. return source.Provider.ExecuteAsync<long>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1362. }
  1363. public static Task<double> Min(this IAsyncQueryable<double> source)
  1364. {
  1365. if (source == null)
  1366. throw new ArgumentNullException("source");
  1367. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1368. }
  1369. public static Task<float> Min(this IAsyncQueryable<float> source)
  1370. {
  1371. if (source == null)
  1372. throw new ArgumentNullException("source");
  1373. return source.Provider.ExecuteAsync<float>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1374. }
  1375. public static Task<decimal> Min(this IAsyncQueryable<decimal> source)
  1376. {
  1377. if (source == null)
  1378. throw new ArgumentNullException("source");
  1379. return source.Provider.ExecuteAsync<decimal>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1380. }
  1381. public static Task<int?> Min(this IAsyncQueryable<int?> source)
  1382. {
  1383. if (source == null)
  1384. throw new ArgumentNullException("source");
  1385. return source.Provider.ExecuteAsync<int?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1386. }
  1387. public static Task<long?> Min(this IAsyncQueryable<long?> source)
  1388. {
  1389. if (source == null)
  1390. throw new ArgumentNullException("source");
  1391. return source.Provider.ExecuteAsync<long?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1392. }
  1393. public static Task<double?> Min(this IAsyncQueryable<double?> source)
  1394. {
  1395. if (source == null)
  1396. throw new ArgumentNullException("source");
  1397. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1398. }
  1399. public static Task<float?> Min(this IAsyncQueryable<float?> source)
  1400. {
  1401. if (source == null)
  1402. throw new ArgumentNullException("source");
  1403. return source.Provider.ExecuteAsync<float?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1404. }
  1405. public static Task<decimal?> Min(this IAsyncQueryable<decimal?> source)
  1406. {
  1407. if (source == null)
  1408. throw new ArgumentNullException("source");
  1409. return source.Provider.ExecuteAsync<decimal?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  1410. }
  1411. public static Task<TSource> Min<TSource>(this IAsyncQueryable<TSource> source)
  1412. {
  1413. if (source == null)
  1414. throw new ArgumentNullException("source");
  1415. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  1416. }
  1417. public static Task<int> Min(this IAsyncQueryable<int> source, CancellationToken cancellationToken)
  1418. {
  1419. if (source == null)
  1420. throw new ArgumentNullException("source");
  1421. return source.Provider.ExecuteAsync<int>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1422. }
  1423. public static Task<long> Min(this IAsyncQueryable<long> source, CancellationToken cancellationToken)
  1424. {
  1425. if (source == null)
  1426. throw new ArgumentNullException("source");
  1427. return source.Provider.ExecuteAsync<long>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1428. }
  1429. public static Task<double> Min(this IAsyncQueryable<double> source, CancellationToken cancellationToken)
  1430. {
  1431. if (source == null)
  1432. throw new ArgumentNullException("source");
  1433. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1434. }
  1435. public static Task<float> Min(this IAsyncQueryable<float> source, CancellationToken cancellationToken)
  1436. {
  1437. if (source == null)
  1438. throw new ArgumentNullException("source");
  1439. return source.Provider.ExecuteAsync<float>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1440. }
  1441. public static Task<decimal> Min(this IAsyncQueryable<decimal> source, CancellationToken cancellationToken)
  1442. {
  1443. if (source == null)
  1444. throw new ArgumentNullException("source");
  1445. return source.Provider.ExecuteAsync<decimal>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1446. }
  1447. public static Task<int?> Min(this IAsyncQueryable<int?> source, CancellationToken cancellationToken)
  1448. {
  1449. if (source == null)
  1450. throw new ArgumentNullException("source");
  1451. return source.Provider.ExecuteAsync<int?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1452. }
  1453. public static Task<long?> Min(this IAsyncQueryable<long?> source, CancellationToken cancellationToken)
  1454. {
  1455. if (source == null)
  1456. throw new ArgumentNullException("source");
  1457. return source.Provider.ExecuteAsync<long?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1458. }
  1459. public static Task<double?> Min(this IAsyncQueryable<double?> source, CancellationToken cancellationToken)
  1460. {
  1461. if (source == null)
  1462. throw new ArgumentNullException("source");
  1463. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1464. }
  1465. public static Task<float?> Min(this IAsyncQueryable<float?> source, CancellationToken cancellationToken)
  1466. {
  1467. if (source == null)
  1468. throw new ArgumentNullException("source");
  1469. return source.Provider.ExecuteAsync<float?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1470. }
  1471. public static Task<decimal?> Min(this IAsyncQueryable<decimal?> source, CancellationToken cancellationToken)
  1472. {
  1473. if (source == null)
  1474. throw new ArgumentNullException("source");
  1475. return source.Provider.ExecuteAsync<decimal?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1476. }
  1477. public static Task<TSource> Min<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  1478. {
  1479. if (source == null)
  1480. throw new ArgumentNullException("source");
  1481. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1482. }
  1483. public static Task<double?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double?>> selector)
  1484. {
  1485. if (source == null)
  1486. throw new ArgumentNullException("source");
  1487. if (selector == null)
  1488. throw new ArgumentNullException("selector");
  1489. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1490. }
  1491. public static Task<float?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float?>> selector)
  1492. {
  1493. if (source == null)
  1494. throw new ArgumentNullException("source");
  1495. if (selector == null)
  1496. throw new ArgumentNullException("selector");
  1497. return source.Provider.ExecuteAsync<float?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1498. }
  1499. public static Task<TSource> Min<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer)
  1500. {
  1501. if (source == null)
  1502. throw new ArgumentNullException("source");
  1503. if (comparer == null)
  1504. throw new ArgumentNullException("comparer");
  1505. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>))), CancellationToken.None);
  1506. }
  1507. public static Task<int> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int>> selector)
  1508. {
  1509. if (source == null)
  1510. throw new ArgumentNullException("source");
  1511. if (selector == null)
  1512. throw new ArgumentNullException("selector");
  1513. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1514. }
  1515. public static Task<long> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long>> selector)
  1516. {
  1517. if (source == null)
  1518. throw new ArgumentNullException("source");
  1519. if (selector == null)
  1520. throw new ArgumentNullException("selector");
  1521. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1522. }
  1523. public static Task<double> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double>> selector)
  1524. {
  1525. if (source == null)
  1526. throw new ArgumentNullException("source");
  1527. if (selector == null)
  1528. throw new ArgumentNullException("selector");
  1529. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1530. }
  1531. public static Task<float> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float>> selector)
  1532. {
  1533. if (source == null)
  1534. throw new ArgumentNullException("source");
  1535. if (selector == null)
  1536. throw new ArgumentNullException("selector");
  1537. return source.Provider.ExecuteAsync<float>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1538. }
  1539. public static Task<decimal> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal>> selector)
  1540. {
  1541. if (source == null)
  1542. throw new ArgumentNullException("source");
  1543. if (selector == null)
  1544. throw new ArgumentNullException("selector");
  1545. return source.Provider.ExecuteAsync<decimal>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1546. }
  1547. public static Task<int?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int?>> selector)
  1548. {
  1549. if (source == null)
  1550. throw new ArgumentNullException("source");
  1551. if (selector == null)
  1552. throw new ArgumentNullException("selector");
  1553. return source.Provider.ExecuteAsync<int?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1554. }
  1555. public static Task<long?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long?>> selector)
  1556. {
  1557. if (source == null)
  1558. throw new ArgumentNullException("source");
  1559. if (selector == null)
  1560. throw new ArgumentNullException("selector");
  1561. return source.Provider.ExecuteAsync<long?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1562. }
  1563. public static Task<decimal?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  1564. {
  1565. if (source == null)
  1566. throw new ArgumentNullException("source");
  1567. if (selector == null)
  1568. throw new ArgumentNullException("selector");
  1569. return source.Provider.ExecuteAsync<decimal?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  1570. }
  1571. public static Task<TResult> Min<TSource, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TResult>> selector)
  1572. {
  1573. if (source == null)
  1574. throw new ArgumentNullException("source");
  1575. if (selector == null)
  1576. throw new ArgumentNullException("selector");
  1577. return source.Provider.ExecuteAsync<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None);
  1578. }
  1579. public static Task<int> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken cancellationToken)
  1580. {
  1581. if (source == null)
  1582. throw new ArgumentNullException("source");
  1583. if (selector == null)
  1584. throw new ArgumentNullException("selector");
  1585. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1586. }
  1587. public static Task<long> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken cancellationToken)
  1588. {
  1589. if (source == null)
  1590. throw new ArgumentNullException("source");
  1591. if (selector == null)
  1592. throw new ArgumentNullException("selector");
  1593. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1594. }
  1595. public static Task<double> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken cancellationToken)
  1596. {
  1597. if (source == null)
  1598. throw new ArgumentNullException("source");
  1599. if (selector == null)
  1600. throw new ArgumentNullException("selector");
  1601. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1602. }
  1603. public static Task<float> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken cancellationToken)
  1604. {
  1605. if (source == null)
  1606. throw new ArgumentNullException("source");
  1607. if (selector == null)
  1608. throw new ArgumentNullException("selector");
  1609. return source.Provider.ExecuteAsync<float>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1610. }
  1611. public static Task<decimal> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken cancellationToken)
  1612. {
  1613. if (source == null)
  1614. throw new ArgumentNullException("source");
  1615. if (selector == null)
  1616. throw new ArgumentNullException("selector");
  1617. return source.Provider.ExecuteAsync<decimal>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1618. }
  1619. public static Task<int?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int?>> selector, CancellationToken cancellationToken)
  1620. {
  1621. if (source == null)
  1622. throw new ArgumentNullException("source");
  1623. if (selector == null)
  1624. throw new ArgumentNullException("selector");
  1625. return source.Provider.ExecuteAsync<int?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1626. }
  1627. public static Task<long?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long?>> selector, CancellationToken cancellationToken)
  1628. {
  1629. if (source == null)
  1630. throw new ArgumentNullException("source");
  1631. if (selector == null)
  1632. throw new ArgumentNullException("selector");
  1633. return source.Provider.ExecuteAsync<long?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1634. }
  1635. public static Task<double?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double?>> selector, CancellationToken cancellationToken)
  1636. {
  1637. if (source == null)
  1638. throw new ArgumentNullException("source");
  1639. if (selector == null)
  1640. throw new ArgumentNullException("selector");
  1641. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1642. }
  1643. public static Task<float?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float?>> selector, CancellationToken cancellationToken)
  1644. {
  1645. if (source == null)
  1646. throw new ArgumentNullException("source");
  1647. if (selector == null)
  1648. throw new ArgumentNullException("selector");
  1649. return source.Provider.ExecuteAsync<float?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1650. }
  1651. public static Task<decimal?> Min<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector, CancellationToken cancellationToken)
  1652. {
  1653. if (source == null)
  1654. throw new ArgumentNullException("source");
  1655. if (selector == null)
  1656. throw new ArgumentNullException("selector");
  1657. return source.Provider.ExecuteAsync<decimal?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1658. }
  1659. public static Task<TResult> Min<TSource, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TResult>> selector, CancellationToken cancellationToken)
  1660. {
  1661. if (source == null)
  1662. throw new ArgumentNullException("source");
  1663. if (selector == null)
  1664. throw new ArgumentNullException("selector");
  1665. return source.Provider.ExecuteAsync<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1666. }
  1667. public static Task<TSource> Min<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
  1668. {
  1669. if (source == null)
  1670. throw new ArgumentNullException("source");
  1671. if (comparer == null)
  1672. throw new ArgumentNullException("comparer");
  1673. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1674. }
  1675. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  1676. {
  1677. if (source == null)
  1678. throw new ArgumentNullException("source");
  1679. if (keySelector == null)
  1680. throw new ArgumentNullException("keySelector");
  1681. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None);
  1682. }
  1683. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, CancellationToken cancellationToken)
  1684. {
  1685. if (source == null)
  1686. throw new ArgumentNullException("source");
  1687. if (keySelector == null)
  1688. throw new ArgumentNullException("keySelector");
  1689. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1690. }
  1691. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  1692. {
  1693. if (source == null)
  1694. throw new ArgumentNullException("source");
  1695. if (keySelector == null)
  1696. throw new ArgumentNullException("keySelector");
  1697. if (comparer == null)
  1698. throw new ArgumentNullException("comparer");
  1699. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  1700. }
  1701. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
  1702. {
  1703. if (source == null)
  1704. throw new ArgumentNullException("source");
  1705. if (keySelector == null)
  1706. throw new ArgumentNullException("keySelector");
  1707. if (comparer == null)
  1708. throw new ArgumentNullException("comparer");
  1709. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1710. }
  1711. public static IAsyncQueryable<TType> OfType<TType>(this IAsyncQueryable<object> source)
  1712. {
  1713. if (source == null)
  1714. throw new ArgumentNullException("source");
  1715. return source.Provider.CreateQuery<TType>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TType)), source.Expression));
  1716. }
  1717. public static IAsyncQueryable<TSource> OnErrorResumeNext<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  1718. {
  1719. if (first == null)
  1720. throw new ArgumentNullException("first");
  1721. if (second == null)
  1722. throw new ArgumentNullException("second");
  1723. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)));
  1724. }
  1725. public static IOrderedAsyncQueryable<TSource> OrderBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  1726. {
  1727. if (source == null)
  1728. throw new ArgumentNullException("source");
  1729. if (keySelector == null)
  1730. throw new ArgumentNullException("keySelector");
  1731. return (IOrderedAsyncQueryable<TSource>)source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  1732. }
  1733. public static IOrderedAsyncQueryable<TSource> OrderBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  1734. {
  1735. if (source == null)
  1736. throw new ArgumentNullException("source");
  1737. if (keySelector == null)
  1738. throw new ArgumentNullException("keySelector");
  1739. if (comparer == null)
  1740. throw new ArgumentNullException("comparer");
  1741. return (IOrderedAsyncQueryable<TSource>)source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))));
  1742. }
  1743. public static IOrderedAsyncQueryable<TSource> OrderByDescending<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  1744. {
  1745. if (source == null)
  1746. throw new ArgumentNullException("source");
  1747. if (keySelector == null)
  1748. throw new ArgumentNullException("keySelector");
  1749. return (IOrderedAsyncQueryable<TSource>)source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  1750. }
  1751. public static IOrderedAsyncQueryable<TSource> OrderByDescending<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  1752. {
  1753. if (source == null)
  1754. throw new ArgumentNullException("source");
  1755. if (keySelector == null)
  1756. throw new ArgumentNullException("keySelector");
  1757. if (comparer == null)
  1758. throw new ArgumentNullException("comparer");
  1759. return (IOrderedAsyncQueryable<TSource>)source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))));
  1760. }
  1761. public static IAsyncQueryable<TSource> Repeat<TSource>(this IAsyncQueryable<TSource> source)
  1762. {
  1763. if (source == null)
  1764. throw new ArgumentNullException("source");
  1765. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  1766. }
  1767. public static IAsyncQueryable<TSource> Repeat<TSource>(this IAsyncQueryable<TSource> source, int count)
  1768. {
  1769. if (source == null)
  1770. throw new ArgumentNullException("source");
  1771. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int))));
  1772. }
  1773. public static IAsyncQueryable<TSource> Retry<TSource>(this IAsyncQueryable<TSource> source)
  1774. {
  1775. if (source == null)
  1776. throw new ArgumentNullException("source");
  1777. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  1778. }
  1779. public static IAsyncQueryable<TSource> Retry<TSource>(this IAsyncQueryable<TSource> source, int retryCount)
  1780. {
  1781. if (source == null)
  1782. throw new ArgumentNullException("source");
  1783. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int))));
  1784. }
  1785. public static IAsyncQueryable<TSource> Reverse<TSource>(this IAsyncQueryable<TSource> source)
  1786. {
  1787. if (source == null)
  1788. throw new ArgumentNullException("source");
  1789. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  1790. }
  1791. public static IAsyncQueryable<TSource> Scan<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  1792. {
  1793. if (source == null)
  1794. throw new ArgumentNullException("source");
  1795. if (accumulator == null)
  1796. throw new ArgumentNullException("accumulator");
  1797. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator));
  1798. }
  1799. public static IAsyncQueryable<TAccumulate> Scan<TSource, TAccumulate>(this IAsyncQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  1800. {
  1801. if (source == null)
  1802. throw new ArgumentNullException("source");
  1803. if (accumulator == null)
  1804. throw new ArgumentNullException("accumulator");
  1805. return source.Provider.CreateQuery<TAccumulate>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator));
  1806. }
  1807. public static IAsyncQueryable<TResult> Select<TSource, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TResult>> selector)
  1808. {
  1809. if (source == null)
  1810. throw new ArgumentNullException("source");
  1811. if (selector == null)
  1812. throw new ArgumentNullException("selector");
  1813. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector));
  1814. }
  1815. public static IAsyncQueryable<TResult> Select<TSource, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  1816. {
  1817. if (source == null)
  1818. throw new ArgumentNullException("source");
  1819. if (selector == null)
  1820. throw new ArgumentNullException("selector");
  1821. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector));
  1822. }
  1823. public static IAsyncQueryable<TOther> SelectMany<TSource, TOther>(this IAsyncQueryable<TSource> source, IAsyncEnumerable<TOther> other)
  1824. {
  1825. if (source == null)
  1826. throw new ArgumentNullException("source");
  1827. if (other == null)
  1828. throw new ArgumentNullException("other");
  1829. return source.Provider.CreateQuery<TOther>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other)));
  1830. }
  1831. public static IAsyncQueryable<TResult> SelectMany<TSource, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, IAsyncEnumerable<TResult>>> selector)
  1832. {
  1833. if (source == null)
  1834. throw new ArgumentNullException("source");
  1835. if (selector == null)
  1836. throw new ArgumentNullException("selector");
  1837. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector));
  1838. }
  1839. public static IAsyncQueryable<TResult> SelectMany<TSource, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int, IAsyncEnumerable<TResult>>> selector)
  1840. {
  1841. if (source == null)
  1842. throw new ArgumentNullException("source");
  1843. if (selector == null)
  1844. throw new ArgumentNullException("selector");
  1845. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector));
  1846. }
  1847. public static IAsyncQueryable<TResult> SelectMany<TSource, TCollection, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, IAsyncEnumerable<TCollection>>> selector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  1848. {
  1849. if (source == null)
  1850. throw new ArgumentNullException("source");
  1851. if (selector == null)
  1852. throw new ArgumentNullException("selector");
  1853. if (resultSelector == null)
  1854. throw new ArgumentNullException("resultSelector");
  1855. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector));
  1856. }
  1857. public static IAsyncQueryable<TResult> SelectMany<TSource, TCollection, TResult>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int, IAsyncEnumerable<TCollection>>> selector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  1858. {
  1859. if (source == null)
  1860. throw new ArgumentNullException("source");
  1861. if (selector == null)
  1862. throw new ArgumentNullException("selector");
  1863. if (resultSelector == null)
  1864. throw new ArgumentNullException("resultSelector");
  1865. return source.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector));
  1866. }
  1867. public static Task<bool> SequenceEqual<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  1868. {
  1869. if (first == null)
  1870. throw new ArgumentNullException("first");
  1871. if (second == null)
  1872. throw new ArgumentNullException("second");
  1873. return first.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)), CancellationToken.None);
  1874. }
  1875. public static Task<bool> SequenceEqual<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second, CancellationToken cancellationToken)
  1876. {
  1877. if (first == null)
  1878. throw new ArgumentNullException("first");
  1879. if (second == null)
  1880. throw new ArgumentNullException("second");
  1881. return first.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1882. }
  1883. public static Task<bool> SequenceEqual<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  1884. {
  1885. if (first == null)
  1886. throw new ArgumentNullException("first");
  1887. if (second == null)
  1888. throw new ArgumentNullException("second");
  1889. if (comparer == null)
  1890. throw new ArgumentNullException("comparer");
  1891. return first.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))), CancellationToken.None);
  1892. }
  1893. public static Task<bool> SequenceEqual<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer, CancellationToken cancellationToken)
  1894. {
  1895. if (first == null)
  1896. throw new ArgumentNullException("first");
  1897. if (second == null)
  1898. throw new ArgumentNullException("second");
  1899. if (comparer == null)
  1900. throw new ArgumentNullException("comparer");
  1901. return first.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer<TSource>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1902. }
  1903. public static Task<TSource> Single<TSource>(this IAsyncQueryable<TSource> source)
  1904. {
  1905. if (source == null)
  1906. throw new ArgumentNullException("source");
  1907. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  1908. }
  1909. public static Task<TSource> Single<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  1910. {
  1911. if (source == null)
  1912. throw new ArgumentNullException("source");
  1913. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1914. }
  1915. public static Task<TSource> Single<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  1916. {
  1917. if (source == null)
  1918. throw new ArgumentNullException("source");
  1919. if (predicate == null)
  1920. throw new ArgumentNullException("predicate");
  1921. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  1922. }
  1923. public static Task<TSource> Single<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  1924. {
  1925. if (source == null)
  1926. throw new ArgumentNullException("source");
  1927. if (predicate == null)
  1928. throw new ArgumentNullException("predicate");
  1929. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1930. }
  1931. public static Task<TSource> SingleOrDefault<TSource>(this IAsyncQueryable<TSource> source)
  1932. {
  1933. if (source == null)
  1934. throw new ArgumentNullException("source");
  1935. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  1936. }
  1937. public static Task<TSource> SingleOrDefault<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  1938. {
  1939. if (source == null)
  1940. throw new ArgumentNullException("source");
  1941. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1942. }
  1943. public static Task<TSource> SingleOrDefault<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  1944. {
  1945. if (source == null)
  1946. throw new ArgumentNullException("source");
  1947. if (predicate == null)
  1948. throw new ArgumentNullException("predicate");
  1949. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None);
  1950. }
  1951. public static Task<TSource> SingleOrDefault<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken)
  1952. {
  1953. if (source == null)
  1954. throw new ArgumentNullException("source");
  1955. if (predicate == null)
  1956. throw new ArgumentNullException("predicate");
  1957. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  1958. }
  1959. public static IAsyncQueryable<TSource> Skip<TSource>(this IAsyncQueryable<TSource> source, int count)
  1960. {
  1961. if (source == null)
  1962. throw new ArgumentNullException("source");
  1963. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int))));
  1964. }
  1965. public static IAsyncQueryable<TSource> SkipLast<TSource>(this IAsyncQueryable<TSource> source, int count)
  1966. {
  1967. if (source == null)
  1968. throw new ArgumentNullException("source");
  1969. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int))));
  1970. }
  1971. public static IAsyncQueryable<TSource> SkipWhile<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  1972. {
  1973. if (source == null)
  1974. throw new ArgumentNullException("source");
  1975. if (predicate == null)
  1976. throw new ArgumentNullException("predicate");
  1977. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate));
  1978. }
  1979. public static IAsyncQueryable<TSource> SkipWhile<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  1980. {
  1981. if (source == null)
  1982. throw new ArgumentNullException("source");
  1983. if (predicate == null)
  1984. throw new ArgumentNullException("predicate");
  1985. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate));
  1986. }
  1987. public static IAsyncQueryable<TSource> StartWith<TSource>(this IAsyncQueryable<TSource> source, params TSource[] values)
  1988. {
  1989. if (source == null)
  1990. throw new ArgumentNullException("source");
  1991. if (values == null)
  1992. throw new ArgumentNullException("values");
  1993. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[]))));
  1994. }
  1995. public static Task<int> Sum(this IAsyncQueryable<int> source)
  1996. {
  1997. if (source == null)
  1998. throw new ArgumentNullException("source");
  1999. return source.Provider.ExecuteAsync<int>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2000. }
  2001. public static Task<long> Sum(this IAsyncQueryable<long> source)
  2002. {
  2003. if (source == null)
  2004. throw new ArgumentNullException("source");
  2005. return source.Provider.ExecuteAsync<long>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2006. }
  2007. public static Task<double> Sum(this IAsyncQueryable<double> source)
  2008. {
  2009. if (source == null)
  2010. throw new ArgumentNullException("source");
  2011. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2012. }
  2013. public static Task<float> Sum(this IAsyncQueryable<float> source)
  2014. {
  2015. if (source == null)
  2016. throw new ArgumentNullException("source");
  2017. return source.Provider.ExecuteAsync<float>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2018. }
  2019. public static Task<decimal> Sum(this IAsyncQueryable<decimal> source)
  2020. {
  2021. if (source == null)
  2022. throw new ArgumentNullException("source");
  2023. return source.Provider.ExecuteAsync<decimal>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2024. }
  2025. public static Task<int?> Sum(this IAsyncQueryable<int?> source)
  2026. {
  2027. if (source == null)
  2028. throw new ArgumentNullException("source");
  2029. return source.Provider.ExecuteAsync<int?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2030. }
  2031. public static Task<long?> Sum(this IAsyncQueryable<long?> source)
  2032. {
  2033. if (source == null)
  2034. throw new ArgumentNullException("source");
  2035. return source.Provider.ExecuteAsync<long?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2036. }
  2037. public static Task<double?> Sum(this IAsyncQueryable<double?> source)
  2038. {
  2039. if (source == null)
  2040. throw new ArgumentNullException("source");
  2041. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2042. }
  2043. public static Task<float?> Sum(this IAsyncQueryable<float?> source)
  2044. {
  2045. if (source == null)
  2046. throw new ArgumentNullException("source");
  2047. return source.Provider.ExecuteAsync<float?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2048. }
  2049. public static Task<decimal?> Sum(this IAsyncQueryable<decimal?> source)
  2050. {
  2051. if (source == null)
  2052. throw new ArgumentNullException("source");
  2053. return source.Provider.ExecuteAsync<decimal?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None);
  2054. }
  2055. public static Task<int> Sum(this IAsyncQueryable<int> source, CancellationToken cancellationToken)
  2056. {
  2057. if (source == null)
  2058. throw new ArgumentNullException("source");
  2059. return source.Provider.ExecuteAsync<int>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2060. }
  2061. public static Task<long> Sum(this IAsyncQueryable<long> source, CancellationToken cancellationToken)
  2062. {
  2063. if (source == null)
  2064. throw new ArgumentNullException("source");
  2065. return source.Provider.ExecuteAsync<long>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2066. }
  2067. public static Task<double> Sum(this IAsyncQueryable<double> source, CancellationToken cancellationToken)
  2068. {
  2069. if (source == null)
  2070. throw new ArgumentNullException("source");
  2071. return source.Provider.ExecuteAsync<double>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2072. }
  2073. public static Task<float> Sum(this IAsyncQueryable<float> source, CancellationToken cancellationToken)
  2074. {
  2075. if (source == null)
  2076. throw new ArgumentNullException("source");
  2077. return source.Provider.ExecuteAsync<float>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2078. }
  2079. public static Task<decimal> Sum(this IAsyncQueryable<decimal> source, CancellationToken cancellationToken)
  2080. {
  2081. if (source == null)
  2082. throw new ArgumentNullException("source");
  2083. return source.Provider.ExecuteAsync<decimal>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2084. }
  2085. public static Task<int?> Sum(this IAsyncQueryable<int?> source, CancellationToken cancellationToken)
  2086. {
  2087. if (source == null)
  2088. throw new ArgumentNullException("source");
  2089. return source.Provider.ExecuteAsync<int?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2090. }
  2091. public static Task<long?> Sum(this IAsyncQueryable<long?> source, CancellationToken cancellationToken)
  2092. {
  2093. if (source == null)
  2094. throw new ArgumentNullException("source");
  2095. return source.Provider.ExecuteAsync<long?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2096. }
  2097. public static Task<double?> Sum(this IAsyncQueryable<double?> source, CancellationToken cancellationToken)
  2098. {
  2099. if (source == null)
  2100. throw new ArgumentNullException("source");
  2101. return source.Provider.ExecuteAsync<double?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2102. }
  2103. public static Task<float?> Sum(this IAsyncQueryable<float?> source, CancellationToken cancellationToken)
  2104. {
  2105. if (source == null)
  2106. throw new ArgumentNullException("source");
  2107. return source.Provider.ExecuteAsync<float?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2108. }
  2109. public static Task<decimal?> Sum(this IAsyncQueryable<decimal?> source, CancellationToken cancellationToken)
  2110. {
  2111. if (source == null)
  2112. throw new ArgumentNullException("source");
  2113. return source.Provider.ExecuteAsync<decimal?>(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2114. }
  2115. public static Task<int> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int>> selector)
  2116. {
  2117. if (source == null)
  2118. throw new ArgumentNullException("source");
  2119. if (selector == null)
  2120. throw new ArgumentNullException("selector");
  2121. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2122. }
  2123. public static Task<long> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long>> selector)
  2124. {
  2125. if (source == null)
  2126. throw new ArgumentNullException("source");
  2127. if (selector == null)
  2128. throw new ArgumentNullException("selector");
  2129. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2130. }
  2131. public static Task<double> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double>> selector)
  2132. {
  2133. if (source == null)
  2134. throw new ArgumentNullException("source");
  2135. if (selector == null)
  2136. throw new ArgumentNullException("selector");
  2137. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2138. }
  2139. public static Task<float> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float>> selector)
  2140. {
  2141. if (source == null)
  2142. throw new ArgumentNullException("source");
  2143. if (selector == null)
  2144. throw new ArgumentNullException("selector");
  2145. return source.Provider.ExecuteAsync<float>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2146. }
  2147. public static Task<decimal> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal>> selector)
  2148. {
  2149. if (source == null)
  2150. throw new ArgumentNullException("source");
  2151. if (selector == null)
  2152. throw new ArgumentNullException("selector");
  2153. return source.Provider.ExecuteAsync<decimal>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2154. }
  2155. public static Task<int?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int?>> selector)
  2156. {
  2157. if (source == null)
  2158. throw new ArgumentNullException("source");
  2159. if (selector == null)
  2160. throw new ArgumentNullException("selector");
  2161. return source.Provider.ExecuteAsync<int?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2162. }
  2163. public static Task<long?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long?>> selector)
  2164. {
  2165. if (source == null)
  2166. throw new ArgumentNullException("source");
  2167. if (selector == null)
  2168. throw new ArgumentNullException("selector");
  2169. return source.Provider.ExecuteAsync<long?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2170. }
  2171. public static Task<double?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double?>> selector)
  2172. {
  2173. if (source == null)
  2174. throw new ArgumentNullException("source");
  2175. if (selector == null)
  2176. throw new ArgumentNullException("selector");
  2177. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2178. }
  2179. public static Task<float?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float?>> selector)
  2180. {
  2181. if (source == null)
  2182. throw new ArgumentNullException("source");
  2183. if (selector == null)
  2184. throw new ArgumentNullException("selector");
  2185. return source.Provider.ExecuteAsync<float?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2186. }
  2187. public static Task<decimal?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  2188. {
  2189. if (source == null)
  2190. throw new ArgumentNullException("source");
  2191. if (selector == null)
  2192. throw new ArgumentNullException("selector");
  2193. return source.Provider.ExecuteAsync<decimal?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None);
  2194. }
  2195. public static Task<int> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken cancellationToken)
  2196. {
  2197. if (source == null)
  2198. throw new ArgumentNullException("source");
  2199. if (selector == null)
  2200. throw new ArgumentNullException("selector");
  2201. return source.Provider.ExecuteAsync<int>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2202. }
  2203. public static Task<long> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken cancellationToken)
  2204. {
  2205. if (source == null)
  2206. throw new ArgumentNullException("source");
  2207. if (selector == null)
  2208. throw new ArgumentNullException("selector");
  2209. return source.Provider.ExecuteAsync<long>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2210. }
  2211. public static Task<double> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken cancellationToken)
  2212. {
  2213. if (source == null)
  2214. throw new ArgumentNullException("source");
  2215. if (selector == null)
  2216. throw new ArgumentNullException("selector");
  2217. return source.Provider.ExecuteAsync<double>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2218. }
  2219. public static Task<float> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken cancellationToken)
  2220. {
  2221. if (source == null)
  2222. throw new ArgumentNullException("source");
  2223. if (selector == null)
  2224. throw new ArgumentNullException("selector");
  2225. return source.Provider.ExecuteAsync<float>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2226. }
  2227. public static Task<decimal> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken cancellationToken)
  2228. {
  2229. if (source == null)
  2230. throw new ArgumentNullException("source");
  2231. if (selector == null)
  2232. throw new ArgumentNullException("selector");
  2233. return source.Provider.ExecuteAsync<decimal>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2234. }
  2235. public static Task<int?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int?>> selector, CancellationToken cancellationToken)
  2236. {
  2237. if (source == null)
  2238. throw new ArgumentNullException("source");
  2239. if (selector == null)
  2240. throw new ArgumentNullException("selector");
  2241. return source.Provider.ExecuteAsync<int?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2242. }
  2243. public static Task<long?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, long?>> selector, CancellationToken cancellationToken)
  2244. {
  2245. if (source == null)
  2246. throw new ArgumentNullException("source");
  2247. if (selector == null)
  2248. throw new ArgumentNullException("selector");
  2249. return source.Provider.ExecuteAsync<long?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2250. }
  2251. public static Task<double?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, double?>> selector, CancellationToken cancellationToken)
  2252. {
  2253. if (source == null)
  2254. throw new ArgumentNullException("source");
  2255. if (selector == null)
  2256. throw new ArgumentNullException("selector");
  2257. return source.Provider.ExecuteAsync<double?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2258. }
  2259. public static Task<float?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, float?>> selector, CancellationToken cancellationToken)
  2260. {
  2261. if (source == null)
  2262. throw new ArgumentNullException("source");
  2263. if (selector == null)
  2264. throw new ArgumentNullException("selector");
  2265. return source.Provider.ExecuteAsync<float?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2266. }
  2267. public static Task<decimal?> Sum<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector, CancellationToken cancellationToken)
  2268. {
  2269. if (source == null)
  2270. throw new ArgumentNullException("source");
  2271. if (selector == null)
  2272. throw new ArgumentNullException("selector");
  2273. return source.Provider.ExecuteAsync<decimal?>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2274. }
  2275. public static IAsyncQueryable<TSource> Take<TSource>(this IAsyncQueryable<TSource> source, int count)
  2276. {
  2277. if (source == null)
  2278. throw new ArgumentNullException("source");
  2279. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int))));
  2280. }
  2281. public static IAsyncQueryable<TSource> TakeLast<TSource>(this IAsyncQueryable<TSource> source, int count)
  2282. {
  2283. if (source == null)
  2284. throw new ArgumentNullException("source");
  2285. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int))));
  2286. }
  2287. public static IAsyncQueryable<TSource> TakeWhile<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  2288. {
  2289. if (source == null)
  2290. throw new ArgumentNullException("source");
  2291. if (predicate == null)
  2292. throw new ArgumentNullException("predicate");
  2293. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate));
  2294. }
  2295. public static IAsyncQueryable<TSource> TakeWhile<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  2296. {
  2297. if (source == null)
  2298. throw new ArgumentNullException("source");
  2299. if (predicate == null)
  2300. throw new ArgumentNullException("predicate");
  2301. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate));
  2302. }
  2303. public static IOrderedAsyncQueryable<TSource> ThenBy<TSource, TKey>(this IOrderedAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  2304. {
  2305. if (source == null)
  2306. throw new ArgumentNullException("source");
  2307. if (keySelector == null)
  2308. throw new ArgumentNullException("keySelector");
  2309. return (IOrderedAsyncQueryable<TSource>)source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  2310. }
  2311. public static IOrderedAsyncQueryable<TSource> ThenBy<TSource, TKey>(this IOrderedAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  2312. {
  2313. if (source == null)
  2314. throw new ArgumentNullException("source");
  2315. if (keySelector == null)
  2316. throw new ArgumentNullException("keySelector");
  2317. if (comparer == null)
  2318. throw new ArgumentNullException("comparer");
  2319. return (IOrderedAsyncQueryable<TSource>)source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))));
  2320. }
  2321. public static IOrderedAsyncQueryable<TSource> ThenByDescending<TSource, TKey>(this IOrderedAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  2322. {
  2323. if (source == null)
  2324. throw new ArgumentNullException("source");
  2325. if (keySelector == null)
  2326. throw new ArgumentNullException("keySelector");
  2327. return (IOrderedAsyncQueryable<TSource>)source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  2328. }
  2329. public static IOrderedAsyncQueryable<TSource> ThenByDescending<TSource, TKey>(this IOrderedAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  2330. {
  2331. if (source == null)
  2332. throw new ArgumentNullException("source");
  2333. if (keySelector == null)
  2334. throw new ArgumentNullException("keySelector");
  2335. if (comparer == null)
  2336. throw new ArgumentNullException("comparer");
  2337. return (IOrderedAsyncQueryable<TSource>)source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))));
  2338. }
  2339. public static Task<TSource[]> ToArray<TSource>(this IAsyncQueryable<TSource> source)
  2340. {
  2341. if (source == null)
  2342. throw new ArgumentNullException("source");
  2343. return source.Provider.ExecuteAsync<TSource[]>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  2344. }
  2345. public static Task<TSource[]> ToArray<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  2346. {
  2347. if (source == null)
  2348. throw new ArgumentNullException("source");
  2349. return source.Provider.ExecuteAsync<TSource[]>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2350. }
  2351. public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  2352. {
  2353. if (source == null)
  2354. throw new ArgumentNullException("source");
  2355. if (keySelector == null)
  2356. throw new ArgumentNullException("keySelector");
  2357. return source.Provider.ExecuteAsync<Dictionary<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None);
  2358. }
  2359. public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, CancellationToken cancellationToken)
  2360. {
  2361. if (source == null)
  2362. throw new ArgumentNullException("source");
  2363. if (keySelector == null)
  2364. throw new ArgumentNullException("keySelector");
  2365. return source.Provider.ExecuteAsync<Dictionary<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2366. }
  2367. public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  2368. {
  2369. if (source == null)
  2370. throw new ArgumentNullException("source");
  2371. if (keySelector == null)
  2372. throw new ArgumentNullException("keySelector");
  2373. if (elementSelector == null)
  2374. throw new ArgumentNullException("elementSelector");
  2375. return source.Provider.ExecuteAsync<Dictionary<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None);
  2376. }
  2377. public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  2378. {
  2379. if (source == null)
  2380. throw new ArgumentNullException("source");
  2381. if (keySelector == null)
  2382. throw new ArgumentNullException("keySelector");
  2383. if (comparer == null)
  2384. throw new ArgumentNullException("comparer");
  2385. return source.Provider.ExecuteAsync<Dictionary<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))), CancellationToken.None);
  2386. }
  2387. public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, CancellationToken cancellationToken)
  2388. {
  2389. if (source == null)
  2390. throw new ArgumentNullException("source");
  2391. if (keySelector == null)
  2392. throw new ArgumentNullException("keySelector");
  2393. if (elementSelector == null)
  2394. throw new ArgumentNullException("elementSelector");
  2395. return source.Provider.ExecuteAsync<Dictionary<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2396. }
  2397. public static Task<Dictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
  2398. {
  2399. if (source == null)
  2400. throw new ArgumentNullException("source");
  2401. if (keySelector == null)
  2402. throw new ArgumentNullException("keySelector");
  2403. if (comparer == null)
  2404. throw new ArgumentNullException("comparer");
  2405. return source.Provider.ExecuteAsync<Dictionary<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2406. }
  2407. public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer)
  2408. {
  2409. if (source == null)
  2410. throw new ArgumentNullException("source");
  2411. if (keySelector == null)
  2412. throw new ArgumentNullException("keySelector");
  2413. if (elementSelector == null)
  2414. throw new ArgumentNullException("elementSelector");
  2415. if (comparer == null)
  2416. throw new ArgumentNullException("comparer");
  2417. return source.Provider.ExecuteAsync<Dictionary<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))), CancellationToken.None);
  2418. }
  2419. public static Task<Dictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
  2420. {
  2421. if (source == null)
  2422. throw new ArgumentNullException("source");
  2423. if (keySelector == null)
  2424. throw new ArgumentNullException("keySelector");
  2425. if (elementSelector == null)
  2426. throw new ArgumentNullException("elementSelector");
  2427. if (comparer == null)
  2428. throw new ArgumentNullException("comparer");
  2429. return source.Provider.ExecuteAsync<Dictionary<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2430. }
  2431. public static Task<List<TSource>> ToList<TSource>(this IAsyncQueryable<TSource> source)
  2432. {
  2433. if (source == null)
  2434. throw new ArgumentNullException("source");
  2435. return source.Provider.ExecuteAsync<List<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  2436. }
  2437. public static Task<List<TSource>> ToList<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  2438. {
  2439. if (source == null)
  2440. throw new ArgumentNullException("source");
  2441. return source.Provider.ExecuteAsync<List<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2442. }
  2443. public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  2444. {
  2445. if (source == null)
  2446. throw new ArgumentNullException("source");
  2447. if (keySelector == null)
  2448. throw new ArgumentNullException("keySelector");
  2449. return source.Provider.ExecuteAsync<ILookup<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None);
  2450. }
  2451. public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, CancellationToken cancellationToken)
  2452. {
  2453. if (source == null)
  2454. throw new ArgumentNullException("source");
  2455. if (keySelector == null)
  2456. throw new ArgumentNullException("keySelector");
  2457. return source.Provider.ExecuteAsync<ILookup<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2458. }
  2459. public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  2460. {
  2461. if (source == null)
  2462. throw new ArgumentNullException("source");
  2463. if (keySelector == null)
  2464. throw new ArgumentNullException("keySelector");
  2465. if (elementSelector == null)
  2466. throw new ArgumentNullException("elementSelector");
  2467. return source.Provider.ExecuteAsync<ILookup<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None);
  2468. }
  2469. public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  2470. {
  2471. if (source == null)
  2472. throw new ArgumentNullException("source");
  2473. if (keySelector == null)
  2474. throw new ArgumentNullException("keySelector");
  2475. if (comparer == null)
  2476. throw new ArgumentNullException("comparer");
  2477. return source.Provider.ExecuteAsync<ILookup<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))), CancellationToken.None);
  2478. }
  2479. public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, CancellationToken cancellationToken)
  2480. {
  2481. if (source == null)
  2482. throw new ArgumentNullException("source");
  2483. if (keySelector == null)
  2484. throw new ArgumentNullException("keySelector");
  2485. if (elementSelector == null)
  2486. throw new ArgumentNullException("elementSelector");
  2487. return source.Provider.ExecuteAsync<ILookup<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2488. }
  2489. public static Task<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
  2490. {
  2491. if (source == null)
  2492. throw new ArgumentNullException("source");
  2493. if (keySelector == null)
  2494. throw new ArgumentNullException("keySelector");
  2495. if (comparer == null)
  2496. throw new ArgumentNullException("comparer");
  2497. return source.Provider.ExecuteAsync<ILookup<TKey, TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2498. }
  2499. public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer)
  2500. {
  2501. if (source == null)
  2502. throw new ArgumentNullException("source");
  2503. if (keySelector == null)
  2504. throw new ArgumentNullException("keySelector");
  2505. if (elementSelector == null)
  2506. throw new ArgumentNullException("elementSelector");
  2507. if (comparer == null)
  2508. throw new ArgumentNullException("comparer");
  2509. return source.Provider.ExecuteAsync<ILookup<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))), CancellationToken.None);
  2510. }
  2511. public static Task<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken cancellationToken)
  2512. {
  2513. if (source == null)
  2514. throw new ArgumentNullException("source");
  2515. if (keySelector == null)
  2516. throw new ArgumentNullException("keySelector");
  2517. if (elementSelector == null)
  2518. throw new ArgumentNullException("elementSelector");
  2519. if (comparer == null)
  2520. throw new ArgumentNullException("comparer");
  2521. return source.Provider.ExecuteAsync<ILookup<TKey, TElement>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  2522. }
  2523. public static IAsyncQueryable<TSource> Union<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  2524. {
  2525. if (first == null)
  2526. throw new ArgumentNullException("first");
  2527. if (second == null)
  2528. throw new ArgumentNullException("second");
  2529. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)));
  2530. }
  2531. public static IAsyncQueryable<TSource> Union<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  2532. {
  2533. if (first == null)
  2534. throw new ArgumentNullException("first");
  2535. if (second == null)
  2536. throw new ArgumentNullException("second");
  2537. if (comparer == null)
  2538. throw new ArgumentNullException("comparer");
  2539. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))));
  2540. }
  2541. public static IAsyncQueryable<TSource> Where<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  2542. {
  2543. if (source == null)
  2544. throw new ArgumentNullException("source");
  2545. if (predicate == null)
  2546. throw new ArgumentNullException("predicate");
  2547. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate));
  2548. }
  2549. public static IAsyncQueryable<TSource> Where<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  2550. {
  2551. if (source == null)
  2552. throw new ArgumentNullException("source");
  2553. if (predicate == null)
  2554. throw new ArgumentNullException("predicate");
  2555. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate));
  2556. }
  2557. public static IAsyncQueryable<TResult> Zip<TFirst, TSecond, TResult>(this IAsyncQueryable<TFirst> first, IAsyncEnumerable<TSecond> second, Expression<Func<TFirst, TSecond, TResult>> selector)
  2558. {
  2559. if (first == null)
  2560. throw new ArgumentNullException("first");
  2561. if (second == null)
  2562. throw new ArgumentNullException("second");
  2563. if (selector == null)
  2564. throw new ArgumentNullException("selector");
  2565. return first.Provider.CreateQuery<TResult>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector));
  2566. }
  2567. }
  2568. }