samedi 28 novembre 2015

SQLite.Net - Don't know about System.Collections.Generic.List fault - Xamarin Android

I'm searching for hours now on this problem and it is very logic he does not know Ability (because Ability is not made yet), But do you guys know how to fix this?

This is the fault message I get: Don't know about System.Collections.Generic.List`1[pokedex.Ability]

My classes: -Ability

[Table ("Ability")]
public class Ability
{
    [PrimaryKey,AutoIncrement]
    public int Id { get; set; }

    public String name{ get; set; }

    [ManyToMany (typeof(PokemonAbility), "PokemonId", "Pokmemons",
        CascadeOperations = CascadeOperation.All)]
    private List<Pokemon> pokemon{ get; set; }

    public Ability (String n)
    {
        name = n;
    }
}

-Pokemon:

[Table ("Pokemon")]
public class Pokemon
{
    [PrimaryKey,AutoIncrement]
    public int DBId { get; set; }

    public int id { get; set; }

    public String name{ get; set; }

    public String type{ get; set; }

    public String image{ get; set; }

    public int Attack{ get; set; }

    public int speed{ get; set; }

    public int sp_atk{ get; set; }

    public int sp_def{ get; set; }

    public int defense{ get; set; }

    public string height{ get; set; }

    public String weight{ get; set; }

    public int hp{ get; set; }

    public String description{ get; set; }

    [ManyToMany (typeof(PokemonAbility), "AbilityId", "Abilities",
        CascadeOperations = CascadeOperation.All)]
    public List<Ability> abilities{ get; set; }

    methods and consttuctor...


}

PokemonAbility:

[Table ("PokemonAbility")]
public class PokemonAbility
{
    public PokemonAbility ()
    {
    }

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

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

My DB:

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
    }

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire