DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Properties | Private Member Functions | Static Private Member Functions | List of all members
Deveel.Data.Linq.TableQueryProvider Class Reference
Inheritance diagram for Deveel.Data.Linq.TableQueryProvider:

Public Member Functions

 TableQueryProvider (ITable table)
 
IQueryable CreateQuery (Expression expression)
 
IQueryable< TElement > CreateQuery< TElement > (Expression expression)
 
object Execute (Expression expression)
 
TResult Execute< TResult > (Expression expression)
 
string GetQueryText (Expression expression)
 

Properties

ITable Table [get, private set]
 

Private Member Functions

object Execute (Expression expression, bool isEnum)
 

Static Private Member Functions

static bool IsQueryOverDataSource (Expression expression)
 

Detailed Description

Definition at line 25 of file TableQueryProvider.cs.

Constructor & Destructor Documentation

Deveel.Data.Linq.TableQueryProvider.TableQueryProvider ( ITable  table)
inline

Definition at line 26 of file TableQueryProvider.cs.

26  {
27  if (table == null)
28  throw new ArgumentNullException("table");
29 
30  Table = table;
31  }

Member Function Documentation

IQueryable Deveel.Data.Linq.TableQueryProvider.CreateQuery ( Expression  expression)
inline

Definition at line 35 of file TableQueryProvider.cs.

35  {
36  var elementType = TypeSystem.GetElementType(expression.Type);
37 
38  try {
39  var type = typeof (QueryableTable<>).MakeGenericType(elementType);
40  return (IQueryable) Activator.CreateInstance(type, new object[] {this, expression});
41  } catch (TargetInvocationException ex) {
42  throw ex.InnerException;
43  }
44  }
IQueryable<TElement> Deveel.Data.Linq.TableQueryProvider.CreateQuery< TElement > ( Expression  expression)
inline

Definition at line 46 of file TableQueryProvider.cs.

46  {
47  return new QueryableTable<TElement>(this, expression);
48  }
object Deveel.Data.Linq.TableQueryProvider.Execute ( Expression  expression)
inline

Definition at line 50 of file TableQueryProvider.cs.

50  {
51  return Execute(expression, false);
52  }
object Execute(Expression expression)
object Deveel.Data.Linq.TableQueryProvider.Execute ( Expression  expression,
bool  isEnum 
)
inlineprivate

Definition at line 55 of file TableQueryProvider.cs.

55  {
56  // The expression must represent a query over the data source.
57  if (!IsQueryOverDataSource(expression))
58  throw new InvalidProgramException("No query over the data source was specified.");
59 
60  var elementType = TypeSystem.GetElementType(expression.Type);
61 
62  IQueryable queryResult;
63 
64  var builder = new QueryBuilder();
65 
66  // Find the call to Where() and get the lambda expression predicate.
67  var whereFinder = new InnermostWhereFinder();
68  var whereExpression = whereFinder.GetInnermostWhere(expression);
69 
70  if (whereExpression == null) {
71  var query = builder.Build();
72  queryResult = query.Execute(elementType, Table).AsQueryable();
73  } else {
74  var lambdaExpression = (LambdaExpression)((UnaryExpression)(whereExpression.Arguments[1])).Operand;
75 
76  // Send the lambda expression through the partial evaluator.
77  lambdaExpression = (LambdaExpression)Evaluator.PartialEval(lambdaExpression);
78 
79  var query = builder.Build(lambdaExpression.Body);
80  queryResult = query.Execute(elementType, Table).AsQueryable();
81  }
82 
83  // Copy the expression tree that was passed in, changing only the first
84  // argument of the innermost MethodCallExpression.
85  var treeCopier = new ExpressionTreeModifier(queryResult, elementType);
86  var newExpressionTree = treeCopier.Visit(expression);
87 
88  // This step creates an IQueryable that executes by replacing Queryable methods with Enumerable methods.
89  if (isEnum)
90  return queryResult.Provider.CreateQuery(newExpressionTree);
91 
92  return queryResult.Provider.Execute(newExpressionTree);
93  }
static bool IsQueryOverDataSource(Expression expression)
TResult Deveel.Data.Linq.TableQueryProvider.Execute< TResult > ( Expression  expression)
inline

Definition at line 101 of file TableQueryProvider.cs.

101  {
102  bool isEnum = (typeof(TResult).Name == "IEnumerable`1");
103  return (TResult) Execute(expression, isEnum);
104  }
object Execute(Expression expression)
string Deveel.Data.Linq.TableQueryProvider.GetQueryText ( Expression  expression)
inline

Definition at line 106 of file TableQueryProvider.cs.

106  {
107  throw new NotImplementedException();
108  }
static bool Deveel.Data.Linq.TableQueryProvider.IsQueryOverDataSource ( Expression  expression)
inlinestaticprivate

Definition at line 95 of file TableQueryProvider.cs.

95  {
96  // If expression represents an unqueried IQueryable data source instance,
97  // expression is of type ConstantExpression, not MethodCallExpression.
98  return (expression is MethodCallExpression);
99  }

Property Documentation

ITable Deveel.Data.Linq.TableQueryProvider.Table
getprivate set

Definition at line 33 of file TableQueryProvider.cs.


The documentation for this class was generated from the following file: