0

My poco object looks like the following:

   public class Poco
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Url { get; set; }
        [Ignore]
        public string IgnoreMe { get; set; }
        [Ignore]
        public List<Page> Pages { get; set; }
    }

When I run:

db.Insert("Poco", Poco);

It throws an exception because it still includes IgnoreMe and the Pages properties in the Insert statement. I also tried setting [ExplicitColumns], and it still tries to include everything.

I created a new web api project and put in the exact same code and Peta Poco version and it ignored the columns. I am using VS 2017 and the Web Api Template with the full .NET Framework (not core). It worked with the new project. The other project is not old either, but is there something that could prevent PetaPoco Ignore from not working

I found out if I have the PetaPoco nuget package installed in two different projects and one project references the other, this is what breaks it. The problem is I need PetaPoco to be installed in both because I need the attributes for one project and I need the query stuff for the other

xaisoft
  • 3,343
  • 8
  • 44
  • 72

1 Answers1

0

Very odd. Are you sure that the Ignore attribute you're using is the PetaPoco one and not one from a different library??? Hover the mouse over the attribute and check the class is PetaPoco.IgnoreAttribute.

You could also try using the [ResultColumn] attribute (although Ignore should be working).

Edit - Another possible answer

Just seen your edit saying that the problem occurs when the PetaPoco nuget package is installed into two separate projects. Are you using the nuget package that puts a PetaPoco.cs class file in a Models folder of each project??

If you are then each of your projects is going to have it's own separate set of PetaPoco classes and this may be what's causing the issue. You could try uninstalling PetaPoco from the two projects, create a third project installing the PetaPoco nuget project to that and then reference this project in the other two.

Jason Hunt
  • 354
  • 2
  • 5