简体   繁体   中英

How to use where query from IMobileServiceTableQuery in xamarin Forms?

i tried get the object id from the email, can i do that in IMobileServiceTableQuery, so if i write my query in sql server it will be something like this SELECT id from Member where email = 'nani@gmail.com' ,so how to do that in IMobileServiceTableQuery , as far i know only with this IMobileServiceTableQuery<T> Where(Expression<Func<T, bool>> predicate); , but i dont know how to implement it.

ok i try with this code, is this code right ?

 public async void GetId(AuthenticationResult result)
        {
            var client = new MobileServiceClient(Constants.ApplicationURL);
            IMobileServiceTable<Member> onlineTable = client.GetTable<Member>();
            var items = await onlineTable
                .Where(t => t.email == "gumilangtheodorus@gmail.com") // HardCode
                .Select(t => t.Id).ToListAsync();
        }

and how to display the id that i get, can i use like this txtid.Text = t.Id; ?

You can try for the similar code as below:

{           var client = new MobileServiceClient (Constantes.ApplicationURL);
            IMobileServiceTable perso = client.GetTable ();
            MobileServiceCollection <Personitas, Personitas> items = await perso
                                              .Where (! Ti => ti.Nombre = null) .ToCollectionAsync ();
            listi.ItemsSource = items.Select (apa => string.Format ( "{0} {1}", apa.Name, apa.LastName));        }

If you are using Node.js backend, you can check this article: https://developer.xamarin.com/guides/xamarin-forms/cloud-services/consuming/azure/ . You can use code as below:

public async Task<ObservableCollection<TodoItem>> GetTodoItemsAsync (bool syncItems = false)
{
  ...
  IEnumerable<TodoItem> items = await todoTable
              .Where (todoItem => !todoItem.Done)
              .ToEnumerableAsync ();

  return new ObservableCollection<TodoItem> (items);
}

Reference: https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter3/client/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM