PageRenderTime 36ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/Bifrost/Entities/IEntityContext.cs

#
C# | 77 lines | 17 code | 7 blank | 53 comment | 0 complexity | 7488f4dc328ae5919c47a544adc1b889 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. #region License
  2. //
  3. // Copyright (c) 2008-2012, DoLittle Studios and Komplett ASA
  4. //
  5. // Licensed under the Microsoft Permissive License (Ms-PL), Version 1.1 (the "License")
  6. // With one exception :
  7. // Commercial libraries that is based partly or fully on Bifrost and is sold commercially,
  8. // must obtain a commercial license.
  9. //
  10. // You may not use this file except in compliance with the License.
  11. // You may obtain a copy of the license at
  12. //
  13. // http://bifrost.codeplex.com/license
  14. //
  15. // Unless required by applicable law or agreed to in writing, software
  16. // distributed under the License is distributed on an "AS IS" BASIS,
  17. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. // See the License for the specific language governing permissions and
  19. // limitations under the License.
  20. //
  21. #endregion
  22. using System;
  23. using System.Linq;
  24. namespace Bifrost.Entities
  25. {
  26. /// <summary>
  27. /// Defines a context for working with entities typically stored in a datastore
  28. /// </summary>
  29. /// <typeparam name="T">Type of entity the context works on</typeparam>
  30. public interface IEntityContext<T> : IDisposable
  31. {
  32. /// <summary>
  33. /// Gets a queryable that one can do queries against
  34. /// </summary>
  35. IQueryable<T> Entities { get; }
  36. /// <summary>
  37. /// Attach an entity to the context
  38. /// </summary>
  39. /// <param name="entity">Entity to attach</param>
  40. /// <remarks>
  41. /// In some conditions you might have an untracked entity, in order for that
  42. /// entity to be state handled by some implementations; you need to attach it.
  43. /// </remarks>
  44. void Attach(T entity);
  45. /// <summary>
  46. /// Insert a newly created entity
  47. /// </summary>
  48. /// <param name="entity">Entity to insert</param>
  49. void Insert(T entity);
  50. /// <summary>
  51. /// Update an existing entity
  52. /// </summary>
  53. /// <param name="entity">Entity to update</param>
  54. void Update(T entity);
  55. /// <summary>
  56. /// Delete an existing entity
  57. /// </summary>
  58. /// <param name="entity">Entity to delete</param>
  59. void Delete(T entity);
  60. /// <summary>
  61. /// Save en existing entity
  62. /// </summary>
  63. /// <param name="entity">Entity to save</param>
  64. void Save(T entity);
  65. /// <summary>
  66. /// Commit any changes in the context
  67. /// </summary>
  68. void Commit();
  69. }
  70. }