public void BeginGetTableTest() { DataTable dt; DataTable dt1; DataSet ds; dt = new DataTable(); dt.Columns.Add("SysId"); dt.Columns.Add("Name"); dt.Columns.Add("Mark"); CodeTimer.Time("ss", 1, () => { using (DbExecutor db = new DbExecutor(new SqlConnection(connString))) { dt = db.BeginGetTable(SqlClientFactory.Instance, "select * from MyTest"); //dt.Rows[0]["Name"] = "ji1111n"; DataRow dr = dt.NewRow(); dt.Rows.Add(dr); dr["Name"] = "jiguixin4444"; dr["Mark"] = "Makr4444"; //db.CommitData(dt, "MyTest"); db.EndCommitTable(dt); Console.WriteLine(dr["SysId"].ToString()); Console.WriteLine(dr["Name"]); var mydt = db.BeginGetTable(SqlClientFactory.Instance, "select * from MyTest where SysId=@SysId", new { SysId = 100054 } ); mydt.Rows[0]["Name"] = "JIm"; db.EndCommitTable(mydt); } }); }
public void BeginGetTableTranTest() { DataTable dt; DataTable dt1; DataSet ds; dt = new DataTable(); dt.Columns.Add("SysId"); dt.Columns.Add("Name"); dt.Columns.Add("Mark"); CodeTimer.Time("ss", 1, () => { using (DbExecutor db = new DbExecutor(new SqlConnection(connString),IsolationLevel.ReadCommitted)) { dt = db.BeginGetTable(SqlClientFactory.Instance, "select * from MyTest"); dt.Rows[0]["Name"] = "Test" + DateTime.Now; dt.Rows[dt.Rows.Count - 1].Delete(); DataRow dr = dt.NewRow(); dt.Rows.Add(dr); dr["Name"] = "jiguixinss"+DateTime.Now; dr["Mark"] = "Makr4444"; db.EndCommitTable(dt); Console.WriteLine(dr["SysId"].ToString()); Console.WriteLine(dr["Name"]); //var mydt = db.BeginGetTable(SqlClientFactory.Instance, // "select * from MyTest where SysId=@SysId", // new // { // SysId // = // 100054 // } // ); //mydt.Rows[0]["Name"] = "JIm"+DateTime.Now; //db.EndCommitTable(mydt); db.TransactionComplete(); } }); }