PageRenderTime 18ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/Source/Bifrost/Entities/IEntityContext.cs

#
C# | 77 lines | 17 code | 7 blank | 53 comment | 0 complexity | 7488f4dc328ae5919c47a544adc1b889 MD5 | raw file
 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
22using System;
23using System.Linq;
24
25namespace Bifrost.Entities
26{
27	/// <summary>
28	/// Defines a context for working with entities typically stored in a datastore
29	/// </summary>
30	/// <typeparam name="T">Type of entity the context works on</typeparam>
31	public interface IEntityContext<T> : IDisposable
32	{
33		/// <summary>
34		/// Gets a queryable that one can do queries against
35		/// </summary>
36		IQueryable<T> Entities { get; }
37
38		/// <summary>
39		/// Attach an entity to the context
40		/// </summary>
41		/// <param name="entity">Entity to attach</param>
42		/// <remarks>
43		/// In some conditions you might have an untracked entity, in order for that
44		/// entity to be state handled by some implementations; you need to attach it.
45		/// </remarks>
46		void Attach(T entity);
47
48		/// <summary>
49		/// Insert a newly created entity
50		/// </summary>
51		/// <param name="entity">Entity to insert</param>
52		void Insert(T entity);
53
54		/// <summary>
55		/// Update an existing entity
56		/// </summary>
57		/// <param name="entity">Entity to update</param>
58		void Update(T entity);
59
60		/// <summary>
61		/// Delete an existing entity
62		/// </summary>
63		/// <param name="entity">Entity to delete</param>
64		void Delete(T entity);
65
66        /// <summary>
67        /// Save en existing entity
68        /// </summary>
69        /// <param name="entity">Entity to save</param>
70	    void Save(T entity);
71
72		/// <summary>
73		/// Commit any changes in the context
74		/// </summary>
75		void Commit();
76	}
77}