forked from smartstore/SmartStoreNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRepository.cs
More file actions
110 lines (95 loc) · 4.63 KB
/
Copy pathIRepository.cs
File metadata and controls
110 lines (95 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace SmartStore.Core.Data
{
/// <summary>
/// Repository
/// </summary>
public partial interface IRepository<T> where T : BaseEntity
{
/// <summary>
/// Returns the queryable entity set for the given type {T}.
/// </summary>
IQueryable<T> Table { get; }
/// <summary>
/// Returns an untracked queryable entity set for the given type {T}.
/// The entities returned will not be cached in the object context thus increasing performance.
/// </summary>
IQueryable<T> TableUntracked { get; }
/// <summary>
/// Provides access to the entities currently being tracked by the context and have not been marked as deleted
/// </summary>
ICollection<T> Local { get; }
/// <summary>
/// Creates a new instance of an entity of type {T}
/// </summary>
/// <returns>The new entity instance.</returns>
T Create();
/// <summary>
/// Gets an entity by id from the database or the local change tracker.
/// </summary>
/// <param name="id">The id of the entity. This can also be a composite key.</param>
/// <returns>The resolved entity</returns>
T GetById(object id);
/// <summary>
/// Marks the entity instance to be saved to the store.
/// </summary>
/// <param name="entity">An entity instance that should be saved to the database.</param>
/// <remarks>Implementors should delegate this to the current <see cref="IDbContext" /></remarks>
void Insert(T entity);
/// <summary>
/// Marks multiple entities to be saved to the store.
/// </summary>
/// <param name="entities">The list of entity instances to be saved to the database</param>
/// <param name="batchSize">The number of entities to insert before saving to the database (if <see cref="AutoCommitEnabled"/> is true)</param>
void InsertRange(IEnumerable<T> entities, int batchSize = 100);
/// <summary>
/// Marks the changes of an existing entity to be saved to the store.
/// </summary>
/// <param name="entity">An instance that should be updated in the database.</param>
/// <remarks>Implementors should delegate this to the current <see cref="IDbContext" /></remarks>
void Update(T entity);
/// <summary>
/// Marks an existing entity to be deleted from the store.
/// </summary>
/// <param name="entity">An entity instance that should be deleted from the database.</param>
/// <remarks>Implementors should delegate this to the current <see cref="IDbContext" /></remarks>
void Delete(T entity);
[Obsolete("Use the extension method from 'SmartStore.Core, SmartStore.Core.Data' instead")]
IQueryable<T> Expand(IQueryable<T> query, string path);
[Obsolete("Use the extension method from 'SmartStore.Core, SmartStore.Core.Data' instead")]
IQueryable<T> Expand<TProperty>(IQueryable<T> query, Expression<Func<T, TProperty>> path);
/// <summary>
/// Gets a value indicating whether the given entity was modified since it has been attached to the context
/// </summary>
/// <param name="entity">The entity to check</param>
/// <returns><c>true</c> if the entity was modified, <c>false</c> otherwise</returns>
bool IsModified(T entity);
/// <summary>
/// Gets a list of modified properties for the specified entity
/// </summary>
/// <param name="entity">The entity instance for which to get modified properties for</param>
/// <returns>
/// A dictionary, where the key is the name of the modified property
/// and the value is its ORIGINAL value (which was tracked when the entity
/// was attached to the context the first time)
/// Returns an empty dictionary if no modification could be detected.
/// </returns>
IDictionary<string, object> GetModifiedProperties(T entity);
/// <summary>
/// Returns the data context associated with the repository.
/// </summary>
/// <remarks>
/// The context is likely shared among multiple repository types.
/// So committing data or changing configuration also affects other repositories.
/// </remarks>
IDbContext Context { get; }
/// <summary>
/// Gets or sets a value indicating whether database write operations
/// such as insert, delete or update should be committed immediately.
/// </summary>
bool AutoCommitEnabled { get; set; }
}
}