2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / System.Data.Linq / src / DbLinq / Data / Linq / ChangeSet.cs
1 #region MIT license\r
2 // \r
3 // MIT license\r
4 //\r
5 // Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne\r
6 // \r
7 // Permission is hereby granted, free of charge, to any person obtaining a copy\r
8 // of this software and associated documentation files (the "Software"), to deal\r
9 // in the Software without restriction, including without limitation the rights\r
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
11 // copies of the Software, and to permit persons to whom the Software is\r
12 // furnished to do so, subject to the following conditions:\r
13 // \r
14 // The above copyright notice and this permission notice shall be included in\r
15 // all copies or substantial portions of the Software.\r
16 // \r
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
23 // THE SOFTWARE.\r
24 // \r
25 #endregion\r
26 \r
27 using System.Collections.Generic;\r
28 \r
29 #if MONO_STRICT\r
30 namespace System.Data.Linq\r
31 #else\r
32 namespace DbLinq.Data.Linq\r
33 #endif\r
34 {\r
35     /// <summary>\r
36     /// Contains list of datacontext entities to be deleted, inserted and updated.\r
37     /// Merges table separate lists into single one.\r
38     /// Standard DLinq class defined in MSDN.\r
39     /// Important: this is immutable and reflects a snapshot of the DataContext when calling GetChangeSet\r
40     /// </summary>\r
41     public sealed class ChangeSet\r
42     {\r
43         /// <summary>\r
44         /// All items to be inserted\r
45         /// </summary>\r
46         public IList<object> Inserts { get; private set; }\r
47 \r
48         /// <summary>\r
49         /// All items to be updated\r
50         /// </summary>\r
51         public IList<object> Updates { get; private set; }\r
52 \r
53         /// <summary>\r
54         /// All items to be deleted\r
55         /// </summary>\r
56         public IList<object> Deletes { get; private set; }\r
57 \r
58         public override string ToString()\r
59         {\r
60             return string.Format("Total changes: {{Added: {0}, Removed: {1}, Modified: {2}}}",\r
61                                  Inserts.Count, Deletes.Count, Updates.Count);\r
62         }\r
63 \r
64         /// <summary>\r
65         /// Initializes a new instance of the <see cref="ChangeSet"/> class.\r
66         /// </summary>\r
67         /// <param name="inserts">The inserts.</param>\r
68         /// <param name="updates">The updates.</param>\r
69         /// <param name="deletes">The deletes.</param>\r
70         internal ChangeSet(List<object> inserts, List<object> updates, List<object> deletes)\r
71         {\r
72             Inserts = inserts.AsReadOnly();\r
73             Updates = updates.AsReadOnly();\r
74             Deletes = deletes.AsReadOnly();\r
75         }\r
76     }\r
77 }\r