-
Notifications
You must be signed in to change notification settings - Fork 933
/
Copy pathQueryOverFetchBuilder.cs
69 lines (52 loc) · 1.45 KB
/
QueryOverFetchBuilder.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
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using NHibernate.Impl;
using NHibernate.SqlCommand;
namespace NHibernate.Criterion.Lambda
{
public class QueryOverFetchBuilder<TRoot,TSubType> : QueryOverFetchBuilderBase<QueryOver<TRoot,TSubType>, TRoot, TSubType>
{
public QueryOverFetchBuilder(QueryOver<TRoot,TSubType> root, Expression<Func<TRoot, object>> path)
: base(root, path) { }
}
public class IQueryOverFetchBuilder<TRoot,TSubType> : QueryOverFetchBuilderBase<IQueryOver<TRoot,TSubType>, TRoot, TSubType>
{
public IQueryOverFetchBuilder(IQueryOver<TRoot,TSubType> root, Expression<Func<TRoot, object>> path)
: base(root, path) { }
}
public class QueryOverFetchBuilderBase<TReturn, TRoot, TSubType> where TReturn : IQueryOver<TRoot,TSubType>
{
protected TReturn root;
protected string path;
protected QueryOverFetchBuilderBase(TReturn root, Expression<Func<TRoot, object>> path)
{
this.root = root;
this.path = ExpressionProcessor.FindMemberExpression(path.Body);
}
public TReturn Eager
{
get
{
this.root.UnderlyingCriteria.SetFetchMode(path, FetchMode.Eager);
return this.root;
}
}
public TReturn Lazy
{
get
{
this.root.UnderlyingCriteria.SetFetchMode(path, FetchMode.Lazy);
return this.root;
}
}
public TReturn Default
{
get
{
this.root.UnderlyingCriteria.SetFetchMode(path, FetchMode.Default);
return this.root;
}
}
}
}