U4-8786 Member search in listview returns error (7.5-beta2)

This commit is contained in:
Shannon
2016-08-04 18:01:57 +02:00
parent 9d62b2f5f9
commit 0be81aa4e5
2 changed files with 33 additions and 4 deletions

View File

@@ -453,8 +453,14 @@ namespace Umbraco.Core.Persistence.Repositories
Func<Tuple<string, object[]>> filterCallback = null;
if (filter.IsNullOrWhiteSpace() == false)
{
sbWhere.Append("AND (umbracoNode." + SqlSyntax.GetQuotedColumnName("text") + " LIKE @" + args.Count + ")");
sbWhere
.Append("AND (umbracoNode.")
.Append(SqlSyntax.GetQuotedColumnName("text"))
.Append(" LIKE @")
.Append(args.Count)
.Append(")");
args.Add("%" + filter + "%");
filterCallback = () => new Tuple<string, object[]>(sbWhere.ToString().Trim(), args.ToArray());
}

View File

@@ -622,9 +622,32 @@ namespace Umbraco.Core.Persistence.Repositories
Func<Tuple<string, object[]>> filterCallback = null;
if (filter.IsNullOrWhiteSpace() == false)
{
sbWhere.Append("AND ((umbracoNode. " + SqlSyntax.GetQuotedColumnName("text") + " LIKE @" + args.Count + ") " +
"OR (cmsMember.LoginName LIKE @0" + args.Count + "))");
args.Add("%" + filter + "%");
//This will build up the where clause - even though the same 'filter' is being
//applied to both columns, the parameters values passed to PetaPoco need to be
//duplicated, otherwise it gets confused :/
var columnFilters = new List<Tuple<string, string>>
{
new Tuple<string, string>("umbracoNode", "text"),
new Tuple<string, string>("cmsMember", "LoginName")
};
sbWhere.Append("AND (");
for (int i = 0; i < columnFilters.Count; i++)
{
sbWhere
.Append("(")
.Append(SqlSyntax.GetQuotedTableName(columnFilters[i].Item1))
.Append(".")
.Append(SqlSyntax.GetQuotedColumnName(columnFilters[i].Item2))
.Append(" LIKE @")
.Append(args.Count)
.Append(") ");
args.Add(string.Format("%{0}%", filter));
if (i < (columnFilters.Count - 1))
{
sbWhere.Append("OR ");
}
}
sbWhere.Append(")");
filterCallback = () => new Tuple<string, object[]>(sbWhere.ToString().Trim(), args.ToArray());
}