예제 #1
0
 public static ActionTask AsyncExecuteReader(this MySqlCommand cmd, TaskChain ch, Action <MySqlDataReader> readerReady)
 {
     return(ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         cmd.InternalExecuteReader(subtable =>
         {
             //this method is respond for call next ***
             ch.AutoCallNext = true;
             //**
             //fetch data
             while (subtable.InternalRead())
             {
                 readerReady(subtable);
                 if (subtable.StopReadingNextRow)
                 {
                     break;
                 }
             }
             //
             subtable.Close(() => { });
             //
             if (ch.AutoCallNext)
             {
                 ch.Next();
             }
         });
     }));
 }
예제 #2
0
 public static ActionTask AsyncClose(this MySqlConnection conn, TaskChain ch)
 {
     return(ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         conn.Close(ch.Next);
     }));
     //not use autocall next task, let the connection call it when ready ***
 }
예제 #3
0
 public static ActionTask AsyncExecuteNonQuery(this MySqlCommand cmd, TaskChain ch)
 {
     return(ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         cmd.ExecuteNonQuery(ch.Next);
     }));
     //not use autocall next task, let the cmd call it when ready ***
 }
예제 #4
0
 public static ActionTask AsyncClose(this MySqlDataReader reader, TaskChain ch)
 {
     return(ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         reader.Close(ch.Next);
     }));
     //not use autocall next task, let the reader call it when ready ***
 }
        public static ActionTask AsyncExecuteNonQuery(this MySqlCommand cmd, TaskChain ch)
        {
            return ch.AddTask(() =>
            {
                ch.AutoCallNext = false;
                cmd.ExecuteNonQuery(ch.Next);

            });
            //not use autocall next task, let the cmd call it when ready ***
        }
        public static ActionTask AsyncClose(this MySqlConnection conn, TaskChain ch)
        {
            return ch.AddTask(() =>
            {
                ch.AutoCallNext = false;
                conn.Close(ch.Next);

            });
            //not use autocall next task, let the connection call it when ready ***
        }
예제 #7
0
 public static ActionTask AsyncOpen(this MySqlConnection conn, TaskChain ch)
 {
     return(ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         //open connection async
         //after finish then call next task in task chain
         conn.InternalOpen(ch.Next);
     }));
     //not use autocall next task, let the connection call it when ready ***
 }
 public static ActionTask AsyncOpen(this MySqlConnection conn, TaskChain ch)
 {
     return ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         //open connection async
         //after finish then call next task in task chain
         conn.InternalOpen(ch.Next);
     });
     //not use autocall next task, let the connection call it when ready ***
 }
예제 #9
0
 public static ActionTask AsyncExecuteScalar <T>(this MySqlCommand cmd, TaskChain ch, Action <T> resultReady)
 {
     return(ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         cmd.ExecuteScalar <T>(result =>
         {
             ch.AutoCallNext = true;
             resultReady(result);
             if (ch.AutoCallNext)
             {
                 ch.Next();
             }
         });
     }));
     //not use autocall next task, let the cmd call it when ready ***
 }
예제 #10
0
 public static ActionTask AsyncExecuteSubTableReader(this MySqlCommand cmd, TaskChain ch, Action <MySqlDataReader> readerReady)
 {
     return(ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         cmd.InternalExecuteSubTableReader(subtable =>
         {
             //this method is respond for call next ***
             ch.AutoCallNext = true;
             readerReady(subtable);
             if (ch.AutoCallNext)
             {
                 ch.Next();
             }
         });
     }));
     //not use autocall next task, let the cmd call it when ready ***
 }
 public static ActionTask AsyncExecuteSubTableReader(this MySqlCommand cmd, TaskChain ch, Action<MySqlDataReader> readerReady)
 {
     return ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         cmd.ExecuteSubTableReader(subtable =>
         {
             //this method is respond for call next ***
             ch.AutoCallNext = true;
             readerReady(subtable);
             if (ch.AutoCallNext)
             {
                 ch.Next();
             }
         });
     });
     //not use autocall next task, let the cmd call it when ready ***
 }
        static void SelectDataBack(MySqlConnection conn, TaskChain tc)
        {


            string sql = "select * from test001";
            var cmd = new MySqlCommand(sql, conn);

            tc.AddTask(() =>
            {
#if DEBUG
                conn.dbugPleaseBreak = true;
#endif
            });

            //this is very basic mapper***
            var mapper = Mapper.Map((SimpleInfo t, int col_id, string col2, string col3) =>
            {
                t.col1 = col_id;
                t.col2 = col2;
            });

            cmd.AsyncExecuteSubTableReader(tc, reader =>
            {

                mapper.DataReader = reader;
                while (reader.Read())
                {
                    var simpleInfo = mapper.Map(new SimpleInfo());
                }

                ////simple map query result to member of the target object  
                ////we create simpleinfo and use mapper to map field 


                tc.AutoCallNext = reader.CurrentSubTable.IsLastTable;

            });
        }
        static void InsertData(MySqlConnection conn, TaskChain tc)
        {
            string sql = "insert into test001(col1,col2,col3,col4) values(10,'AA','123456789','0001-01-01')";
            var cmd = new MySqlCommand(sql, conn);
            cmd.AsyncExecuteNonQuery(tc);
            tc.AddTask(() =>
            {
                var lastInsertId = cmd.LastInsertedId;
            });

        }
 public static ActionTask AsyncClose(this MySqlDataReader reader, TaskChain ch)
 {
     return ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         reader.Close(ch.Next);
     });
     //not use autocall next task, let the reader call it when ready ***
 }
 public static ActionTask AsyncExecuteScalar(this MySqlCommand cmd, TaskChain ch, Action<object> resultReady)
 {
     return ch.AddTask(() =>
     {
         ch.AutoCallNext = false;
         cmd.ExecuteScalar(result =>
         {
             ch.AutoCallNext = true;
             resultReady(result);
             if (ch.AutoCallNext)
             {
                 ch.Next();
             }
         });
     });
     //not use autocall next task, let the cmd call it when ready ***
 }