Peta Poco where子句

编程入门 行业动态 更新时间:2024-10-24 12:28:07
本文介绍了Peta Poco where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正试图在petapoco中做到这一点

I am trying to do this in petapoco

var people = db.Query<Person>("SELECT * FROM people").Where(p => p.FirstName.Equals("George") && p.LastName.Equals("Clooney")).ToList();

问题在于它从数据库中获取了整个记录集,然后对其进行过滤.我尝试使用Fetch而不是查询,结果相同.

the problem is that it gets the entire set of records from the database and then performs the filtration on it. I tried Fetch instead of query, same result.

如何编写查询,以便它发送查询以从数据库中获取过滤后的结果,而不是在Web服务器上进行过滤?

How do I write the query so that it sends the query to get the filtered results from the database, instead of doing the filtering at the webserver?

推荐答案

var people = db.Fetch<Person>("where firstname = @0 and lastname = @1", "George", "Clooney");

或使用NPoco(基于PetaPoco)也可以实现

or using NPoco (which which is based off PetaPoco) this is also possible

var people = db.FetchWhere<Person>(x=>x.FirstName == "George" && x.LastName == "Clooney");

更多推荐

Peta Poco where子句

本文发布于:2023-07-27 11:53:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222311.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子句   Peta   Poco

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!