惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Spread Privacy
Spread Privacy
D
Docker
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
F
Full Disclosure
美团技术团队
Y
Y Combinator Blog
N
Netflix TechBlog - Medium
Security Latest
Security Latest
C
Check Point Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
罗磊的独立博客
A
Arctic Wolf
S
Schneier on Security
T
Threatpost
C
CERT Recently Published Vulnerability Notes
L
LangChain Blog
博客园 - 叶小钗
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
W
WeLiveSecurity
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
GbyAI
GbyAI
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Heimdal Security Blog
L
LINUX DO - 热门话题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
O
OpenAI News
G
GRAHAM CLULEY
M
MIT News - Artificial intelligence
S
Security @ Cisco Blogs
博客园 - 司徒正美
N
News and Events Feed by Topic
Microsoft Azure Blog
Microsoft Azure Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Schneier on Security
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
月光博客
月光博客
The Last Watchdog
The Last Watchdog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
C
Cisco Blogs
雷峰网
雷峰网

博客园 - 乔闻

关于NVIDIA-geforce 1650和tesla-P4系列显卡,共用一个驱动的办法。其他型号一样。 记一次安装nvidia-container-runtme后,作为containerd默认的runtime,k8s节点挂掉的问题。 Docker Swarm Keepalived Operator:高可用集群虚拟 IP 管理方案 scheduler报错: Failed to watch *v1beta1.PodDisruptionBudget: failed to list *v1beta1.PodDisruptionBudget, no kind "KubeSchedulerConfiguration" is registered for version "componentconfig/v1alpha1" 介绍一个prometheus监控数据生成工具 EOS:dfuse stream 保证不会错过一个心跳 ubuntu18.04安装时ACPI error 无法进入系统的问题 Supervisor-类unix系统下的进程控制工具 windows10 自带的OpenSSH Client(Beta) windows10 易升 下载失败 解决方法 Visual Studio for Mac 安装时无法连接到网络等问题 用VsCode编辑TypeScript OWIN是什么? 实例字段与静态字段区别 ref - 按引用传递参数 TweenMax 前台脚本库 如何使用CSS Sprites技术进行图片合并 QQ群开放接口 使用 Hexo 生成一套静态博客网页
Dapper
乔闻 · 2015-12-11 · via 博客园 - 乔闻
本文内容摘自dapper官网
动态类型
public static IEnumerable<dynamic> Query (this IDbConnection cnn, string sql, object param = null, SqlTransaction transaction = null, bool buffered = true)

This method will execute SQL and return a dynamic list.

Example usage:

var rows = connection.Query("select 1 A, 2 B union all select 3, 4");

((int)rows[0].A)
   .IsEqualTo(1);

((int)rows[0].B)
   .IsEqualTo(2);

((int)rows[1].A)
   .IsEqualTo(3);

((int)rows[1].B)
    .IsEqualTo(4);
多次执行语句

Execute a Command multiple times

The same signature also allows you to conveniently and efficiently execute a command multiple times (for example to bulk-load data)

Example usage:

connection.Execute(@"insert MyTable(colA, colB) values (@a, @b)",
    new[] { new { a=1, b=1 }, new { a=2, b=2 }, new { a=3, b=3 } }
  ).IsEqualTo(3); // 3 rows inserted: "1,1", "2,2" and "3,3"

This works for any parameter that implements IEnumerable for some T.

 集合 支持

List Support

Dapper allow you to pass in IEnumerable and will automatically parameterize your query.

For example:

connection.Query<int>("select * from (select 1 as Id union all select 2 union all select 3) as X where Id in @Ids", new { Ids = new int[] { 1, 2, 3 });

Will be translated to:

select * from (select 1 as Id union all select 2 union all select 3) as X where Id in (@Ids1, @Ids2, @Ids3)" // @Ids1 = 1 , @Ids2 = 2 , @Ids2 = 3
一次执行多条语句

Multiple Results

Dapper allows you to process multiple result grids in a single query.

Example:

var sql = 
@"
select * from Customers where CustomerId = @id
select * from Orders where CustomerId = @id
select * from Returns where CustomerId = @id";

using (var multi = connection.QueryMultiple(sql, new {id=selectedId}))
{
   var customer = multi.Read<Customer>().Single();
   var orders = multi.Read<Order>().ToList();
   var returns = multi.Read<Return>().ToList();
   ...
} 

Stored Procedures 存储过程