mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Perf improvement in localization service. Replacing List() with Slice(1) and no need to use overload on Query as it is taken care of in inner query
This commit is contained in:
@@ -29,15 +29,13 @@ namespace Orchard.Localization.Services {
|
||||
if (localized == null)
|
||||
return null;
|
||||
|
||||
var query = versionOptions == null
|
||||
? _contentManager.Query<LocalizationPart>(content.ContentItem.ContentType)
|
||||
: _contentManager.Query<LocalizationPart>(versionOptions, content.ContentItem.ContentType);
|
||||
|
||||
// Warning: Returns only the first of same culture localizations.
|
||||
return query.Where<LocalizationPartRecord>(l =>
|
||||
return _contentManager
|
||||
.Query<LocalizationPart>(versionOptions, content.ContentItem.ContentType)
|
||||
.Where<LocalizationPartRecord>(l =>
|
||||
(l.Id == content.ContentItem.Id || l.MasterContentItemId == content.ContentItem.Id)
|
||||
&& l.CultureId == cultureRecord.Id)
|
||||
.List()
|
||||
.Slice(1)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user