From de1d5fd4a73c18f2a742997ce26000d2c36ff7e5 Mon Sep 17 00:00:00 2001 From: Daniel Cohen Gindi Date: Tue, 23 Oct 2018 19:28:11 +0300 Subject: [PATCH] Added "Subtract" to PhraseHelper --- dg.Sql/Sql/Phrases/{Aggregate => Math}/Add.cs | 0 dg.Sql/Sql/Phrases/Math/Subtract.cs | 122 +++++++ dg.Sql/Sql/Phrases/PhraseHelper.cs | 318 ++++++++++++------ dg.Sql/dg.Sql.csproj | 3 +- 4 files changed, 336 insertions(+), 107 deletions(-) rename dg.Sql/Sql/Phrases/{Aggregate => Math}/Add.cs (100%) create mode 100644 dg.Sql/Sql/Phrases/Math/Subtract.cs diff --git a/dg.Sql/Sql/Phrases/Aggregate/Add.cs b/dg.Sql/Sql/Phrases/Math/Add.cs similarity index 100% rename from dg.Sql/Sql/Phrases/Aggregate/Add.cs rename to dg.Sql/Sql/Phrases/Math/Add.cs diff --git a/dg.Sql/Sql/Phrases/Math/Subtract.cs b/dg.Sql/Sql/Phrases/Math/Subtract.cs new file mode 100644 index 00000000..da2f5e15 --- /dev/null +++ b/dg.Sql/Sql/Phrases/Math/Subtract.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Text; +using dg.Sql.Connector; + +namespace dg.Sql.Phrases +{ + public class Subtract : IPhrase + { + public ValueWrapper Value1; + public ValueWrapper Value2; + + #region Constructors + + public Subtract( + string tableName1, string columnName1, + string tableName2, string columnName2) + { + this.Value1 = new ValueWrapper(tableName1, columnName1); + this.Value2 = new ValueWrapper(tableName2, columnName2); + } + + public Subtract( + string tableName1, string columnName1, + object value2, ValueObjectType valueType2) + { + this.Value1 = new ValueWrapper(tableName1, columnName1); + this.Value2 = new ValueWrapper(value2, valueType2); + } + + public Subtract( + object value1, ValueObjectType valueType1, + string tableName2, string columnName2) + { + this.Value1 = new ValueWrapper(value1, valueType1); + this.Value2 = new ValueWrapper(tableName2, columnName2); + } + + public Subtract( + object value1, ValueObjectType valueType1, + object value2, ValueObjectType valueType2) + { + this.Value1 = new ValueWrapper(value1, valueType1); + this.Value2 = new ValueWrapper(value2, valueType2); + } + + public Subtract(string tableName1, string columnName1, Int32 value2) + { + this.Value1 = new ValueWrapper(tableName1, columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string tableName1, string columnName1, Int64 value2) + { + this.Value1 = new ValueWrapper(tableName1, columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string tableName1, string columnName1, decimal value2) + { + this.Value1 = new ValueWrapper(tableName1, columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string tableName1, string columnName1, double value2) + { + this.Value1 = new ValueWrapper(tableName1, columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string tableName1, string columnName1, float value2) + { + this.Value1 = new ValueWrapper(tableName1, columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string columnName1, Int32 value2) + { + this.Value1 = new ValueWrapper(columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string columnName1, Int64 value2) + { + this.Value1 = new ValueWrapper(columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string columnName1, decimal value2) + { + this.Value1 = new ValueWrapper(columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string columnName1, double value2) + { + this.Value1 = new ValueWrapper(columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + public Subtract(string columnName1, float value2) + { + this.Value1 = new ValueWrapper(columnName1); + this.Value2 = new ValueWrapper(value2, ValueObjectType.Value); + } + + #endregion + + public string BuildPhrase(ConnectorBase conn, Query relatedQuery = null) + { + string ret = @""; + + ret += Value1.Build(conn, relatedQuery); + + ret += @"-"; + + ret += Value2.Build(conn, relatedQuery); + + return ret; + } + } +} diff --git a/dg.Sql/Sql/Phrases/PhraseHelper.cs b/dg.Sql/Sql/Phrases/PhraseHelper.cs index e1c3bd70..e3119bfc 100644 --- a/dg.Sql/Sql/Phrases/PhraseHelper.cs +++ b/dg.Sql/Sql/Phrases/PhraseHelper.cs @@ -709,6 +709,218 @@ public static UnionAll UnionAll(params Query[] queries) #region Math + public static Add Add( + string tableName1, string columnName1, + string tableName2, string columnName2) + { + return new Add( + tableName1, columnName1, + tableName2, columnName2); + } + + public static Add Add( + string tableName1, string columnName1, + object value2, ValueObjectType valueType2) + { + return new Add( + tableName1, columnName1, + value2, valueType2); + } + + public static Add Add( + object value1, ValueObjectType valueType1, + string tableName2, string columnName2) + { + return new Add( + value1, valueType1, + tableName2, columnName2); + } + + public static Add Add( + object value1, ValueObjectType valueType1, + object value2, ValueObjectType valueType2) + { + return new Add( + value1, valueType1, + value2, valueType2); + } + + public static Add Add(string tableName1, string columnName1, Int32 value2) + { + return new Add( + tableName1, columnName1, + value2); + } + + public static Add Add(string tableName1, string columnName1, Int64 value2) + { + return new Add( + tableName1, columnName1, + value2); + } + + public static Add Add(string tableName1, string columnName1, decimal value2) + { + return new Add( + tableName1, columnName1, + value2); + } + + public static Add Add(string tableName1, string columnName1, double value2) + { + return new Add( + tableName1, columnName1, + value2); + } + + public static Add Add(string tableName1, string columnName1, float value2) + { + return new Add( + tableName1, columnName1, + value2); + } + + public static Add Add(string columnName1, Int32 value2) + { + return new Add( + columnName1, + value2); + } + + public static Add Add(string columnName1, Int64 value2) + { + return new Add( + columnName1, + value2); + } + + public static Add Add(string columnName1, decimal value2) + { + return new Add( + columnName1, + value2); + } + + public static Add Add(string columnName1, double value2) + { + return new Add( + columnName1, + value2); + } + + public static Add Add(string columnName1, float value2) + { + return new Add( + columnName1, + value2); + } + + public static Subtract Subtract( + string tableName1, string columnName1, + string tableName2, string columnName2) + { + return new Subtract( + tableName1, columnName1, + tableName2, columnName2); + } + + public static Subtract Subtract( + string tableName1, string columnName1, + object value2, ValueObjectType valueType2) + { + return new Subtract( + tableName1, columnName1, + value2, valueType2); + } + + public static Subtract Subtract( + object value1, ValueObjectType valueType1, + string tableName2, string columnName2) + { + return new Subtract( + value1, valueType1, + tableName2, columnName2); + } + + public static Subtract Subtract( + object value1, ValueObjectType valueType1, + object value2, ValueObjectType valueType2) + { + return new Subtract( + value1, valueType1, + value2, valueType2); + } + + public static Subtract Subtract(string tableName1, string columnName1, Int32 value2) + { + return new Subtract( + tableName1, columnName1, + value2); + } + + public static Subtract Subtract(string tableName1, string columnName1, Int64 value2) + { + return new Subtract( + tableName1, columnName1, + value2); + } + + public static Subtract Subtract(string tableName1, string columnName1, decimal value2) + { + return new Subtract( + tableName1, columnName1, + value2); + } + + public static Subtract Subtract(string tableName1, string columnName1, double value2) + { + return new Subtract( + tableName1, columnName1, + value2); + } + + public static Subtract Subtract(string tableName1, string columnName1, float value2) + { + return new Subtract( + tableName1, columnName1, + value2); + } + + public static Subtract Subtract(string columnName1, Int32 value2) + { + return new Subtract( + columnName1, + value2); + } + + public static Subtract Subtract(string columnName1, Int64 value2) + { + return new Subtract( + columnName1, + value2); + } + + public static Subtract Subtract(string columnName1, decimal value2) + { + return new Subtract( + columnName1, + value2); + } + + public static Subtract Subtract(string columnName1, double value2) + { + return new Subtract( + columnName1, + value2); + } + + public static Subtract Subtract(string columnName1, float value2) + { + return new Subtract( + columnName1, + value2); + } + public static Abs Abs(object value, ValueObjectType valueType, int decimalPlaces = 0) { return new Abs(value, valueType, decimalPlaces); @@ -1035,112 +1247,6 @@ public static Round Round(Where where) #region Aggregate - public static Add Add( - string tableName1, string columnName1, - string tableName2, string columnName2) - { - return new Add( - tableName1, columnName1, - tableName2, columnName2); - } - - public static Add Add( - string tableName1, string columnName1, - object value2, ValueObjectType valueType2) - { - return new Add( - tableName1, columnName1, - value2, valueType2); - } - - public static Add Add( - object value1, ValueObjectType valueType1, - string tableName2, string columnName2) - { - return new Add( - value1, valueType1, - tableName2, columnName2); - } - - public static Add Add( - object value1, ValueObjectType valueType1, - object value2, ValueObjectType valueType2) - { - return new Add( - value1, valueType1, - value2, valueType2); - } - - public static Add Add(string tableName1, string columnName1, Int32 value2) - { - return new Add( - tableName1, columnName1, - value2); - } - - public static Add Add(string tableName1, string columnName1, Int64 value2) - { - return new Add( - tableName1, columnName1, - value2); - } - - public static Add Add(string tableName1, string columnName1, decimal value2) - { - return new Add( - tableName1, columnName1, - value2); - } - - public static Add Add(string tableName1, string columnName1, double value2) - { - return new Add( - tableName1, columnName1, - value2); - } - - public static Add Add(string tableName1, string columnName1, float value2) - { - return new Add( - tableName1, columnName1, - value2); - } - - public static Add Add(string columnName1, Int32 value2) - { - return new Add( - columnName1, - value2); - } - - public static Add Add(string columnName1, Int64 value2) - { - return new Add( - columnName1, - value2); - } - - public static Add Add(string columnName1, decimal value2) - { - return new Add( - columnName1, - value2); - } - - public static Add Add(string columnName1, double value2) - { - return new Add( - columnName1, - value2); - } - - public static Add Add(string columnName1, float value2) - { - return new Add( - columnName1, - value2); - } - public static Avg Avg(object value, ValueObjectType valueType) { return new Avg(value, valueType); diff --git a/dg.Sql/dg.Sql.csproj b/dg.Sql/dg.Sql.csproj index d51d54d9..afb29924 100644 --- a/dg.Sql/dg.Sql.csproj +++ b/dg.Sql/dg.Sql.csproj @@ -90,6 +90,7 @@ + @@ -131,7 +132,7 @@ - +