Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Sqlite Xamarin表单中连接两个表值?_C#_Sqlite_Xamarin - Fatal编程技术网

C# 如何在Sqlite Xamarin表单中连接两个表值?

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

我在我的Xamarin中从C。 我可以分别访问每个模型的值,但现在我想在SQLite中连接这两个表。 有人知道如何连接这两个模型来访问listview中的数据吗?提前谢谢。

试试这个

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连接。有关更多帮助,请参阅。