The problem of inserting petapoco

I have a class defined like this:

public class Location
{
    public Location()
    {
        Meetings = new List<Meeting>();
    }

    public virtual int ID { get; private set; }
    public virtual string Name { get; set; }

    public virtual ICollection<Meeting> Meetings { get; set; }

}

And the database table for this is simply "locations" with the identifier and the Name property.

Some other table “meetings” have a foreign key to this table. And that goes beyond what I'm trying to work with in this example, but I think this leads to PetaPoco failing ...

I am trying to use PetaPoco to insert a new location into a database as follows:

    public int AddLocation(string name)
    {
        var newLocation = new Location{Name = name};
        var db = new PetaPoco.Database(_connectionString);
        db.Insert("locations", "ID", newLocation);
        return newLocation.ID;
    }

And it causes an error, for example:

{"There is no object type mapping System.Collections.Generic.List`1 [[NHRepoTemplate.sampleUsage.sampleModel.Meeting, NHRepoTemplate, Version = 1.0.0.0, Culture = Neutral, PublicKeyToken = null]] to a known managed type provider." }

, , PetaPoco , ... "" , ?

+5
2

Meetings:

[PetaPoco.Ignore]
+6

[ExplicitColumns] petapoco, , [Column],

0

All Articles