0

I found this nice branch of PetaPoco by schootime which handles composite primary keys.

Now what I didn't find is how he handled in his version of PetaPoco methods which require a primary key, with composite keys like for example db.Exists and db.GetById methods.

With a single primary key you just pass the value but how to threat those methods with multiple keys? Should I pass a dictionary of string/object instead with the primary column name and the value?

If you are using this branch, any hint would be appreciated.

Also is there a way of using the Page method to query results for all the results with PetaPoco? Meaning passing no pages/items per page.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Manight
  • 500
  • 5
  • 26

1 Answers1

1

These methods take an object, which can be an anonymous object. eg.

db.SingleById<User>(new{ Name="John", Email="John@smith.com"});
Schotime
  • 15,707
  • 10
  • 46
  • 75
  • Thanks Schotime this is wonderful... will Exists, IsNew, Save methods work in the same way? About paging it was not related to this issue I was just wondering if it's possible to use the db.Page() method to request ALL results (without paging) – Manight Jan 13 '13 at 20:59
  • 1
    The Exists works but the IsNew does not yet. You could always pass the page number as 1 and make the page size a really big number, but I'm not sure why you would do this. Just use `Fetch<>` if you want all the results. – Schotime Jan 14 '13 at 23:14
  • Yes schotime agress is a nonsense. Thank you for your support so far. Too bad petapoco development seems struck it's really wonderful bit of code – Manight Jan 15 '13 at 13:59