简体   繁体   中英

Composite primary keys with PetaPoco for Exists and GetById methods

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.

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

db.SingleById<User>(new{ Name="John", Email="John@smith.com"});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM