PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/mcs/class/System.Data.Linq/src/DbLinq/Data/Linq/ChangeSet.cs

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