public void CreateQueryGeneric() { IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret..."); IMobileServiceTable <StringType> table = service.GetTable <StringType>(); IMobileServiceTableQuery <StringType> query = table.CreateQuery(); Assert.IsNotNull(query); }
// Table input binding // This binding supplies a strongly-typed IMobileServiceTable<T> to the function. This allows // for queries, inserts, updates, and deletes to all be made against the table. // See the 'Input bindings' section below for more info. public static async Task DeleteProcessedItems( [TimerTrigger("00:05")] TimerInfo timerInfo, [EasyTable] IMobileServiceTable <Item> table) { IEnumerable <Item> processedItems = await table.CreateQuery() .Where(i => i.IsProcessed && i.ProcessedAt < DateTime.Now.AddMinutes(-5)) .ToListAsync(); foreach (Item i in processedItems) { await table.DeleteAsync(i); } }
public IMobileServiceTableQuery <T> Convert(MobileTableAttribute attribute) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } // The Table POCO rule already knows how to get the table MobileTablePocoTableBuilder <T> tablePocoBuilder = new MobileTablePocoTableBuilder <T>(_config); IMobileServiceTable <T> table = tablePocoBuilder.Convert(attribute); return(table.CreateQuery()); }
public async Task <List <PracticasDetalle> > GetDetailItems(string IdPractica) { List <PracticasDetalle> ret = null; try { var query = _tbPractica_Detalles.CreateQuery().Where(p => p.IdPractica == IdPractica); IEnumerable <PracticasDetalle> Items = await _tbPractica_Detalles.ReadAsync(query); ret = new List <PracticasDetalle>(Items); } catch (Exception ex) { Debug.WriteLine(@"Error {0}", ex.Message); ret = new List <PracticasDetalle>(); } return(ret); }
public object GetValue() { Type paramType = this.Type; if (paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof(IMobileServiceTableQuery <>)) { // If TableName is specified, add it to the internal table cache. Now items of this type // will operate on the specified TableName. if (!string.IsNullOrEmpty(_context.ResolvedTableName)) { _context.Client.AddToTableNameCache(typeof(T), _context.ResolvedTableName); } IMobileServiceTable <T> table = _context.Client.GetTable <T>(); return(table.CreateQuery()); } return(null); }
private async Task SyncAsync() { await App.MobileService.SyncContext.PushAsync(); await todoGetTable.PullAsync("AppLogins", todoTable.CreateQuery()); }
public async Task <IEnumerable <Category> > GetCategoriesAsync() { return((await _categoryTable.CreateQuery().ToEnumerableAsync()).ToArray()); }
public async Task <IEnumerable <ExpenseReceipt> > GetExpenseReceiptsAsync(string expenseId) { return((await _expenseReceiptTable.CreateQuery().Where(x => x.ExpenseId == expenseId).ToEnumerableAsync()) .ToArray()); }
public async Task <IEnumerable <Expense> > GetExpensesAsync() { return((await _expenseTable.CreateQuery() .ToEnumerableAsync()) .ToArray()); }
/// <summary> /// Create a new collection view based on the query. /// </summary> /// <returns>The collection view.</returns> public static MobileServiceIncrementalLoadingCollection <TTable, TTable> ToIncrementalLoadingCollection <TTable>(this IMobileServiceTable <TTable> table) { return(table.CreateQuery().ToIncrementalLoadingCollection()); }
protected override void OnCreate(Bundle bundle) { List <GameData> gameDataListTemp = new List <GameData>(); likeCloudGameDataList = new List <string> (); likeGameDataListResults = new List <GameData> (); //read in like list storagePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); storageFile = storagePath + "/appinate.json"; if (File.Exists(storageFile)) { string likeString = File.ReadAllText(storageFile); likeGameDataList = JsonConvert.DeserializeObject <List <GameData> > (likeString); gameDataList = new List <GameData> (); firstTime = false; } base.OnCreate(bundle); if (firstTime) { likeGameDataList = new List <GameData> (); gameDataList = new List <GameData> (); } firstTime = false; // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); Spinner spinner = FindViewById <Spinner> (Resource.Id.spinner1); spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected); var adapter = ArrayAdapter.CreateFromResource( this, Resource.Array.gamer_type_array, Android.Resource.Layout.SimpleSpinnerItem); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spinner.Adapter = adapter; Button buttonEditLikes = FindViewById <Button> (Resource.Id.button1); CheckBox checkbox2 = FindViewById <CheckBox> (Resource.Id.checkBox2); buttonEditLikes.Click += async(sender, e) => { if (!checkbox2.Checked) { //turn phase 3 completely off //MainActivity.currentSelectedGamerType=""; } StartActivity(typeof(LikeActivity)); }; CheckBox checkbox = FindViewById <CheckBox> (Resource.Id.checkBox1); checkbox2.Click += async(sender, e) => { //Getting back the data: if (MainActivity.currentSelectedGamerType == "General") { checkbox2.Checked = !checkbox2.Checked; } else { if (currentSelectedGamerType != "") { switch (currentSelectedGamerType) { case "Casual": IMobileServiceTable <CasualGamer> casualTable = MobileService.GetTable <CasualGamer>(); IMobileServiceTableQuery <CasualGamer> query = casualTable.CreateQuery().OrderByDescending(t => t.date); List <CasualGamer> games = await query.ToListAsync(); likeCloudGameDataList.Add(games.First().myList); break; case "Hardcore": IMobileServiceTable <HardcoreGamer> hardcoreTable = MobileService.GetTable <HardcoreGamer>(); IMobileServiceTableQuery <HardcoreGamer> query2 = hardcoreTable.CreateQuery().OrderByDescending(t => t.date); List <HardcoreGamer> games2 = await query2.ToListAsync(); likeCloudGameDataList.Add(games2.First().myList); break; case "Puzzle": IMobileServiceTable <PuzzleGamer> puzzleTable = MobileService.GetTable <PuzzleGamer>(); IMobileServiceTableQuery <PuzzleGamer> query3 = puzzleTable.CreateQuery().OrderByDescending(t => t.date); List <PuzzleGamer> games3 = await query3.ToListAsync(); likeCloudGameDataList.Add(games3.First().myList); break; case "Apps User": IMobileServiceTable <AppUser> appUserTable = MobileService.GetTable <AppUser>(); IMobileServiceTableQuery <AppUser> query4 = appUserTable.CreateQuery().OrderByDescending(t => t.date); List <AppUser> games4 = await query4.ToListAsync(); likeCloudGameDataList.Add(games4.First().myList); break; case "Racing": IMobileServiceTable <RacingGamer> racingTable = MobileService.GetTable <RacingGamer>(); IMobileServiceTableQuery <RacingGamer> query5 = racingTable.CreateQuery().OrderByDescending(t => t.date); List <RacingGamer> games5 = await query5.ToListAsync(); likeCloudGameDataList.Add(games5.First().myList); break; } if (likeCloudGameDataList.Count > 0) { string toast2 = string.Format("Cloud like data downloaded to device."); Toast.MakeText(this, toast2, ToastLength.Long).Show(); } } else { string toast3 = string.Format("Current Gamer Category is blank"); Toast.MakeText(this, toast3, ToastLength.Long).Show(); } } }; // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button> (Resource.Id.myButton); button.Click += async(sender, e) => { CurrentPlatform.Init(); string recommendation = ""; numSeperateLists = 1; int maxSize = 3; if (checkbox2.Checked) { //we're using phase three: cloud recommendations maxSize = 4; } gameDataList.Clear(); gameDataListTemp.Clear(); string[] recommendations = new string[200]; int sizeOfRecommendations; if (checkbox.Checked) { recommendation = CollectRecommendations(); } TextView text = FindViewById <TextView> (Resource.Id.autoCompleteTextView1); string apiUrl = "https://42matters.com/api/1/apps/query.json?access_token=8baf2a81c06ef3af38cd6ee3bbfee42f74e2497a"; if (checkbox2.Checked) { if (likeCloudGameDataList.Count <= 0) { string toast = string.Format("There is no cloud data for that category, try again!"); Toast.MakeText(this, toast, ToastLength.Long).Show(); return; } //phase 3 recommendation += likeCloudGameDataList.Last(); } sizeOfRecommendations = this.TrimToStringArray(recommendation, ref recommendations); int currentRecommendationIndex = 0; int recommendationsToSearch = Math.Min(sizeOfRecommendations, maxSize); string searchTerm = text.Text; if (searchTerm == "") { //we must have not searched on anything, skip it and use first recommendation instead if (currentRecommendationIndex < recommendations.Length) { searchTerm = recommendations[currentRecommendationIndex]; } else { currentRecommendationIndex = recommendationsToSearch; //skip to end } currentRecommendationIndex++; } do { string Matters42 = "https://42matters.com/api/1/apps/search.json?q=" + searchTerm + "&limit=50&page=2&&access_token=8baf2a81c06ef3af38cd6ee3bbfee42f74e2497a"; string strUri = string.Format(Matters42); //Download string using webclient object var webclient = new WebClient(); string strResultData = ""; try { strResultData = await webclient.DownloadStringTaskAsync(new System.Uri(strUri)); } catch { Toast.MakeText(this, "Unable to connect to server!!!", ToastLength.Short).Show(); } finally { webclient.Dispose(); //dispose webclient object //List<GameDataResults> result = JsonConvert.DeserializeObject<List<GameDataResults>>(strResultData); var jObj = (JObject)JsonConvert.DeserializeObject(strResultData); var result = jObj["results"] .Select(item => new GameData { promo_video = (string)item["promo_video"], description = (string)item["description"], icon = (string)item["icon"], title = (string)item["title"], market_url = (string)item["market_url"] }) .ToList(); gameDataListTemp = result; int index = 0; foreach (GameData g in gameDataListTemp) { if (index < 20) { gameDataList.Insert(index * numSeperateLists, g); } index++; } } if (currentRecommendationIndex < recommendations.Length) { searchTerm = recommendations[currentRecommendationIndex]; } else { currentRecommendationIndex = recommendationsToSearch; //skip to end } currentRecommendationIndex++; numSeperateLists++; } while (currentRecommendationIndex < recommendationsToSearch); pruneGameDataListWithLikeList(); //remove games which are already in users like list! StartActivity(typeof(ResultsActivity)); }; }
public async Task <int> populateCloudLikeList() { if (currentSelectedGamerType != "") { switch (currentSelectedGamerType) { case "Casual": IMobileServiceTable <CasualGamer> casualTable = MobileService.GetTable <CasualGamer>(); IMobileServiceTableQuery <CasualGamer> query = casualTable.CreateQuery().OrderByDescending(t => t.date); List <CasualGamer> games = await query.ToListAsync(); likeCloudGameDataList.Add(games.First().myList); break; case "Hardcore": IMobileServiceTable <HardcoreGamer> hardcoreTable = MobileService.GetTable <HardcoreGamer>(); IMobileServiceTableQuery <HardcoreGamer> query2 = hardcoreTable.CreateQuery().OrderByDescending(t => t.date); List <HardcoreGamer> games2 = await query2.ToListAsync(); likeCloudGameDataList.Add(games2.First().myList); break; case "Puzzle": IMobileServiceTable <PuzzleGamer> puzzleTable = MobileService.GetTable <PuzzleGamer>(); IMobileServiceTableQuery <PuzzleGamer> query3 = puzzleTable.CreateQuery().OrderByDescending(t => t.date); List <PuzzleGamer> games3 = await query3.ToListAsync(); likeCloudGameDataList.Add(games3.First().myList); break; case "Apps User": IMobileServiceTable <AppUser> appUserTable = MobileService.GetTable <AppUser>(); IMobileServiceTableQuery <AppUser> query4 = appUserTable.CreateQuery().OrderByDescending(t => t.date); List <AppUser> games4 = await query4.ToListAsync(); likeCloudGameDataList.Add(games4.First().myList); break; case "Racing": IMobileServiceTable <RacingGamer> racingTable = MobileService.GetTable <RacingGamer>(); IMobileServiceTableQuery <RacingGamer> query5 = racingTable.CreateQuery().OrderByDescending(t => t.date); List <RacingGamer> games5 = await query5.ToListAsync(); likeCloudGameDataList.Add(games5.First().myList); break; } if (likeCloudGameDataList.Count > 0) { string toast2 = string.Format("Cloud like data downloaded to device."); Toast.MakeText(this, toast2, ToastLength.Long).Show(); return(1); } } else { string toast3 = string.Format("Current Gamer Category is blank"); Toast.MakeText(this, toast3, ToastLength.Long).Show(); return(0); } return(0); }
public IMobileServiceTableQuery <T> GetQuery() { return(table.CreateQuery()); }
public async Task <IEnumerable <Report> > GetReportsAsync() { return((await _reportTable.CreateQuery() .ToEnumerableAsync()) .ToArray()); }
/// <summary> /// Create a new collection based on the table. /// </summary> /// <param name="table"> /// The table from which to create the new collection. /// </param> /// <param name="pageSize"> /// Optional page size. /// </param> /// <returns>The collection.</returns> public static Task <MobileServiceCollection <TTable, TTable> > ToCollectionAsync <TTable>(this IMobileServiceTable <TTable> table, int pageSize = 0) => table.CreateQuery().ToCollectionAsync(pageSize);