Пример #1
0
        private List <ObjectBinding> AutoLog(List <EntityEntry> lstEntries)
        {
            List <ObjectBinding> lstObjs = new List <ObjectBinding>();

            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 async Task <List <ObjectBinding> > AutoLogAsync(List <EntityEntry> lstEntries)
        {
            return(await Task.Factory.StartNew(() =>
            {
                List <ObjectBinding> lstObjs = new List <ObjectBinding>();

                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;
            }));
        }