0

I have a Xamarin App that I primarily write in C#. In de app I've got a SQlite database in which I store an Int (ID), a string and two doubles.

I need the string and two doubles in a Tuple list.

Altohugh I figured out how to put the information in a normal list, I don't know how to put it in a Tuple.

How I populated the normal list:

protected override async void OnAppearing()
    {
        devListLoc.ItemsSource = await App.Database.GetAllLocations();
    }

How I populate Tuple without SQlite:

List list = new List<Tuple<string, double, double>>
        {
            new Tuple<string, double, double>("tesst1", 57.434180, 7.236162),
            new Tuple<string, double, double>("test2", 58.435602, 8.234298),
        };

So I want to populate the Tuple list in kindof the same way, but I can't figure out how, nor can I find the answer somewhere else.

Cheers!

Edit: The GetAllLocations task:

public Task<List<BarLoc>> GetAllLocations()
    {
        return database.QueryAsync<BarLoc>("SELECT * FROM [BarLoc]");
    }

1 Answer 1

1
using System.Linq;

var locations = await App.Database.GetAllLocations();

var tuples = (from l in locations 
              select new Tuple<string,double,double>(l.Name, l.Lat, l.Long)).ToList(); 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but it gets the following error: Could not find an implementation of the query pattern for source type 'Task<List<BarLoc>>'. 'Select' not found I added the GetAllLocations Task code in the question because thats what it's talking about. (And I forgot adding it, whoops)
you need to await it - I left that out of my original response

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.