コード例 #1
0
ファイル: aModel.cs プロジェクト: hieuht300894/NetCoreAPI
        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
ファイル: aModel.cs プロジェクト: hieuht300894/NetCoreAPI
        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;
            }));
        }