public void Lookup <T>(int id, Action <AzureResponse <T> > callback) where T : class
        {
            var ms     = new MobileServiceRequestHelper <T>(_azureEndPoint, _applicationKey);
            var result = ms.Get(id);

            callback(result);
        }
        public void Read <T>(Action <AzureResponse <List <T> > > callback) where T : class
        {
            var ms     = new MobileServiceRequestHelper <T>(_azureEndPoint, _applicationKey);
            var result = ms.Get();

            callback(result);
        }
        public static void SetItemId <T>(T item, int?id) where T : class
        {
            var type = typeof(T);
            var prop = MobileServiceRequestHelper <T> .GetIdProperty();

            prop.SetValue(item, id, null);
        }
        /// <summary>
        /// Returns a filtered list.  NOTE: The predicate runs client side in
        /// the Unity Editor version, so you won't get the same behaviours.  It works server side on native deployments.
        /// It retrieves the maximum result page size (usually first 50 entries) and then filters it.
        /// </summary>
        public void Where <T>(Expression <Func <T, bool> > predicate, Action <AzureResponse <List <T> > > callback) where T : class
        {
            var ms     = new MobileServiceRequestHelper <T>(_azureEndPoint, _applicationKey);
            var result = ms.Query(predicate.Compile());

            callback(result);
        }
        public void Delete <T>(T item) where T : class
        {
            var type = typeof(T);
            var ms   = new MobileServiceRequestHelper <T>(_azureEndPoint, _applicationKey);
            var id   = (int)type.GetProperty("Id").GetValue(item, null);

            ms.Delete(id);
        }
        public void Insert <T>(T item) where T : class
        {
            var type = typeof(T);
            var ms   = new MobileServiceRequestHelper <T>(_azureEndPoint, _applicationKey);

            type.GetProperty("Id").SetValue(item, null, null);

            ms.Post(item);
        }
        public static int GetItemId <T>(T item) where T : class
        {
            var type = typeof(T);
            var prop = MobileServiceRequestHelper <T> .GetIdProperty();

            var id = (int)prop.GetValue(item, null);

            return(id);
        }
        /// <summary>
        /// Inserts a new item
        /// </summary>
        public void Insert <T>(T item, Action <AzureResponse <T> > callback = null) where T : class
        {
            Log("Inserting:" + item);
            var ms = CreateHelper <T>();

            MobileServiceRequestHelper <T> .SetItemId(item, null);

            ms.PostAsync(item, callback);
            Log("Insert request sent.");
        }
        /// <summary>
        /// Deletes a specific item.
        /// </summary>
        public void Delete <T>(T item, Action <AzureResponse <object> > callback = null) where T : class
        {
            Log("Deleting: " + item);
            var type = typeof(T);
            var id   = MobileServiceRequestHelper <T> .GetItemId <T>(item);

            var ms = CreateHelper <T>();

            ms.DeleteAsync(id, callback);
            Log("Delete request sent.");
        }
        /// <summary>
        /// Updates a specific item
        /// </summary>
        public void Update <T>(T item, Action <AzureResponse <T> > callback = null) where T : class
        {
            Log("Updating:" + item);
            var ms = CreateHelper <T>();
            var id = MobileServiceRequestHelper <T> .GetItemId <T>(item);

            MobileServiceRequestHelper <T> .SetItemId <T>(item, null);

            ms.PutAsync(item, id, callback);
            Log("Update request sent.");
            MobileServiceRequestHelper <T> .SetItemId <T>(item, id);
        }
        private MobileServiceRequestHelper <T> CreateHelper <T>() where T : class
        {
            var ms = new MobileServiceRequestHelper <T>(_azureEndPoint, _applicationKey, User);

            return(ms);
        }