/// <summary>
 /// Pulls the data from the remote Azure App Service and stores them into the local database.
 /// </summary>
 /// <param name="ct">The cancellation token.</param>
 /// <param name="uniqueQueryId">The unique ID of the query.</param>
 /// <param name="predicate">The predicate to use.</param>
 /// <returns></returns>
 public async Task Pull(CancellationToken ct, string uniqueQueryId, Expression <Func <T, bool> > predicate)
 {
     if (_supportsLocalStore)
     {
         await TableLocal.PullAsync(uniqueQueryId, TableLocal.Where(predicate), ct);
     }
 }
 /// <summary>
 /// Performs a database Get operation and returns the item that corresponds to the specified id.
 /// </summary>
 /// <param name="id">The id to find</param>
 /// <returns>The requested T object</returns>
 public async Task <T> FindById(string id)
 {
     if (_supportsLocalStore)
     {
         return(await TableLocal.LookupAsync(id));
     }
     else
     {
         return(await TableCloud.LookupAsync(id));
     }
 }
 /// <summary>
 /// Performs a database Get operation and returns all of the items included in the table.
 /// </summary>
 /// <returns></returns>
 public async Task <List <T> > FindAll()
 {
     if (_supportsLocalStore)
     {
         return(await TableLocal.ToListAsync());
     }
     else
     {
         return(await TableCloud.ToListAsync());
     }
 }
 /// <summary>
 /// Performs a database Delete operation.
 /// </summary>
 /// <param name="objectToDelete">The object to delete.</param>
 /// <returns></returns>
 public async Task Delete(T objectToDelete)
 {
     if (_supportsLocalStore)
     {
         await TableLocal.DeleteAsync(objectToDelete);
     }
     else
     {
         await TableCloud.DeleteAsync(objectToDelete);
     }
 }
 /// <summary>
 /// Performs a database Update operation.
 /// </summary>
 /// <param name="objectToUpdate">The object to update.</param>
 /// <returns></returns>
 public async Task Update(T objectToUpdate)
 {
     if (_supportsLocalStore)
     {
         await TableLocal.UpdateAsync(objectToUpdate);
     }
     else
     {
         await TableCloud.UpdateAsync(objectToUpdate);
     }
 }
 /// <summary>
 /// Performs a database Insert operation.
 /// </summary>
 /// <param name="objectToSave">The object to save.</param>
 /// <returns></returns>
 public async Task Insert(T objectToSave)
 {
     if (_supportsLocalStore)
     {
         await TableLocal.InsertAsync(objectToSave);
     }
     else
     {
         await TableCloud.InsertAsync(objectToSave);
     }
 }
        /// <summary>
        /// Performs a database Get operation and returns all of the items that correspond to the specified predicate.
        /// </summary>
        /// <param name="predicate">The predicate to use.</param>
        /// <param name="criteria">The criteria for the where clause.</param>
        /// <returns>The list of T objects matching the predicate or the criteria</returns>
        public async Task <List <T> > FindAll(Expression <Func <T, bool> > predicate, Dictionary <string, object> criteria = null)
        {
            if (_supportsLocalStore)
            {
                if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    if (PredicateCanRunAsSql(predicate.Body.ToString()) && criteria != null)
                    {
                        return(FindAllSql(criteria));
                    }
                }

                return(await TableLocal.Where(predicate).ToListAsync());
            }
            else
            {
                return(await TableCloud.Where(predicate).ToListAsync());
            }
        }