QueryText = string.Format("SELECT {0}, {1} Path FROM Scope() "
+ "WHERE {0} = 'test' AND {1} BETWEEN '"
+ minimumDate.ToString("yyyy-MM-dd HH:mm:ss") + "' AND '" + maximumDate.ToString("yyyy-MM-dd HH:mm:ss")
+ "' ORDER BY {1} Desc", "TestField", "DateField");
minimumDate 和 maximumDate 的类型为 DateTime (.net DateTime)。这是一个全文 SQL 查询。
注意:在添加子句之间的日期之前 - 此查询很好,因此字段肯定存在等。
编辑:实际查询字符串:
"SELECT TestField, DateField FROM Scope() WHERE TestField = 'test' AND DateField BETWEEN '2011-06-30 09:41:23' AND '2012-06-29 09:41:23' ORDER BY DateField Desc"
编辑:我犯了一个错误,说它在 between 子句之前就起作用了——我一定是篡改了 select,因为我省略了一个重要的逗号。