久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

MoreLinq maxBy vs LINQ max + where

MoreLinq maxBy vs LINQ max + where(MoreLinq maxBy vs LINQ max + where)
本文介紹了MoreLinq maxBy vs LINQ max + where的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我將 EF5MoreLinq 擴展一起使用,在生產中測試我的程序(非常大的數(shù)據(jù)庫)時,我發(fā)現(xiàn)該行:

I am using EF5 with the MoreLinq extenstion, while testing my program in production (very big database), I found out that the line:

var x = db.TheBigTable.MaxBy(x => x.RecordTime);

需要很長時間(RecordTime 是一個非索引的datetime)

Takes very long time (RecordTime is a non-indexed datetime)

是不是因為MaxBy 總是在客戶端運行(并且首先從數(shù)據(jù)庫中獲取所有記錄)?

Is that because MaxBy always runs on the client side (and firstly gets ALL records from the database)?

推薦答案

這里是 MaxBy 擴展方法:

Here is the signature of the MaxBy extension method:

public static TSource MaxBy<TSource, TKey>(this IEnumerable<TSource> source,
    Func<TSource, TKey> selector)
{
    return source.MaxBy(selector, Comparer<TKey>.Default);
}

它返回 IEnumerable 的最大元素(基于給定的投影),而不是 IQueryable.所以查詢db.TheBigTable的結果確實都是先加載到內存中,然后迭代求最大值.

It returns the maximal element (based on the given projection) of an IEnumerable<T>, not an IQueryable<T>. So the results of the query db.TheBigTable are indeed all loaded into memory first, and then they are iterated to find the maximum.

這篇關于MoreLinq maxBy vs LINQ max + where的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語法?)
How to set null value to int in c#?(如何在c#中將空值設置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調用)
主站蜘蛛池模板: 国产精品亚洲成在人线 | 免费超碰| 天天干,夜夜操 | 欧美日韩亚洲国产 | 久久久久久黄 | 天天天操操操 | 99视频在线播放 | 国产在线中文字幕 | 黄网站免费在线 | 欧美激情在线精品一区二区三区 | 拍拍无遮挡人做人爱视频免费观看 | 中文字幕在线不卡播放 | 亚洲成人午夜电影 | 色婷婷在线视频 | 久草热在线| 精品国产一区二区国模嫣然 | 在线免费黄色 | 在线观看视频91 | 99热都是精品 | 久久国产精品72免费观看 | 嫩草视频入口 | 久草影视在线 | 综合网中文字幕 | 九九热精品在线 | 一区二区三区精品视频 | 欧美精品一区二区三区在线 | 久久久免费少妇高潮毛片 | 日韩欧美一区在线 | 亚洲欧美一区二区三区国产精品 | 日韩欧美在线一区 | 在线日韩福利 | 影音先锋男 | 国产成人精品免费视频大全最热 | 国产日韩欧美另类 | 国产日韩精品一区二区三区 | 欧美日韩国产一区二区三区 | 一区二区av在线 | 色男人天堂av | 久草网站 | 365夜爽爽欧美性午夜免费视频 | 日韩亚洲欧美综合 |