Peta Poco where子句 [英] Peta Poco where clause

查看:76
本文介绍了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子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