C# Net-Don';我不知道System.Collections.Generic.List故障-Xamarin Android

C# Net-Don';我不知道System.Collections.Generic.List故障-Xamarin Android,c#,android,sqlite,orm,xamarin,C#,Android,Sqlite,Orm,Xamarin,我已经在这个问题上搜索了好几个小时了,很有逻辑,他不知道这个能力(因为这个能力还没有形成),但你们知道如何解决这个问题吗 这是我得到的故障信息: 不了解System.Collections.Generic.List`1[pokedex.Ability] 我的班级: -才能 我的数据库: public class NormalDatabase { private String pathToDatabase; public NormalDatabase () {

我已经在这个问题上搜索了好几个小时了,很有逻辑,他不知道这个能力(因为这个能力还没有形成),但你们知道如何解决这个问题吗

这是我得到的故障信息: 不了解System.Collections.Generic.List`1[pokedex.Ability]

我的班级: -才能

我的数据库:

public class NormalDatabase
{

    private String pathToDatabase;

    public NormalDatabase ()
    {
        var documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
        pathToDatabase = Path.Combine (documents, "db_adonet.db");
    }

    //aanmaken van de tabel => met objecten pokemon
    public void CreateDatabase ()
    {
        using (var conn = new SQLite.SQLiteConnection (pathToDatabase)) {
            conn.DropTable<Pokemon> ();
            conn.DropTable<Ability> ();
            conn.DropTable<PokemonAbility> ();
            conn.CreateTable<Pokemon> ();  //here he fails ofc
            conn.CreateTable<Ability> ();
            conn.CreateTable<PokemonAbility> ();
        }
    other methods
    }
公共类数据库
{
私有字符串路径数据库;
公共数据库()
{
var documents=Environment.GetFolderPath(Environment.SpecialFolder.Personal);
pathToDatabase=Path.Combine(文档,“db_adonet.db”);
}
//aanmaken van de tabel=>met objecten口袋妖怪
公共数据库()
{
使用(var conn=new SQLite.SQLiteConnection(pathToDatabase)){
conn.DropTable();
conn.DropTable();
conn.DropTable();
conn.CreateTable();//这里他失败了
conn.CreateTable();
conn.CreateTable();
}
其他方法
}

提前感谢!

请参考异常类型:它属于不支持异常


请参见此处:

我认为这是因为您的能力表定义中的键入错误。在许多属性中,您应该使用“口袋妖怪”而不是“口袋备忘录”。此外,您的表的另一个属性是“能力”,而不是“能力”。如果没有帮助,请更新帖子…

列表对于SQLite数据库值来说不是有效的类型

请检查以下有效类型:


    public static string SqlType (TableMapping.Column p, bool storeDateTimeAsTicks)
    {
        var clrType = p.ColumnType;
        if (clrType == typeof(Boolean) || clrType == typeof(Byte) || clrType == typeof(UInt16) || clrType == typeof(SByte) || clrType == typeof(Int16) || clrType == typeof(Int32)) {
            return "integer";
        } else if (clrType == typeof(UInt32) || clrType == typeof(Int64)) {
            return "bigint";
        } else if (clrType == typeof(Single) || clrType == typeof(Double) || clrType == typeof(Decimal)) {
            return "float";
        } else if (clrType == typeof(String)) {
            int len = p.MaxStringLength;
            return "varchar(" + len + ")";
        } else if (clrType == typeof(DateTime)) {
            return storeDateTimeAsTicks ? "bigint" : "datetime";
            #if !NETFX_CORE
        } else if (clrType.IsEnum) {
            #else
        } else if (clrType.GetTypeInfo().IsEnum) {
            #endif
            return "integer";
        } else if (clrType == typeof(byte[])) {
            return "blob";
        } else if (clrType == typeof(Guid)) {
            return "varchar(36)";
        } else {
            throw new NotSupportedException ("Don't know about " + clrType); //Here the exception is thrown
        }
    }


我认为OP确实根据你所指的文章中的答案建立了他的关系(当然,我的意思是,第二个答案建议使用扩展-正是OP所使用的).所以我不明白为什么你提供的链接回答了这个问题。我更新了代码,但它还不起作用。同样的错误。谢谢回答!你在manytomany属性中仍然有“AbilityId”,但列的名称是“Id”。Pokemon表也是如此。我认为您不需要在属性中指定列-而且,如果以后您想更改列的名称,它将无法正确重构。为什么不直接编写[ManyToMany(typeof(PokeMobility))]?我在没有这些规范的情况下尝试过它([ManyToMany(typeof(PokeMobility))),但它给出了相同的错误,而且如果我只是将Id en DBId放入,它不知道列表。好的,现在看起来它没有加载sqlite扩展。如何添加它?是否使用nuget?尝试从项目中删除扩展和sqlite net包,然后添加扩展nuget。有关详细信息,请参阅此链接:
[Table ("PokemonAbility")]
public class PokemonAbility
{
    public PokemonAbility ()
    {
    }

    [ForeignKey (typeof(Pokemon))]
    public int PokemonId { get; set; }

    [ForeignKey (typeof(Ability))]
    public int AbilityId { get; set; }
}
public class NormalDatabase
{

    private String pathToDatabase;

    public NormalDatabase ()
    {
        var documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
        pathToDatabase = Path.Combine (documents, "db_adonet.db");
    }

    //aanmaken van de tabel => met objecten pokemon
    public void CreateDatabase ()
    {
        using (var conn = new SQLite.SQLiteConnection (pathToDatabase)) {
            conn.DropTable<Pokemon> ();
            conn.DropTable<Ability> ();
            conn.DropTable<PokemonAbility> ();
            conn.CreateTable<Pokemon> ();  //here he fails ofc
            conn.CreateTable<Ability> ();
            conn.CreateTable<PokemonAbility> ();
        }
    other methods
    }

    public static string SqlType (TableMapping.Column p, bool storeDateTimeAsTicks)
    {
        var clrType = p.ColumnType;
        if (clrType == typeof(Boolean) || clrType == typeof(Byte) || clrType == typeof(UInt16) || clrType == typeof(SByte) || clrType == typeof(Int16) || clrType == typeof(Int32)) {
            return "integer";
        } else if (clrType == typeof(UInt32) || clrType == typeof(Int64)) {
            return "bigint";
        } else if (clrType == typeof(Single) || clrType == typeof(Double) || clrType == typeof(Decimal)) {
            return "float";
        } else if (clrType == typeof(String)) {
            int len = p.MaxStringLength;
            return "varchar(" + len + ")";
        } else if (clrType == typeof(DateTime)) {
            return storeDateTimeAsTicks ? "bigint" : "datetime";
            #if !NETFX_CORE
        } else if (clrType.IsEnum) {
            #else
        } else if (clrType.GetTypeInfo().IsEnum) {
            #endif
            return "integer";
        } else if (clrType == typeof(byte[])) {
            return "blob";
        } else if (clrType == typeof(Guid)) {
            return "varchar(36)";
        } else {
            throw new NotSupportedException ("Don't know about " + clrType); //Here the exception is thrown
        }
    }