/// <summary>
        ///     Run a query given by its query spec, only returning results from the selected page.
        /// </summary>
        /// <param name="querySpec"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public JArray Query(QuerySpec querySpec, int pageIndex)
        {
            lock (smartlock)
            {
                QuerySpec.SmartQueryType qt = querySpec.QueryType;
                var    results    = new JArray();
                string sql        = ConvertSmartSql(querySpec.SmartSql);
                int    offsetRows = querySpec.PageSize * pageIndex;
                int    numberRows = querySpec.PageSize;
                string limit      = offsetRows + "," + numberRows;

                using (ISQLiteStatement statement = DBHelper.GetInstance(DatabasePath)
                                                    .LimitRawQuery(sql, limit, querySpec.getArgs()))
                {
                    if (statement.DataCount > 0)
                    {
                        do
                        {
                            if (qt == QuerySpec.SmartQueryType.Smart)
                            {
                                results.Add(GetDataFromRow(statement));
                            }
                            else
                            {
                                results.Add(JObject.Parse(GetObject(statement, 0).ToString()));
                            }
                        } while (statement.Step() == SQLiteResult.ROW);
                    }
                    statement.ResetAndClearBindings();
                }
                return(results);
            }
        }
 /// <summary>
 ///     count of results for a "smart" query
 /// </summary>
 /// <param name="querySpec"></param>
 /// <returns></returns>
 public long CountQuery(QuerySpec querySpec)
 {
     lock (smartlock)
     {
         String countSql = ConvertSmartSql(querySpec.CountSmartSql);
         return(DBHelper.GetInstance(DatabasePath).CountRawCountQuery(countSql, querySpec.getArgs()));
     }
 }
 /// <summary>
 ///     count of results for a "smart" query
 /// </summary>
 /// <param name="querySpec"></param>
 /// <returns></returns>
 public long CountQuery(QuerySpec querySpec)
 {
     lock (smartlock)
     {
         String countSql = ConvertSmartSql(querySpec.CountSmartSql);
         return DBHelper.GetInstance(DatabasePath).CountRawCountQuery(countSql, querySpec.getArgs());
     }
 }
        /// <summary>
        ///     Run a query given by its query spec, only returning results from the selected page.
        /// </summary>
        /// <param name="querySpec"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public JArray Query(QuerySpec querySpec, int pageIndex)
        {
            lock (smartlock)
            {
                QuerySpec.SmartQueryType qt = querySpec.QueryType;
                var results = new JArray();
                string sql = ConvertSmartSql(querySpec.SmartSql);
                int offsetRows = querySpec.PageSize * pageIndex;
                int numberRows = querySpec.PageSize;
                string limit = offsetRows + "," + numberRows;

                using (ISQLiteStatement statement = DBHelper.GetInstance(DatabasePath)
                    .LimitRawQuery(sql, limit, querySpec.getArgs()))
                {
                    if (statement.DataCount > 0)
                    {
                        do
                        {
                            if (qt == QuerySpec.SmartQueryType.Smart)
                            {
                                results.Add(GetDataFromRow(statement));
                            }
                            else
                            {
                                results.Add(JObject.Parse(GetObject(statement, 0).ToString()));
                            }
                        } while (statement.Step() == SQLiteResult.ROW);
                    }
                    statement.ResetAndClearBindings();
                }
                return results;
            }
        }