/// <summary>Constructor.</summary>
        /// <param name="action">The action.</param>
        /// <param name="key">The key.</param>
        /// <param name="kind">The kind.</param>
        /// <param name="dataSource">The data source.</param>
        public DapperPlusAction(BaseDapperPlusActionSet action, string key, DapperPlusActionKind kind, object dataSource)
        {
            Key = key;
            Connection = action.Connection;
            DataSource = dataSource;
            Kind = kind;

            Execute();
        }
        /// <summary>Constructor.</summary>
        /// <param name="action">The action.</param>
        /// <param name="key">The key.</param>
        /// <param name="kind">The kind.</param>
        /// <param name="dataSource">The data source.</param>
        public DapperPlusAction(BaseDapperPlusActionSet action, string key, DapperPlusActionKind kind, object dataSource)
        {
            Key        = key;
            Connection = action.Connection;
            DataSource = dataSource;
            Kind       = kind;

            Execute();
        }
Beispiel #3
0
        /// <summary>Adds an action to the actionSet.</summary>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="childs">The childs to perform the action kind on.</param>
        public void AddAction(string mapperKey, DapperPlusActionKind actionKind, IEnumerable <object> childs)
        {
            if (childs == null)
            {
                return;
            }

            childs.Where(x => x != null)
            .ToList()
            .ForEach(x => Actions.Add(new DapperPlusAction(this, mapperKey, actionKind, x)));
        }
Beispiel #4
0
        /// <summary>Adds an action to the actionSet.</summary>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="item">The item to perform the action kind on.</param>
        public void AddAction(string mapperKey, DapperPlusActionKind actionKind, TEntity item)
        {
            // FROM: Constructor

            if (item == null)
            {
                return;
            }

            Actions.Add(new DapperPlusAction(this, mapperKey, actionKind, item));
        }
Beispiel #5
0
        /// <summary>Adds an action to the actionSet.</summary>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="item">The item to perform the action kind on.</param>
        public void AddAction(string mapperKey, DapperPlusActionKind actionKind, IEnumerable <TEntity> item)
        {
            // FROM: Constructor
            // FROM: CreateDapperAction

            if (item == null)
            {
                return;
            }

            Actions.Add(new DapperPlusAction(this, mapperKey, actionKind, item));
        }
Beispiel #6
0
        /// <summary>Constructor.</summary>
        /// <param name="connection">The connection.</param>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="items">The items.</param>
        public DapperPlusActionSet(IDbConnection connection, string mapperKey, DapperPlusActionKind actionKind, IEnumerable <TEntity> items)
        {
            // FROM: cn.BulkAction<T>(params T[] items)

            Connection = connection;

            if (items == null)
            {
                return;
            }

            Current = items.ToList();
            AddAction(mapperKey, actionKind, Current);
        }
Beispiel #7
0
        /// <summary>Adds an action to the actionSet.</summary>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="selectors">The selection of entities to perform the action kind on.</param>
        public void AddAction(string mapperKey, DapperPlusActionKind actionKind, params Func <TEntity, object>[] selectors)
        {
            // FROM: AlsoBulkAction

            if (selectors == null)
            {
                return;
            }

            if (Current != null)
            {
                var childs = selectors.Select(x => Current.Select(x).ToList()).ToList();
                AddAction(mapperKey, actionKind, childs);
            }
            else if (CurrentItem != null)
            {
                var childs = selectors.Select(x => x(CurrentItem)).ToList();
                AddAction(mapperKey, actionKind, childs);
            }
        }
Beispiel #8
0
        /// <summary>Adds an action to the actionSet.</summary>
        /// <typeparam name="T">Generic type parameter.</typeparam>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="selectors">The selection of entities to perform the action kind on.</param>
        public void AddAction <T>(string mapperKey, DapperPlusActionKind actionKind, params Func <T, object>[] selectors)
        {
            // FROM: Extensions.AlsoBulKAction

            if (selectors == null)
            {
                return;
            }

            if (Current != null)
            {
                var childs = selectors.Select(x => ((IEnumerable <T>)Current).Select(x).ToList()).ToList();
                AddAction(mapperKey, actionKind, childs);
            }
            else if (CurrentItem != null)
            {
                var childs = selectors.Select(x => ((IEnumerable <T>)CurrentItem).Select(x).ToList()).ToList();
                AddAction(mapperKey, actionKind, childs);
            }
        }
Beispiel #9
0
        /// <summary>Constructor.</summary>
        /// <param name="connection">The connection.</param>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="items">The items.</param>
        /// <param name="selectors">A variable-length parameters list containing selectors.</param>
        public DapperPlusActionSet(IDbConnection connection, string mapperKey, DapperPlusActionKind actionKind, IEnumerable <TEntity> items, params Func <TEntity, object>[] selectors)
        {
            // FROM: cn.BulkAction<T>(IEnumerable<T> items, selectors)

            Connection = connection;

            if (items == null)
            {
                return;
            }

            Current = items.ToList();
            AddAction(mapperKey, actionKind, Current);

            if (selectors == null)
            {
                return;
            }

            var childs = selectors.Select(x => Current.Select(x).ToList()).ToList();

            AddAction(mapperKey, actionKind, childs);
        }
