bbrooke
bbrooke

Reputation: 2347

get value from Parse Object in Xamarin

I'm trying to get a value (firstName) from a Parse Object in Xamarin.

I've tried the following but get the error there is no definition for "Get".

Any thoughts? I appreciate the time and expertise.

My query

async void GetLegacies() {
            var query = ParseObject.GetQuery
("Legacy").WhereEqualTo("objectId", "EVw5ziGIIb");
            IEnumerable<ParseObject> results = await query.FindAsync();
            var count = await query.CountAsync();
            string firstName = results.Get<string>("firstName");
            Console.WriteLine(count);
            Console.WriteLine (firstName);
        }

Upvotes: 0

Views: 614

Answers (1)

Jason
Jason

Reputation: 89204

IEnumerable<ParseObject> results = await query.FindAsync();

results is a collection of ParseObject, not a single result. You should try

IEnumerable<ParseObject> results = await query.FindAsync();
List<ParseObject> list = results.ToList();

then

list[0].Get<string>("firstName");

to get the value for the first element in the results

Upvotes: 4

Related Questions