简体   繁体   English

使用 PetaPoco for Exists 和 GetById 方法复合主键

[英]Composite primary keys with PetaPoco for Exists and GetById methods

I found this nice branch of PetaPoco by schootime which handles composite primary keys.我发现这个很好的 PetaPoco 分支是由 schootime 处理复合主键的。

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.现在我没有发现他在需要主键的 PetaPoco 方法版本中如何处理,复合键例如 db.Exists 和 db.GetById 方法。

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?还有一种方法是使用 Page 方法来查询 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"});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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