1 //---------------------------------------------------------------------
2 // <copyright file="ChangeNode.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
10 using System
.Data
.Metadata
.Edm
;
11 using System
.Collections
.Generic
;
13 using System
.Globalization
;
14 namespace System
.Data
.Mapping
.Update
.Internal
17 /// This class encapsulates changes propagated to a node in an update mapping view.
18 /// It contains lists of deleted and inserted rows. Key intersections betweens rows
19 /// in the two sets are treated as updates in the store.
23 /// Additional tags indicating the roles of particular values (e.g., concurrency, undefined,
24 /// etc.) are stored within each row: where appropriate, constants appearing
25 /// within a row are associated with a <see cref="PropagatorResult" /> through the <see cref=
26 /// "UpdateTranslator" />.
29 /// The 'leaves' of an update mapping view (UMV) are extent expressions. A change node
30 /// associated with an extent expression is simply the list of changes to the C-Space
31 /// requested by a caller. As changes propagate 'up' the UMV expression tree, we recursively
32 /// apply transformations such that the change node associated with the root of the UMV
33 /// represents changes to apply in the S-Space.
36 internal class ChangeNode
40 /// Constructs a change node containing changes belonging to the specified collection
41 /// schema definition.
43 /// <param name="elementType">Sets <see cref="ElementType" /> property.</param>
44 internal ChangeNode(TypeUsage elementType
)
46 m_elementType
= elementType
;
51 private TypeUsage m_elementType
;
52 private List
<PropagatorResult
> m_inserted
= new List
<PropagatorResult
>();
53 private List
<PropagatorResult
> m_deleted
= new List
<PropagatorResult
>();
54 private PropagatorResult m_placeholder
;
59 /// Gets the type of the rows contained in this node. This type corresponds (not coincidentally)
60 /// to the type of an expression in an update mapping view.
62 internal TypeUsage ElementType { get { return m_elementType; }
}
65 /// Gets a list of rows to be inserted.
67 internal List
<PropagatorResult
> Inserted { get { return m_inserted; }
}
70 /// Gets a list of rows to be deleted.
72 internal List
<PropagatorResult
> Deleted { get { return m_deleted; }
}
75 /// Gets or sets a version of a record at this node with default record. The record has the type
76 /// of the node we are visiting.
78 internal PropagatorResult Placeholder
80 get { return m_placeholder; }
81 set { m_placeholder = value; }
86 public override string ToString()
88 StringBuilder builder
= new StringBuilder();
90 builder
.AppendLine("{");
91 builder
.AppendFormat(CultureInfo
.InvariantCulture
, " ElementType = {0}", ElementType
).AppendLine();
92 builder
.AppendLine(" Inserted = {");
93 foreach (PropagatorResult insert
in Inserted
)
95 builder
.Append(" ").AppendLine(insert
.ToString());
97 builder
.AppendLine(" }");
98 builder
.AppendLine(" Deleted = {");
99 foreach (PropagatorResult delete
in Deleted
)
101 builder
.Append(" ").AppendLine(delete
.ToString());
103 builder
.AppendLine(" }");
104 builder
.AppendFormat(CultureInfo
.InvariantCulture
, " PlaceHolder = {0}", Placeholder
).AppendLine();
107 return builder
.ToString();