@@ -6,43 +6,32 @@ namespace FluentNHibernate.Mapping;
6
6
7
7
public class CachePart ( Type entityType ) : ICacheMappingProvider
8
8
{
9
- readonly AttributeStore attributes = new AttributeStore ( ) ;
9
+ readonly AttributeStore attributes = new ( ) ;
10
10
11
11
/// <summary>
12
12
/// Sets caching to read-write
13
13
/// </summary>
14
- public CachePart ReadWrite ( )
15
- {
16
- attributes . Set ( "Usage" , Layer . UserSupplied , "read-write" ) ;
17
- return this ;
18
- }
14
+ public CachePart ReadWrite ( ) => CustomUsage ( "read-write" ) ;
19
15
20
16
/// <summary>
21
17
/// Sets caching to non-strict read-write
22
18
/// </summary>
23
- public CachePart NonStrictReadWrite ( )
24
- {
25
- attributes . Set ( "Usage" , Layer . UserSupplied , "nonstrict-read-write" ) ;
26
- return this ;
27
- }
19
+ public CachePart NonStrictReadWrite ( ) => CustomUsage ( "nonstrict-read-write" ) ;
28
20
29
21
/// <summary>
30
22
/// Sets caching to read-only
31
23
/// </summary>
32
- public CachePart ReadOnly ( )
33
- {
34
- attributes . Set ( "Usage" , Layer . UserSupplied , "read-only" ) ;
35
- return this ;
36
- }
24
+ public CachePart ReadOnly ( ) => CustomUsage ( "read-only" ) ;
37
25
38
26
/// <summary>
39
27
/// Sets caching to transactional
40
28
/// </summary>
41
- public CachePart Transactional ( )
42
- {
43
- attributes . Set ( "Usage" , Layer . UserSupplied , "transactional" ) ;
44
- return this ;
45
- }
29
+ public CachePart Transactional ( ) => CustomUsage ( "transactional" ) ;
30
+
31
+ /// <summary>
32
+ /// Sets caching to never
33
+ /// </summary>
34
+ public CachePart Never ( ) => CustomUsage ( "never" ) ;
46
35
47
36
/// <summary>
48
37
/// Specifies a custom cache behaviour
@@ -68,20 +57,12 @@ public CachePart Region(string name)
68
57
/// Include all properties for caching
69
58
/// </summary>
70
59
/// <returns></returns>
71
- public CachePart IncludeAll ( )
72
- {
73
- attributes . Set ( "Include" , Layer . UserSupplied , "all" ) ;
74
- return this ;
75
- }
60
+ public CachePart IncludeAll ( ) => CustomInclude ( "all" ) ;
76
61
77
62
/// <summary>
78
63
/// Include only non-lazy properties for caching
79
64
/// </summary>
80
- public CachePart IncludeNonLazy ( )
81
- {
82
- attributes . Set ( "Include" , Layer . UserSupplied , "non-lazy" ) ;
83
- return this ;
84
- }
65
+ public CachePart IncludeNonLazy ( ) => CustomInclude ( "non-lazy" ) ;
85
66
86
67
/// <summary>
87
68
/// Specify a custom property inclusion strategy
@@ -95,11 +76,9 @@ public CachePart CustomInclude(string custom)
95
76
96
77
internal bool IsDirty => attributes . IsSpecified ( "Region" ) || attributes . IsSpecified ( "Usage" ) || attributes . IsSpecified ( "Include" ) ;
97
78
98
- CacheMapping ICacheMappingProvider . GetCacheMapping ( )
99
- {
100
- var mapping = new CacheMapping ( attributes . Clone ( ) ) ;
101
- mapping . ContainedEntityType = entityType ;
102
-
103
- return mapping ;
104
- }
79
+ CacheMapping ICacheMappingProvider . GetCacheMapping ( ) =>
80
+ new ( attributes . Clone ( ) )
81
+ {
82
+ ContainedEntityType = entityType
83
+ } ;
105
84
}
0 commit comments