Browse files

Fixed case-sensitive WHERE replacer

  • Loading branch information...
1 parent b11d943 commit 14e117421d89d141cd26455b712c71a3b0eda2cc @subsonic subsonic committed Feb 21, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 Massive.cs
View
6 Massive.cs
@@ -8,6 +8,7 @@
using System.Linq;
using System.Text;
using System.Collections;
+using System.Text.RegularExpressions;
namespace Massive {
public static class ObjectExtensions {
@@ -340,12 +341,13 @@ public class DynamicModel {
var sql = string.Format("SELECT {0} FROM (SELECT ROW_NUMBER() OVER (ORDER BY {2}) AS Row, {0} FROM {3}) AS Paged ",columns,pageSize,orderBy,TableName);
var pageStart = (currentPage -1) * pageSize;
sql+= string.Format(" WHERE Row >={0} AND Row <={1}",pageStart, (pageStart + pageSize));
+ var pagedWhere = "";
if (!string.IsNullOrEmpty(where)) {
if (where.Trim().StartsWith("where", StringComparison.CurrentCultureIgnoreCase)) {
- where = where.Replace("where ", "and ");
+ pagedWhere = Regex.Replace(where, "where ", "and ", RegexOptions.IgnoreCase);
}
}
- sql += where;
+ sql += pagedWhere;
countSQL += where;
result.TotalRecords = Scalar(countSQL,args);
result.TotalPages = result.TotalRecords / pageSize;

0 comments on commit 14e1174

Please sign in to comment.