#19342: Using Eq operator when querying a single content type

Work Item: 19342

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2013-04-29 16:16:23 -07:00
parent 6353e6b94e
commit 4680c32825

View File

@@ -66,7 +66,13 @@ namespace Orchard.ContentManagement {
private void ForType(params string[] contentTypeNames) {
if (contentTypeNames != null && contentTypeNames.Length != 0)
BindTypeCriteria().Add(Restrictions.InG("Name", contentTypeNames));
// don't use the IN operator if not needed for performance reasons
if (contentTypeNames.Length == 1) {
BindTypeCriteria().Add(Restrictions.Eq("Name", contentTypeNames[0]));
}
else {
BindTypeCriteria().Add(Restrictions.InG("Name", contentTypeNames));
}
}
public void ForVersion(VersionOptions options) {