Beispiel #10
0
        /// <summary>Constructor.</summary>
        /// <param name="connection">The connection.</param>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="item">The item.</param>
        /// <param name="selectors">A variable-length parameters list containing selectors.</param>
        public DapperPlusActionSet(IDbConnection connection, string mapperKey, DapperPlusActionKind actionKind, TEntity item, params Func <TEntity, object>[] selectors)
        {
            // FROM: cn.BulkAction<T>(T item, selectors)

            Connection = connection;

            if (item == null)
            {
                return;
            }

            CurrentItem = item;
            AddAction(mapperKey, actionKind, CurrentItem);

            if (selectors == null)
            {
                return;
            }

            var childs = selectors.Select(x => x(CurrentItem)).ToList();

            AddAction(mapperKey, actionKind, childs);
        }
Beispiel #11
0
        /// <summary>Creates dapper action.</summary>
        /// <typeparam name="T2">Generic type parameter.</typeparam>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="selectors">A variable-length parameters list containing selectors.</param>
        /// <returns>The new dapper action.</returns>
        public DapperPlusActionSet <T2> CreateDapperAction <T2>(string mapperKey, DapperPlusActionKind actionKind, params Func <TEntity, T2>[] selectors)
        {
            // FROM: ThenBulkAction

            var action = new DapperPlusActionSet <T2>(this);

            if (selectors == null)
            {
                return(action);
            }

            if (Current != null)
            {
                var childs = selectors.Select(x => Current.Select(x).ToList()).ToList();
                action.AddAction(mapperKey, actionKind, childs);
            }
            else if (CurrentItem != null)
            {
                var childs = selectors.Select(x => x(CurrentItem)).ToList();
                action.AddAction(mapperKey, actionKind, childs);
            }

            return(action);
        }
Beispiel #12
0
        /// <summary>Creates dapper action.</summary>
        /// <typeparam name="T1">Generic type parameter.</typeparam>
        /// <typeparam name="T2">Generic type parameter.</typeparam>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="selectors">A variable-length parameters list containing selectors.</param>
        /// <returns>The new dapper action.</returns>
        public DapperPlusActionSet <T2> CreateDapperAction <T1, T2>(string mapperKey, DapperPlusActionKind actionKind, params Func <T1, T2>[] selectors)
        {
            // FROM: Extensions.AlsoBulKAction

            var action = new DapperPlusActionSet <T2>(this);

            if (selectors == null)
            {
                return(action);
            }

            if (Current != null)
            {
                var childs = selectors.Select(x => ((IEnumerable <T1>)Current).Select(x).ToList()).ToList();
                AddAction(mapperKey, actionKind, childs);
            }
            else if (CurrentItem != null)
            {
                var childs = selectors.Select(x => ((IEnumerable <T1>)CurrentItem).Select(x).ToList()).ToList();
                AddAction(mapperKey, actionKind, childs);
            }

            return(action);
        }
Beispiel #13
0
        /// <summary>Constructor.</summary>
        /// <param name="oldActionSet">Set the old action belongs to.</param>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="items">The items.</param>
        /// <param name="selectors">A variable-length parameters list containing selectors.</param>
        public DapperPlusActionSet(BaseDapperPlusActionSet oldActionSet, string mapperKey, DapperPlusActionKind actionKind, IEnumerable <TEntity> items, params Func <TEntity, object>[] selectors)
        {
            // FROM: action.BulkAction<T>(IEnumerable<T> items, selectors)

            ImportConfiguration(oldActionSet);

            if (items == null)
            {
                return;
            }

            Current = items.ToList();
            AddAction(mapperKey, actionKind, Current);

            if (selectors == null)
            {
                return;
            }

            var childs = selectors.Select(x => Current.Select(x).ToList()).ToList();

            AddAction(mapperKey, actionKind, childs);
        }
Beispiel #14
0
        /// <summary>Constructor.</summary>
        /// <param name="oldActionSet">Set the old action belongs to.</param>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="item">The item.</param>
        /// <param name="selectors">A variable-length parameters list containing selectors.</param>
        public DapperPlusActionSet(BaseDapperPlusActionSet oldActionSet, string mapperKey, DapperPlusActionKind actionKind, TEntity item, params Func <TEntity, object>[] selectors)
        {
            // FROM: action.BulkAction<T>(T item, selectors)

            ImportConfiguration(oldActionSet);

            if (item == null)
            {
                return;
            }

            CurrentItem = item;
            AddAction(mapperKey, actionKind, CurrentItem);

            if (selectors == null)
            {
                return;
            }

            var childs = selectors.Select(x => x(CurrentItem)).ToList();

            AddAction(mapperKey, actionKind, childs);
        }
Beispiel #15
0
        /// <summary>Constructor.</summary>
        /// <param name="oldActionSet">Set the old action belongs to.</param>
        /// <param name="mapperKey">The mapper key.</param>
        /// <param name="actionKind">The action kind.</param>
        /// <param name="items">The items.</param>
        public DapperPlusActionSet(BaseDapperPlusActionSet oldActionSet, string mapperKey, DapperPlusActionKind actionKind, IEnumerable <TEntity> items)
        {
            // FROM: action.BulkAction<T>(params T[] items)

            ImportConfiguration(oldActionSet);

            if (items == null)
            {
                return;
            }

            Current = items.ToList();
            AddAction(mapperKey, actionKind, Current);
        }