0
是以下任一方法,用於查詢使用蒙戈DB驅動爲C#比其他?:更優化對於使用Mongo Db Driver for C#查詢而不是其他方法,哪種方法更優化?
變種partsLogs = MvcApplication.MongoLoggingDatabase.GetCollection( 「PartDetailLog」) .FindAll()
.Where(x => x.UserId == UserId) .Select(x => new RecentActivityPartsLogDto { OemCode = x.Request.OemCode, OemPartCode = x.Request.OemPartCode, OemPartDescription = x.Request.OemPartDescription, TimeStamp = x.TimeStamp, UserId = x.UserId.ToString() }) .OrderByDescending(x => x.TimeStamp) .Skip(pageSize * (page - 1)) .Take(pageSize);
或者
var doc = new QueryDocument(); doc [「UserId」] = UserId;
VAR partsLogs = MvcApplication.MongoLoggingDatabase.GetCollection( 「PartDetailLog」)
.Find(doc) .Select(x => new RecentActivityPartsLogDto { OemCode = x.Request.OemCode, OemPartCode = x.Request.OemPartCode, OemPartDescription = x.Request.OemPartDescription, TimeStamp = x.TimeStamp, UserId = x.UserId.ToString()}) .OrderByDescending(x => x.TimeStamp) .Skip(pageSize*(page - 1)) .Take(pageSize);
是否有其他recomendations使這個查詢更好嗎?