Пример #1
0
        private async Task <List <ObjectBinding> > AutoLogAsync(List <DbEntityEntry> lstEntries)
        {
            return(await Task.Factory.StartNew(() =>
            {
                List <ObjectBinding> lstObjs = new List <ObjectBinding>();
                if (CurrentAccount != null && CurrentPersonnel != null)
                {
                    foreach (var entry in lstEntries)
                    {
                        ObjectBinding obj = new ObjectBinding();

                        if (entry.State == EntityState.Added)
                        {
                            obj.State = entry.State;
                            obj.Entity = entry;
                            obj.CurrentValues = entry.CurrentValues;
                            lstObjs.Add(obj);
                        }
                        else if (entry.State == EntityState.Modified)
                        {
                            obj.State = entry.State;
                            obj.Entity = entry;
                            obj.OriginalValues = entry.OriginalValues;
                            obj.CurrentValues = entry.CurrentValues;
                            lstObjs.Add(obj);
                        }
                        else if (entry.State == EntityState.Deleted)
                        {
                            obj.State = entry.State;
                            obj.Entity = entry;
                            obj.OriginalValues = entry.OriginalValues;
                            lstObjs.Add(obj);
                        }
                    }
                }
                return lstObjs;
            }));
        }
Пример #2
0
        private List <ObjectBinding> AutoLog(List <DbEntityEntry> lstEntries)
        {
            List <ObjectBinding> lstObjs = new List <ObjectBinding>();

            if (CurrentAccount != null && CurrentPersonnel != null)
            {
                foreach (var entry in lstEntries)
                {
                    ObjectBinding obj = new ObjectBinding();

                    if (entry.State == EntityState.Added)
                    {
                        obj.State         = entry.State;
                        obj.Entity        = entry;
                        obj.CurrentValues = entry.CurrentValues;
                        lstObjs.Add(obj);
                    }
                    else if (entry.State == EntityState.Modified)
                    {
                        obj.State          = entry.State;
                        obj.Entity         = entry;
                        obj.OriginalValues = entry.OriginalValues;
                        obj.CurrentValues  = entry.CurrentValues;
                        lstObjs.Add(obj);
                    }
                    else if (entry.State == EntityState.Deleted)
                    {
                        obj.State          = entry.State;
                        obj.Entity         = entry;
                        obj.OriginalValues = entry.OriginalValues;
                        lstObjs.Add(obj);
                    }
                }
            }
            return(lstObjs);
        }