diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index 121074a6e..878fcbe0c 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -3618,7 +3618,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
var whereText = " where Type=@SelectType";
whereText += " And CleanName In (Select CleanValue from ItemValues where Type=@ItemValueType AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
- cmd.CommandText += whereText;
var outerQuery = new InternalItemsQuery(query.User)
{
@@ -3638,10 +3637,13 @@ namespace MediaBrowser.Server.Implementations.Persistence
var outerWhereClauses = GetWhereClauses(outerQuery, cmd);
- var outerWhereText = outerWhereClauses.Count == 0 ?
+ whereText += outerWhereClauses.Count == 0 ?
string.Empty :
" AND " + string.Join(" AND ", outerWhereClauses.ToArray());
- cmd.CommandText += outerWhereText;
+ //cmd.CommandText += GetGroupBy(query);
+
+ cmd.CommandText += whereText;
+ cmd.CommandText += " group by PresentationUniqueKey";
cmd.Parameters.Add(cmd, "@SelectType", DbType.String).Value = returnType;
cmd.Parameters.Add(cmd, "@ItemValueType", DbType.Int32).Value = itemValueType;
@@ -3651,9 +3653,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.Parameters.Add(cmd, "@UserId", DbType.Guid).Value = query.User.Id;
}
- //cmd.CommandText += GetGroupBy(query);
- cmd.CommandText += " group by PresentationUniqueKey";
-
cmd.CommandText += " order by SortName";
if (query.Limit.HasValue || query.StartIndex.HasValue)
@@ -3679,7 +3678,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
if (query.EnableTotalRecordCount)
{
- cmd.CommandText += "select count (guid)" + GetFromText();
+ cmd.CommandText += "select count (distinct PresentationUniqueKey)" + GetFromText();
cmd.CommandText += GetJoinUserDataText(query);
cmd.CommandText += whereText;
diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
index 3456ea2cc..a8fedd678 100644
--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
@@ -965,9 +965,6 @@
PreserveNewest
-
- PreserveNewest
-
PreserveNewest