This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SQL Server CEで試した例。SQL Serverの場合はプロバイダ名をSystem.Data.SqlClientに。 | |
var factory = System.Data.Common.DbProviderFactories.GetFactory("System.Data.SqlServerCe.4.0"); | |
using (var cn = factory.CreateConnection()) | |
{ | |
cn.ConnectionString = "接続文字列"; | |
cn.Open(); | |
var ret = cn.Query("SELECT * FROM users WHERE Age > @Age", new { Age = 20 }); | |
foreach (var r in ret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Glimpse.Ado OKのパターン | |
// DbFactoryからConnectionをCreateするようにする | |
var factory = System.Data.Common.DbProviderFactories.GetFactory("Oracle.DataAccess.Client"); | |
using (var cn = factory.CreateConnection()) | |
{ | |
cn.ConnectionString = "接続文字列"; | |
cn.Open(); | |
var cmd = cn.CreateCommand(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Glimpse.Ado NGのパターン | |
using (System.Data.Common.DbConnection cnOrg = new Oracle.DataAccess.Client.OracleConnection("接続文字列")) | |
{ | |
using (var cn = new Glimpse.Ado.AlternateType.GlimpseDbConnection(cnOrg)) | |
{ | |
cn.Open(); | |
var cmd = cn.CreateCommand(); | |
cmd.CommandText = "select * from hoge"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 接続文字列。環境に合わせてください。 | |
var connectionString = "Data Source=\"c:\\users\\kiyokura\\documents\\visual studio 2012\\Projects\\WebApplication12\\WebApplication12\\App_Data\\Database1.sdf\"" ; | |
// SQL Server CEで試した例。SQL Serverの場合はSystem.Data.SqlClient.SqlConnectionを使ってください | |
using ( var cnOrg = new System.Data.SqlServerCe.SqlCeConnection (connectionString)) | |
{ | |
using ( var cn = new Glimpse.Ado.AlternateType.GlimpseDbConnection (cnOrg)) | |
{ | |
cn.Open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 接続文字列。環境に合わせてください。 | |
var connectionString = "Data Source=\"c:\\users\\kiyokura\\documents\\visual studio 2012\\Projects\\WebApplication12\\WebApplication12\\App_Data\\Database1.sdf\"" ; | |
// SQL Server CEで試した例。SQL Serverの場合はSystem.Data.SqlClient.SqlConnectionを使ってください | |
using ( var cn = new System.Data.SqlServerCe.SqlCeConnection (connectionString)) | |
{ | |
cn.Open(); | |
var cmd = cn.CreateCommand(); | |
cmd.CommandText = "SELECT * FROM users WHERE Age > @Age"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<runtimePolicies> | |
<ignoredTypes> | |
<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet"/> | |
</ignoredTypes> | |
</runtimePolicies> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Page_PreInit(object sender, EventArgs e) | |
{ | |
System.Diagnostics.Debug.Assert(false, "Debug.Assertしてみた(Assert失敗)"); | |
System.Diagnostics.Debug.Write("Debug.Writeしてみた"); | |
System.Diagnostics.Trace.TraceInformation("System.Diagnostics.Trace.TraceInformationしてみた"); | |
System.Diagnostics.Trace.TraceWarning("System.Diagnostics.Trace.TraceWarningしてみた"); | |
System.Diagnostics.Trace.TraceError("System.Diagnostics.Trace.TraceErrorしてみた"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using Dapper; | |
@{ | |
using( var cn = new System.Data.SqlServerCe.SqlCeConnection("接続文字列")) | |
{ | |
cn.Open(); | |
using(var tr = cn.BeginTransaction()){ | |
try | |
{ | |
// Executeメソッドの第三引数にトランザクションオブジェクトを渡す | |
cn.Execute("UPDATE users SET Age = @Age Where ID = @ID", new {Age = 25 , ID = 1} , tr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using Dapper; | |
@{ | |
IEnumerable< UserEntity> users; | |
using( var cn = new System.Data.SqlServerCe.SqlCeConnection("接続文字列")) | |
{ | |
cn.open(); | |
users = cn.Query<UserEntity>( "SELECT * FROM users"); | |
} | |
} | |
<!DOCTYPE html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using Dapper; |