DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
QueryConfigurationExtensions.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 
20 
21 namespace Deveel.Data.Sql.Fluid {
22  public static class QueryConfigurationExtensions {
23  public static IQueryConfiguration All(this IQueryConfiguration configuration) {
24  return configuration.All(true);
25  }
26 
27  public static IQueryConfiguration Distinct(this IQueryConfiguration configuration) {
28  return configuration.Distinct(true);
29  }
30 
31  public static ISelectListConfiguration Column(this ISelectListConfiguration configuration, ObjectName columnName) {
32  return Column(configuration, columnName, null);
33  }
34 
35  public static ISelectListConfiguration Column(this ISelectListConfiguration configuration, ObjectName columnName, string alias) {
36  return configuration.Expression(SqlExpression.Reference(columnName), alias);
37  }
38 
39  public static ISelectListConfiguration Column(this ISelectListConfiguration configuration, string columnName) {
40  return Column(configuration, columnName, null);
41  }
42 
43  public static ISelectListConfiguration Column(this ISelectListConfiguration configuration, string columnName, string alias) {
44  return configuration.Column(ObjectName.Parse(columnName), alias);
45  }
46 
47  public static ISelectListConfiguration Expression(this ISelectListConfiguration configuration, SqlExpression expression) {
48  return Expression(configuration, expression, null);
49  }
50 
51  public static ISelectListConfiguration Expression(this ISelectListConfiguration configuration, SqlExpression expression, string alias) {
52  return configuration.Item(x => x.Expression(expression).As(alias));
53  }
54 
55  public static IQueryConfiguration From(this IQueryConfiguration configuration, string tableName) {
56  return From(configuration, null, tableName);
57  }
58 
59  public static IQueryConfiguration From(this IQueryConfiguration configuration, string alias, string tableName) {
60  configuration.From(sources => sources.Table(ObjectName.Parse(tableName)).As(alias));
61  return configuration;
62  }
63  }
64 }
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
Definition: ObjectName.cs:139
The single COLUMN of a table in a database, handling the form of data that can be stored in a cell...
IQueryConfiguration From(Action< IFromSourceConfiguration > config)
static IQueryConfiguration Distinct(this IQueryConfiguration configuration)
static IQueryConfiguration From(this IQueryConfiguration configuration, string tableName)
IQueryConfiguration Distinct(bool flag)
Describes the name of an object within a database.
Definition: ObjectName.cs:44
ISelectListConfiguration Item(Action< ISelectItemConfiguration > config)
static ISelectListConfiguration Column(this ISelectListConfiguration configuration, string columnName)
static ISelectListConfiguration Expression(this ISelectListConfiguration configuration, SqlExpression expression, string alias)
IQueryConfiguration All(bool flag)
static SqlReferenceExpression Reference(ObjectName objectName)
static ISelectListConfiguration Column(this ISelectListConfiguration configuration, ObjectName columnName)
static ISelectListConfiguration Expression(this ISelectListConfiguration configuration, SqlExpression expression)
Defines the base class for instances that represent SQL expression tree nodes.
static ISelectListConfiguration Column(this ISelectListConfiguration configuration, string columnName, string alias)
static ISelectListConfiguration Column(this ISelectListConfiguration configuration, ObjectName columnName, string alias)
static IQueryConfiguration All(this IQueryConfiguration configuration)
static IQueryConfiguration From(this IQueryConfiguration configuration, string alias, string tableName)