public int InsertUserTeamClassicLeague(UserTeamClassicLeagues classicleagues, SqlConnection db)
        {
            try
            {
                int rowsAffected = 0;

                using (IDataReader reader = classicleagues.GetDataReader())
                //using (var db = new SqlConnection(ConfigurationManager.ConnectionStrings["FantasyPremierLeagueUserTeam"].ConnectionString))
                {
                    //db.Open();

                    using (var bulkCopy = new SqlBulkCopy(db))
                    {
                        bulkCopy.BulkCopyTimeout      = 1000;
                        bulkCopy.BatchSize            = 500;
                        bulkCopy.DestinationTableName = "UserTeamClassicLeague";
                        bulkCopy.EnableStreaming      = true;

                        // Add your column mappings here
                        bulkCopy.ColumnMappings.Add("id", "leagueid");
                        bulkCopy.ColumnMappings.Add("entry_rank", "entry_rank");
                        bulkCopy.ColumnMappings.Add("entry_last_rank", "entry_last_rank");
                        bulkCopy.ColumnMappings.Add("entry_can_leave", "entry_can_leave");
                        bulkCopy.ColumnMappings.Add("entry_can_admin", "entry_can_admin");
                        bulkCopy.ColumnMappings.Add("entry_can_invite", "entry_can_invite");
                        bulkCopy.ColumnMappings.Add("userteamid", "userteamid");

                        //using (var dataReader = userTeamChips.ToDataReader())
                        //{
                        bulkCopy.WriteToServer(reader);
                        rowsAffected = SqlBulkCopyExtension.RowsCopiedCount(bulkCopy);
                        //}
                    }
                }

                return(rowsAffected);
            }
            catch (Exception ex)
            {
                Logger.Error("UserTeamClassicLeague Repository (insert) error: " + ex.Message);
                throw ex;
            }
        }
        public int InsertUserTeamClassicLeague(UserTeamClassicLeagues classicleagues, SqlConnection db)
        {
            int rowsAffected = 0;

            try
            {
                using (IDataReader reader = classicleagues.GetDataReader())
                {
                    using (var bulkCopy = new SqlBulkCopy(db))
                    {
                        bulkCopy.BulkCopyTimeout      = 0;
                        bulkCopy.BatchSize            = 500;
                        bulkCopy.DestinationTableName = "UserTeamClassicLeagueStaging";
                        bulkCopy.EnableStreaming      = true;

                        // Add your column mappings here
                        bulkCopy.ColumnMappings.Add("id", "leagueid");
                        bulkCopy.ColumnMappings.Add("entry_rank", "entry_rank");
                        bulkCopy.ColumnMappings.Add("entry_last_rank", "entry_last_rank");
                        bulkCopy.ColumnMappings.Add("entry_can_leave", "entry_can_leave");
                        bulkCopy.ColumnMappings.Add("entry_can_admin", "entry_can_admin");
                        bulkCopy.ColumnMappings.Add("entry_can_invite", "entry_can_invite");
                        bulkCopy.ColumnMappings.Add("userteamid", "userteamid");

                        bulkCopy.WriteToServer(reader);
                        rowsAffected = SqlBulkCopyExtension.RowsCopiedCount(bulkCopy);
                    }
                }

                return(rowsAffected);
            }
            catch (Exception ex)
            {
                Logger.Error("UserTeamClassicLeague Repository (insert) error: " + ex.Message);
                return(rowsAffected);
                //throw ex;
            }
        }