DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
QueryableTable.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.Collections;
19 using System.Collections.Generic;
20 using System.Linq;
21 using System.Linq.Expressions;
22 
23 namespace Deveel.Data.Linq {
24  class QueryableTable<T> : IOrderedQueryable<T> {
26  Provider = provider;
27  Expression = Expression.Constant(this);
28  }
29 
30  public QueryableTable(TableQueryProvider provider, Expression expression) {
31  if (provider == null)
32  throw new ArgumentNullException("provider");
33  if (expression == null)
34  throw new ArgumentNullException("expression");
35 
36  if (!typeof(IQueryable<T>).IsAssignableFrom(expression.Type))
37  throw new ArgumentException("Invalid expression type.", "expression");
38 
39  Provider = provider;
40  Expression = expression;
41  }
42 
43  IEnumerator IEnumerable.GetEnumerator() {
44  return ((IEnumerable) Provider.Execute(Expression)).GetEnumerator();
45  }
46 
47  public Expression Expression { get; private set; }
48 
49  public Type ElementType {
50  get { return typeof (T); }
51  }
52 
53  public IQueryProvider Provider { get; private set; }
54 
55  public IEnumerator<T> GetEnumerator() {
56  return ((IEnumerable<T>) Provider.Execute<T>(Expression)).GetEnumerator();
57  }
58 
59  public override string ToString() {
60  return ((TableQueryProvider) Provider).GetQueryText(Expression);
61  }
62  }
63 }
IEnumerator< T > GetEnumerator()
QueryableTable(TableQueryProvider provider)
QueryableTable(TableQueryProvider provider, Expression expression)