public int GetStatMetaDataCount(Query query)
 {
     using (var conn = Database.OpenMonitorDatabase())
     {
         var tuple = Sql.SelectMetaDataCount(query);
          var result =conn.ExecuteScalar<int>(tuple.Item1, (object)tuple.Item2);
          return result;
     }
 }
 public IEnumerable<Model.StatMetaData.StatMetaData> SelectBy(Query query, out int totalRows)
 {
     if (query.PageIndex <= 0)
     {
         query.PageIndex = 1;
     }
     if (query.PageSize <= 0)
     {
         query.PageSize = 100;
     }
     using (var conn = Database.OpenMonitorDatabase())
     {
         var tuple = Sql.SelectMetaDataCount(query);
         totalRows = conn.ExecuteScalar<int>(tuple.Item1, (object)tuple.Item2);
         return conn.Query<Model.StatMetaData.StatMetaData>(Sql.SelectByQuery(query), query);
     }
 }