Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Mapping / Update / Internal / ChangeNode.cs
blob1eabff48fc861279a0359c9e2fcd303458c3f98e
1 //---------------------------------------------------------------------
2 // <copyright file="ChangeNode.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 //
6 // @owner Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
10 using System.Data.Metadata.Edm;
11 using System.Collections.Generic;
12 using System.Text;
13 using System.Globalization;
14 namespace System.Data.Mapping.Update.Internal
16 /// <summary>
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.
20 /// </summary>
21 /// <remarks>
22 /// <para>
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" />.
27 /// </para>
28 /// <para>
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.
34 /// </para>
35 /// </remarks>
36 internal class ChangeNode
38 #region Constructors
39 /// <summary>
40 /// Constructs a change node containing changes belonging to the specified collection
41 /// schema definition.
42 /// </summary>
43 /// <param name="elementType">Sets <see cref="ElementType" /> property.</param>
44 internal ChangeNode(TypeUsage elementType)
46 m_elementType = elementType;
48 #endregion
50 #region Fields
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;
55 #endregion
57 #region Properties
58 /// <summary>
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.
61 /// </summary>
62 internal TypeUsage ElementType { get { return m_elementType; } }
64 /// <summary>
65 /// Gets a list of rows to be inserted.
66 /// </summary>
67 internal List<PropagatorResult> Inserted { get { return m_inserted; } }
69 /// <summary>
70 /// Gets a list of rows to be deleted.
71 /// </summary>
72 internal List<PropagatorResult> Deleted { get { return m_deleted; } }
74 /// <summary>
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.
77 /// </summary>
78 internal PropagatorResult Placeholder
80 get { return m_placeholder; }
81 set { m_placeholder = value; }
83 #endregion
85 #if DEBUG
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();
106 builder.Append("}");
107 return builder.ToString();
109 #endif