forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLazyPropertyDescriptor.cs
80 lines (71 loc) · 1.79 KB
/
LazyPropertyDescriptor.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NHibernate.Type;
namespace NHibernate.Bytecode
{
/// <summary>
/// Descriptor for a property which is enabled for bytecode lazy fetching
///
/// Author: Steve Ebersole
/// </summary>
[Serializable]
public class LazyPropertyDescriptor
{
public static LazyPropertyDescriptor From(
Mapping.Property property,
int propertyIndex,
int lazyIndex)
{
var fetchGroupName = string.IsNullOrEmpty(property.LazyGroup)
? "DEFAULT"
: property.LazyGroup;
return new LazyPropertyDescriptor(
propertyIndex,
lazyIndex,
property.Name,
property.Type,
fetchGroupName
);
}
private LazyPropertyDescriptor(
int propertyIndex,
int lazyIndex,
string name,
IType type,
string fetchGroupName)
{
if (propertyIndex < lazyIndex)
{
throw new InvalidOperationException("Property index is lower than the lazy index.");
}
PropertyIndex = propertyIndex;
LazyIndex = lazyIndex;
Name = name;
Type = type;
FetchGroupName = fetchGroupName;
}
/// <summary>
/// Access to the index of the property in terms of its position in the entity persister
/// </summary>
public int PropertyIndex { get; }
/// <summary>
/// Access to the index of the property in terms of its position within the lazy properties of the persister
/// </summary>
public int LazyIndex { get; }
/// <summary>
/// Access to the name of the property
/// </summary>
public string Name { get; }
/// <summary>
/// Access to the property's type
/// </summary>
public IType Type { get; }
/// <summary>
/// Access to the name of the fetch group to which the property belongs
/// </summary>
public string FetchGroupName { get; }
}
}