DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
DeveelDbLanguage.cs
Go to the documentation of this file.
1 using System;
2 using System.Linq.Expressions;
3 using System.Reflection;
4 
5 using IQToolkit;
6 using IQToolkit.Data.Common;
7 
8 namespace Deveel.Data.Linq {
9  class DeveelDbLanguage : QueryLanguage {
10  private readonly DeveelDbTypeSystem typeSystem;
11 
12  public DeveelDbLanguage() {
13  typeSystem = new DeveelDbTypeSystem();
14  }
15 
16  public override Expression GetGeneratedIdExpression(MemberInfo member) {
17  // TODO: Get the mapped table name corresponding to the type reflecting
18  // the member, to invoke the function "LAST_UNIKE_KEY('table_name')"
19  string tableName = "";
20  var args = new Expression[] {Expression.Constant(tableName, typeof (string))};
21  return new FunctionExpression(TypeHelper.GetMemberType(member), "last_unique_key", args);
22  }
23 
24  public override QueryTypeSystem TypeSystem {
25  get { return typeSystem; }
26  }
27 
28  public override QueryLinguist CreateLinguist(QueryTranslator translator) {
29  return new DeveelDbLinguist(this, translator);
30  }
31 
32  #region DeveelDbLinguist
33 
34  class DeveelDbLinguist : QueryLinguist {
35  public DeveelDbLinguist(DeveelDbLanguage language, QueryTranslator translator)
36  : base(language, translator) {
37  }
38 
39  public override Expression Translate(Expression expression) {
40  // fix up any order-by's
41  expression = OrderByRewriter.Rewrite(Language, expression);
42  expression = base.Translate(expression);
43  expression = UnusedColumnRemover.Remove(expression);
44 
45  return expression;
46  }
47 
48  public override string Format(Expression expression) {
49  return DeveelDbFormatter.Format(expression);
50  }
51  }
52 
53  #endregion
54  }
55 }
readonly DeveelDbTypeSystem typeSystem
static new string Format(Expression expression)
override Expression GetGeneratedIdExpression(MemberInfo member)
override string Format(Expression expression)
override QueryLinguist CreateLinguist(QueryTranslator translator)
override Expression Translate(Expression expression)
DeveelDbLinguist(DeveelDbLanguage language, QueryTranslator translator)