mardi 2 février 2016

UWP SQLite query result class contains another class

I know that we can do a multiple tables query, like this:

using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), App.DB_PATH))
{
    var result = db.Query<PersonWithAddress>(
        @"SELECT Person.Id, Person.Name, Person.Surname, 
            Address.Street, Address.City, Address.Country
        FROM Person INNER JOIN Address ON Person.AddressId = Address.Id;");
}

private class PersonWithAddress
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Surname { get; set; }
    public string Street { get; set; }
    public string City { get; set; }
    public string Country { get; set; }
}

*Reference from Query multiple tables SQLite Windows 10 UWP

But how about I need the result class PersonWithAddress should be :

private class PersonWithAddress
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Surname { get; set; }
    public Address mAddress { get; set}
}

private class Address {
    public string Street { get; set; }
    public string City { get; set; }
    public string Country { get; set; }
}

I'm looking for a way of DataReader, but it's seem SQLite on UWP doesn't support it.

Aucun commentaire:

Enregistrer un commentaire