5 // Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne
\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
14 // The above copyright notice and this permission notice shall be included in
\r
15 // all copies or substantial portions of the Software.
\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
27 using System.Collections.Generic;
\r
30 namespace System.Data.Linq
\r
32 namespace DbLinq.Data.Linq
\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
41 public sealed class ChangeSet
\r
44 /// All items to be inserted
\r
46 public IList<object> Inserts { get; private set; }
\r
49 /// All items to be updated
\r
51 public IList<object> Updates { get; private set; }
\r
54 /// All items to be deleted
\r
56 public IList<object> Deletes { get; private set; }
\r
58 public override string ToString()
\r
60 return string.Format("Total changes: {{Added: {0}, Removed: {1}, Modified: {2}}}",
\r
61 Inserts.Count, Deletes.Count, Updates.Count);
\r
65 /// Initializes a new instance of the <see cref="ChangeSet"/> class.
\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
72 Inserts = inserts.AsReadOnly();
\r
73 Updates = updates.AsReadOnly();
\r
74 Deletes = deletes.AsReadOnly();
\r