<select id="pagedListOrderOpen">
SELECT * FROM (
</select>
<sql id="pagedListOrderClose">
) PagedList
<dynamic prepend="WHERE">
<isNotNull prepend="AND" property="StartIndex"><![CDATA[PagedList.rowNum>=#StartIndex#]]></isNotNull>
<isNotNull prepend="AND" property="EndIndex"><![CDATA[PagedList.rowNum<=#EndIndex#]]></isNotNull>
</dynamic>
</sql>
<select id="selOrdersWithPaging" parameterClass="OrderSearch" resultClass="Order" extends="pagedListOrderOpen" resultMap="OrderMappingResult">
SELECT O.*,rowNum = ROW_NUMBER() OVER(ORDER BY OrderId DESC)
FROM OrderInfo AS O (NOLOCK)
<include refid="fuzzySearchActivityConfig"/>
<include refid="pagedListOrderClose" />
</select>
<sql id="fuzzySearchOrder">
<dynamic prepend="WHERE">
<isNotEmpty property="Caption" prepend="AND">
<![CDATA[O.Caption LIKE '%$Caption$%']]>
</isNotEmpty>
<isNotNull property="SaleStartDate" prepend="AND">
<![CDATA[O.SaleDate >= #SaleStartDate#]]>
</isNotNull>
<isNotNull property="SaleEndDate" prepend="AND">
<![CDATA[O.SaleDate <= #SaleEndDate#]]>
</isNotNull>
<isNotEmpty property="Status" prepend="AND">
<![CDATA[O.Status=#Status#]]>
</isNotEmpty>
</dynamic>
</sql>