Esempio n. 1
0
        public void Prepare()
        {
            var rowsMap = GetRowsMap();

            foreach (var trackAssoc in changeSet.trackAssocs)
            {
                var assoc     = _metadata.associations[trackAssoc.assocName];
                var pkey      = string.Format("{0}:{1}", assoc.parentDbSetName, trackAssoc.parentKey);
                var ckey      = string.Format("{0}:{1}", assoc.childDbSetName, trackAssoc.childKey);
                var parent    = rowsMap[pkey];
                var child     = rowsMap[ckey];
                var childNode = new ParentChildNode(child);
                childNode.association = assoc;
                childNode.ParentRow   = parent;
                updateNodes.AddLast(childNode);
            }


            foreach (var dbSet in GetSortedDbSets())
            {
                foreach (var rowInfo in dbSet.rows)
                {
                    var dbSetInfo = rowInfo.dbSetInfo;
                    _allList.AddLast(rowInfo);
                    switch (rowInfo.changeType)
                    {
                    case ChangeType.Added:
                        _insertList.AddLast(rowInfo);
                        break;

                    case ChangeType.Updated:
                        _updateList.AddLast(rowInfo);
                        break;

                    case ChangeType.Deleted:
                        _deleteList.AddFirst(rowInfo);
                        break;

                    default:
                        throw new DomainServiceException(string.Format(ErrorStrings.ERR_REC_CHANGETYPE_INVALID,
                                                                       dbSetInfo.EntityType.Name, rowInfo.changeType));
                    }
                }
            }
        }
 public EntityChangeState()
 {
     NamesOfChangedFields = new string[0];
     ParentRows           = new ParentChildNode[0];
 }