检查记录是否存在于Dapper ORM中 [英] Check if record exists with Dapper ORM
本文介绍了检查记录是否存在于Dapper ORM中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Dapper ORM检查记录是否存在的最简单方法是什么?
What is the simplest way to check if record exists using the Dapper ORM?
我真的需要为只想检查的查询定义POCO对象吗?
Do I really need to define POCO objects for a query where I only want to check if a record exists?
推荐答案
int id = ...
var exists = conn.ExecuteScalar<bool>("select count(1) from Table where Id=@id", new {id});
应该工作...
这篇关于检查记录是否存在于Dapper ORM中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文