Esempio n. 1
0
        protected virtual void TrackChangesToEntity(RowInfo rowInfo)
        {
            DbSetInfo dbSetInfo = rowInfo.GetDbSetInfo();

            if (!dbSetInfo.GetIsTrackChanges())
            {
                return;
            }

            try
            {
                string[] changed = new string[0];
                switch (rowInfo.changeType)
                {
                case ChangeType.Updated:
                {
                    changed = rowInfo.GetChangeState().ChangedFieldNames;
                }
                break;

                default:
                {
                    changed = dbSetInfo.GetNames().Select(f => f.n).ToArray();
                }
                break;
                }

                string[] pknames  = dbSetInfo.GetPKFields().Select(f => f.fieldName).ToArray();
                string   diffgram = DiffGram.GetDiffGram(rowInfo.GetChangeState().OriginalEntity,
                                                         rowInfo.changeType == ChangeType.Deleted ? null : rowInfo.GetChangeState().Entity,
                                                         dbSetInfo.GetEntityType(), changed, pknames, rowInfo.changeType, dbSetInfo.dbSetName);

                OnTrackChange(dbSetInfo.dbSetName, rowInfo.changeType, diffgram);
            }
            catch (Exception ex)
            {
                _OnError(ex);
            }
        }