annotate Source/Data/Linq/CompiledQuery.cs @ 1:8f65451dc28f

Исправлена проблема с фабрикой и выборкой нескольких объектов в linq выражении
author cin
date Fri, 28 Mar 2014 01:04:56 +0400
parents f990fcb411a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
1 using System;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
2 using System.Collections.Generic;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
3 using System.Linq;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
4 using System.Linq.Expressions;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
5
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
6 namespace BLToolkit.Data.Linq
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
7 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
8 using BLToolkit.Linq;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
9 using Reflection;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
10
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
11 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
12 /// Provides for compilation and caching of queries for reuse.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
13 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
14 public class CompiledQuery
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
15 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
16 protected CompiledQuery(LambdaExpression query)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
17 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
18 _query = query;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
19 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
20
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
21 readonly object _sync = new object();
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
22 readonly LambdaExpression _query;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
23 volatile Func<object[],object> _compiledQuery;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
24
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
25 TResult ExecuteQuery<TResult>(params object[] args)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
26 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
27 if (_compiledQuery == null)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
28 lock (_sync)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
29 if (_compiledQuery == null)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
30 _compiledQuery = CompileQuery(_query);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
31
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
32 return (TResult)_compiledQuery(args);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
33 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
34
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
35 private interface ITableHelper
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
36 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
37 Expression CallTable(LambdaExpression query, Expression expr, ParameterExpression ps, bool isQueriable);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
38 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
39
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
40 internal class TableHelper<T> : ITableHelper
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
41 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
42 public Expression CallTable(LambdaExpression query, Expression expr, ParameterExpression ps, bool isQueriable)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
43 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
44 var table = new CompiledTable<T>(query, expr);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
45
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
46 return Expression.Call(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
47 Expression.Constant(table),
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
48 isQueriable ?
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
49 ReflectionHelper.Expressor<CompiledTable<T>>.MethodExpressor(t => t.Create (null)) :
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
50 ReflectionHelper.Expressor<CompiledTable<T>>.MethodExpressor(t => t.Execute(null)),
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
51 ps);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
52 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
53 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
54
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
55 static Func<object[],object> CompileQuery(LambdaExpression query)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
56 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
57 var ps = Expression.Parameter(typeof(object[]), "ps");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
58
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
59 var info = query.Body.Convert(pi =>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
60 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
61 switch (pi.NodeType)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
62 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
63 case ExpressionType.Parameter :
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
64 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
65 var idx = query.Parameters.IndexOf((ParameterExpression)pi);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
66
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
67 if (idx >= 0)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
68 return Expression.Convert(Expression.ArrayIndex(ps, Expression.Constant(idx)), pi.Type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
69
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
70 break;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
71 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
72
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
73 case ExpressionType.Call :
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
74 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
75 var expr = (MethodCallExpression)pi;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
76
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
77 if (expr.IsQueryable())
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
78 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
79 var qtype = TypeHelper.GetGenericType(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
80 TypeHelper.IsSameOrParent(typeof(IQueryable), expr.Type) ?
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
81 typeof(IQueryable<>) :
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
82 typeof(IEnumerable<>),
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
83 expr.Type);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
84
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
85 var helper = (ITableHelper)Activator.CreateInstance(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
86 typeof(TableHelper<>).MakeGenericType(qtype == null ? expr.Type : qtype.GetGenericArguments()[0]));
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
87
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
88 return helper.CallTable(query, expr, ps, qtype != null);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
89 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
90
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
91 if (expr.Method.Name == "GetTable" && expr.Method.DeclaringType == typeof(Extensions))
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
92 goto case ExpressionType.MemberAccess;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
93 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
94
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
95 break;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
96
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
97 case ExpressionType.MemberAccess :
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
98 if (pi.Type.IsGenericType && pi.Type.GetGenericTypeDefinition() == typeof(Table<>))
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
99 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
100 var helper = (ITableHelper)Activator
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
101 .CreateInstance(typeof(TableHelper<>)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
102 .MakeGenericType(pi.Type.GetGenericArguments()[0]));
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
103 return helper.CallTable(query, pi, ps, true);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
104 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
105
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
106 break;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
107 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
108
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
109 return pi;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
110 });
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
111
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
112 return Expression.Lambda<Func<object[],object>>(Expression.Convert(info, typeof(object)), ps).Compile();
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
113 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
114
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
115 #region Invoke
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
116
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
117 public TResult Invoke<TDC,TResult>(TDC dataContext)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
118 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
119 return ExecuteQuery<TResult>(dataContext);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
120 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
121
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
122 public TResult Invoke<TDC,T1,TResult>(TDC dataContext, T1 arg1)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
123 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
124 return ExecuteQuery<TResult>(dataContext, arg1);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
125 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
126
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
127 public TResult Invoke<TDC,T1,T2,TResult>(TDC dataContext, T1 arg1, T2 arg2)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
128 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
129 return ExecuteQuery<TResult>(dataContext, arg1, arg2);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
130 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
131
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
132 public TResult Invoke<TDC,T1,T2,T3,TResult>(TDC dataContext, T1 arg1, T2 arg2, T3 arg3)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
133 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
134 return ExecuteQuery<TResult>(dataContext, arg1, arg2, arg3);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
135 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
136
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
137 public TResult Invoke<TDC,T1,T2,T3,T4,TResult>(TDC dataContext, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
138 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
139 return ExecuteQuery<TResult>(dataContext, arg1, arg2, arg3, arg4);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
140 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
141
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
142 public TResult Invoke<TDC,T1,T2,T3,T4,T5,TResult>(TDC dataContext, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
143 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
144 return ExecuteQuery<TResult>(dataContext, arg1, arg2, arg3, arg4, arg5);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
145 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
146
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
147 #endregion
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
148
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
149 #region Compile
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
150
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
151 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
152 /// Compiles the query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
153 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
154 /// <returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
155 /// A generic delegate that represents the compiled query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
156 /// </returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
157 /// <param name="query">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
158 /// The query expression to be compiled.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
159 /// </param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
160 /// <typeparam name="TDC ">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
161 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
162 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
163 /// <typeparam name="TResult">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
164 /// Returned type of the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
165 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
166 public static Func<TDC,TResult> Compile<TDC,TResult>(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
167 [JetBrains.Annotations.NotNull] Expression<Func<TDC,TResult>> query)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
168 where TDC : IDataContext
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
169 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
170 if (query == null) throw new ArgumentNullException("query");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
171 return new CompiledQuery(query).Invoke<TDC,TResult>;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
172 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
173
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
174 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
175 /// Compiles the query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
176 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
177 /// <returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
178 /// A generic delegate that represents the compiled query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
179 /// </returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
180 /// <param name="query">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
181 /// The query expression to be compiled.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
182 /// </param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
183 /// <typeparam name="TDC">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
184 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
185 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
186 /// <typeparam name="TArg1">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
187 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
188 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
189 /// <typeparam name="TResult">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
190 /// Returned type of the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
191 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
192 public static Func<TDC,TArg1,TResult> Compile<TDC,TArg1,TResult>(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
193 [JetBrains.Annotations.NotNull] Expression<Func<TDC,TArg1,TResult>> query)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
194 where TDC : IDataContext
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
195 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
196 if (query == null) throw new ArgumentNullException("query");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
197 return new CompiledQuery(query).Invoke<TDC,TArg1,TResult>;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
198 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
199
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
200 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
201 /// Compiles the query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
202 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
203 /// <returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
204 /// A generic delegate that represents the compiled query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
205 /// </returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
206 /// <param name="query">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
207 /// The query expression to be compiled.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
208 /// </param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
209 /// <typeparam name="TDC ">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
210 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
211 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
212 /// <typeparam name="TArg1">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
213 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
214 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
215 /// <typeparam name="TArg2">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
216 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
217 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
218 /// <typeparam name="TResult">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
219 /// Returned type of the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
220 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
221 public static Func<TDC,TArg1,TArg2,TResult> Compile<TDC,TArg1,TArg2,TResult>(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
222 [JetBrains.Annotations.NotNull] Expression<Func<TDC,TArg1,TArg2,TResult>> query)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
223 where TDC : IDataContext
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
224 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
225 if (query == null) throw new ArgumentNullException("query");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
226 return new CompiledQuery(query).Invoke<TDC,TArg1,TArg2,TResult>;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
227 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
228
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
229 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
230 /// Compiles the query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
231 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
232 /// <returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
233 /// A generic delegate that represents the compiled query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
234 /// </returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
235 /// <param name="query">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
236 /// The query expression to be compiled.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
237 /// </param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
238 /// <typeparam name="TDC ">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
239 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
240 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
241 /// <typeparam name="TArg1">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
242 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
243 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
244 /// <typeparam name="TArg2">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
245 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
246 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
247 /// <typeparam name="TArg3">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
248 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
249 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
250 /// <typeparam name="TResult">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
251 /// Returned type of the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
252 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
253 public static Func<TDC,TArg1,TArg2,TArg3,TResult> Compile<TDC,TArg1,TArg2,TArg3,TResult>(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
254 [JetBrains.Annotations.NotNull] Expression<Func<TDC,TArg1,TArg2,TArg3,TResult>> query)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
255 where TDC : IDataContext
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
256 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
257 if (query == null) throw new ArgumentNullException("query");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
258 return new CompiledQuery(query).Invoke<TDC,TArg1,TArg2,TArg3,TResult>;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
259 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
260
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
261 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
262 /// Compiles the query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
263 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
264 /// <returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
265 /// A generic delegate that represents the compiled query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
266 /// </returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
267 /// <param name="query">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
268 /// The query expression to be compiled.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
269 /// </param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
270 /// <typeparam name="TDC ">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
271 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
272 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
273 /// <typeparam name="TArg1">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
274 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
275 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
276 /// <typeparam name="TArg2">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
277 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
278 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
279 /// <typeparam name="TArg3">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
280 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
281 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
282 /// <typeparam name="TArg4">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
283 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
284 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
285 /// <typeparam name="TResult">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
286 /// Returned type of the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
287 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
288 public static Func<TDC,TArg1,TArg2,TArg3,TArg4,TResult> Compile<TDC,TArg1,TArg2,TArg3,TArg4,TResult>(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
289 [JetBrains.Annotations.NotNull] Expression<Func<TDC,TArg1,TArg2,TArg3,TArg4,TResult>> query)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
290 where TDC : IDataContext
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
291 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
292 if (query == null) throw new ArgumentNullException("query");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
293 return new CompiledQuery(query).Invoke<TDC,TArg1,TArg2,TArg3,TArg4,TResult>;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
294 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
295
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
296 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
297 /// Compiles the query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
298 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
299 /// <returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
300 /// A generic delegate that represents the compiled query.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
301 /// </returns>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
302 /// <param name="query">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
303 /// The query expression to be compiled.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
304 /// </param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
305 /// <typeparam name="TDC ">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
306 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
307 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
308 /// <typeparam name="TArg1">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
309 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
310 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
311 /// <typeparam name="TArg2">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
312 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
313 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
314 /// <typeparam name="TArg3">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
315 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
316 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
317 /// <typeparam name="TArg4">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
318 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
319 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
320 /// <typeparam name="TArg5">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
321 /// Represents the type of the parameter that has to be passed in when executing the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
322 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
323 /// <typeparam name="TResult">
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
324 /// Returned type of the delegate returned by the method.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
325 /// </typeparam>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
326 public static Func<TDC,TArg1,TArg2,TArg3,TArg4,TArg5,TResult> Compile<TDC,TArg1,TArg2,TArg3,TArg4,TArg5,TResult>(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
327 [JetBrains.Annotations.NotNull] Expression<Func<TDC,TArg1,TArg2,TArg3,TArg4,TArg5,TResult>> query)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
328 where TDC : IDataContext
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
329 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
330 if (query == null) throw new ArgumentNullException("query");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
331 return new CompiledQuery(query).Invoke<TDC,TArg1,TArg2,TArg3,TArg4,TArg5,TResult>;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
332 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
333
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
334 #endregion
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
335 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
336 }