C# 如何在Sqlite Xamarin表单中连接两个表值?
我在我的Xamarin中从C。 我可以分别访问每个模型的值,但现在我想在SQLite中连接这两个表。 有人知道如何连接这两个模型来访问listview中的数据吗?提前谢谢。试试这个C# 如何在Sqlite Xamarin表单中连接两个表值?,c#,sqlite,xamarin,C#,Sqlite,Xamarin,我在我的Xamarin中从C。 我可以分别访问每个模型的值,但现在我想在SQLite中连接这两个表。 有人知道如何连接这两个模型来访问listview中的数据吗?提前谢谢。试试这个 public class MusicItems { [PrimaryKey, AutoIncrement] public int Id { get; set; } public String Name { get; set; } public String Tension { get
public class MusicItems
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public String Name { get; set; }
public String Tension { get; set; }
public String Category { get; set; }
public String Subcategory { get; set; }
public int ResId { get; set; }
public int LoopStart { get; set; }
}
public class Playlist
{
public String Name { get; set; }
public int ResId { get; set; }
public int LoopStart { get; set; }
}
public class Themes
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public String ThemeName { get; set; }
public String ThemeDesc { get; set; }
public int ThemeImg { get; set; }
public String ThemeCategory { get; set; }
public String ThemeSubcategory { get; set; }
}
public class MusicInThemes
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public int ResId { get; set; }
public int ThemeId { get; set; }
}
查询:
return database.Table<MusicItems>()
.Join(database.Table<MusicInThemes>().Where(t => t.ThemeId == ThemeID)
,m =>m.ResId
,t => t.ResId
,(m,t) => new {mym = m, myt = t })
.Select(a => new Playlist
{
Name = a.mym.Name,
ResId = a.mym.ResId,
LoopStart = 0
})
.ToList();
亲爱的杰伊·帕特尔。非常感谢您的源代码。我使用SQLite在xamarin表单中尝试了您的代码。但这表明Join不支持。您知道如何解决此问题吗?SQLite似乎不支持通过Linq连接。有关更多帮助,请参阅。