Skip to content

Instantly share code, notes, and snippets.

@kiyokura
Last active December 26, 2015 17:09
Show Gist options
  • Save kiyokura/7185300 to your computer and use it in GitHub Desktop.
Save kiyokura/7185300 to your computer and use it in GitHub Desktop.
RazorでのDapperサンプル(dynamicで受け取る場合)
@using Dapper;
@{
dynamic users;
using( var cn = new System.Data.SqlServerCe.SqlCeConnection("接続文字列"))
{
cn.open();
users = cn.Query("SELECT * FROM users");
}
}
<!DOCTYPE html>
<html lang="en">
<head >
<meta charset="utf-8" />
<title></ title>
</head>
<body>
<ul>
@foreach( var d in users){
<li> @d.Name : @ d.Email : @d.Age</li>
}
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment