1

I've seen that if i want to make a linq query using sqlite-net if i do:

var query = conn.Table<TableName1>().Where(x => x.Field=="Val1");

i can apply a where to the select; is it possible to do something similar for more than 1 table, applying a join between TableName1 and TableName2 ? If it is possible, which is the right syntax for the linq query?

4

1 回答 1

1

使用查询:

var query = string.Format (
                @"
                SELECT artist.Name as ArtistName, album.Id as AlbumId, album.Title as AlbumTitle,
                    track.Id as TrackId, track.Name as TrackName, track.Number as TrackNumber
                FROM Track track
                LEFT OUTER JOIN Album album
                ON track.AlbumId = album.Id
                LEFT OUTER JOIN Artist artist
                ON album.ArtistId = artist.Id
                WHERE track.Id = '{0}'
                "
                ,trackId.ToString ());

            var trackViewModels = await QueryAsync<TrackViewModel> (query);
            return trackViewModels.FirstOrDefault();
于 2012-11-09T05:53:54.277 回答