This file contains hidden or 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
cn.Open(); | |
var param = new | |
{ | |
// IN句に並べたい値をリストとして積んでやる | |
AgeList = new List<int>() { 20, 38 } | |
}; | |
var ret = cn.Query<UserEntity>("SELECT * FROM Users WHERE Age IN @AgeList ORDER BY ID", param).ToList(); |
This file contains hidden or 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
void SomeMethod(Hoge filler) | |
{ | |
using(var cn = new Oracle.DataAccess.Clinet.OracleConnection("接続文字列")){ | |
cn.Open(); | |
// -- NG NG NG NG NG NG -- | |
// NUMBER型のカラムis_fooに与えるパラメータIsFooをboolで与えると例外 | |
var r1 = cn.Query("SELECT * FROM Hoge WHERE is_foo = :IsFoo " , filler ); | |
// -- NG NG NG NG NG NG -- | |
This file contains hidden or 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
void SomeMethod() | |
{ | |
using(var cn = new Oracle.DataAccess.Clinet.OracleConnection("接続文字列")){ | |
cn.Open(); | |
// -1 を 暗黙でtureとしてbool型にマッピングしてくれる。 | |
var r1 = cn.Query<Hoge>("SELECT -1 as IsFoo FROM DUAL"); | |
// 0 は false | |
var r2 = cn.Query<Hoge>("SELECT 0 as IsFoo FROM DUAL"); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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してみた"); | |
} |