Example #1
0
        public IDbConnector Execute(
            ISqlCommand sqlCommand
            )
        {
            this.ResetStateProperties();
            this.Close();

            using (var Connection = this.OpenSqlConnection())
            {
                using (var cmd = sqlCommand.GenerateSqlCommandInstance <System.Data.SqlClient.SqlCommand>())
                {
                    cmd.Connection        = Connection;
                    this.AffectedRowCount = cmd.ExecuteNonQuery();
                }
                this.GetAndAssignLatestID(Connection);
                Connection.Close();
            }

            return(this);
        }
Example #2
0
        public IDbConnector Read(
            ISqlCommand sqlCommand,
            out IDbTable dbTable
            )
        {
            this.ResetStateProperties();
            this.Connection = this.OpenSqlConnection();
            using (var cmd = sqlCommand.GenerateSqlCommandInstance <System.Data.SqlClient.SqlCommand>())
            {
                cmd.Connection      = this.Connection;
                this.DataAdapter    = this.GetDataAdapter(cmd);
                this.CommandBuilder = this.GetCommandBuilder(this.DataAdapter);

                var DataTable = new System.Data.DataTable();
                this.DataAdapter.Fill(DataTable);
                dbTable = new DbTable(DataTable);
            }
            this.Connection.Close();

            return(this);
        }