示例#1
0
        public static bool DiffTwoList <TEntity>(EntityList <TEntity> before, EntityList <TEntity> after, out BindingCollection <TEntity> add, out BindingCollection <TEntity> upd, out BindingCollection <TEntity> del) where TEntity : EntityBase <TEntity>
        {
            add = new BindingCollection <TEntity>();
            upd = new BindingCollection <TEntity>();
            del = new BindingCollection <TEntity>();

            if ((before == null) && (after != null))
            {
                add = after.Entities;
            }
            else if ((before != null) && (after == null))
            {
                del = before.Entities;
            }
            else if ((before != null) && (after != null))
            {
                del = new BindingCollection <TEntity>(before.Entities.Except(after.Entities, new EntityIdComparer <TEntity>()).ToList <TEntity>());

                foreach (TEntity entity in after.Entities.Except(before.Entities, new EntityFullComparer <TEntity>()))
                {
                    if (entity.IsNewEntity)
                    {
                        add.Add(entity);
                    }
                    else
                    {
                        upd.Add(entity);
                    }
                }
            }
            return(add.Count == 0 && upd.Count == 0 && del.Count == 0);
        }
示例#2
0
        public static BindingCollection <TEntity> DiffTwoListAndGetUpd <TEntity>(EntityList <TEntity> before, EntityList <TEntity> after) where TEntity : EntityBase <TEntity>
        {
            BindingCollection <TEntity> result = new BindingCollection <TEntity>();

            if ((before != null) && (after != null))
            {
                foreach (TEntity entity in after.Entities.Except(before.Entities, new EntityFullComparer <TEntity>()))
                {
                    if (!entity.IsNewEntity)
                    {
                        result.Add(entity);
                    }
                }
            }
            return(result);
        }
示例#3
0
        public EntityList <T> Clone()
        {
            BindingCollection <T> bindingListView = new BindingCollection <T>();

            if (_Entitys != null)
            {
                foreach (T entity in _Entitys)
                {
                    bindingListView.Add(entity.Clone());
                }
            }
            EntityList <T> entityList = new EntityList <T>(bindingListView);

            if (Current != null)
            {
                entityList.Current = Current.Clone();
            }
            entityList.Caption = Caption;
            return(entityList);
        }