PetaPoco, specifically schotime's, 'no mapping exists to a known provider type'

StackOverflow https://stackoverflow.com/questions/9542289

  •  04-12-2019
  •  | 
  •  

Question

I'm using a fairly old version of PetaPoco from https://github.com/schotime/PetaPoco - it's basically vanilla with support for multi-primary key columns. Decided it was time to upgrade. Grabbed the newest version from the schotime link just mentioned, dumped it into my project, and immediately had failures with code structured like so:

    class Program
{
    public class AggregateObject
    {
        public int aoId { get; set; }

        [PetaPoco.Ignore]
        public Object1 o1 { get; set; }

        [PetaPoco.Ignore]
        public Object2 o2 { get; set; }
    }

    public class Object1
    {
        public int o1Id { get; set; }
    }

    public class Object2
    {
        public int o2Id { get; set; }
    }

    static void Main(string[] args)
    {
        var db = new Database("test");

        var test = db.Fetch<AggregateObject, Object1, Object2, AggregateObject>(
            (ao, o1, o2) =>
                {
                    ao.o1 = o1;
                    ao.o2 = o2;
                    return ao;
                },
            "SELECT 1 AS aoId, 2 AS o1Id, 3 AS o2Id WHERE 1 <> @start AND 2 <> @end",
            new
                {
                    start = 5,
                    end = 5
                });
    }
}

Which throws this error

No mapping exists from object type <>f__AnonymousType0`2[[System.Int32, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],
System.Data.SqlClient.SqlParameter, System.Data, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]] to a known managed provider native type.

for each parameter I'm attempting to pass in (in this case, System.Int32, System.Int32).

Did something change in the way parameters are passed in via this method? Very confused at the error.

Was it helpful?

Solution

This has been fixed in 4.0.3.12 available to download here: https://github.com/schotime/PetaPoco/downloads

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top