From b84630abc5bc9fd93ccbdd21b0581ce5e141f665 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Thu, 8 Jul 2010 17:05:26 +0000 Subject: [PATCH] JoinSpec refactored --- Common/UploadManager.cs | 5 ++--- Common/dataobjects/Account.cs | 3 +-- Common/dataobjects/AccountIndicator.cs | 3 +-- Common/dataobjects/AccountSettings.cs | 3 +-- Common/dataobjects/Board.cs | 3 +-- Common/dataobjects/Category.cs | 6 ++---- Common/dataobjects/User.cs | 3 +-- Core/DB/JoinSpec.cs | 23 +++++++++++++++++++++-- 8 files changed, 30 insertions(+), 19 deletions(-) diff --git a/Common/UploadManager.cs b/Common/UploadManager.cs index 666c0a7..426cdf4 100644 --- a/Common/UploadManager.cs +++ b/Common/UploadManager.cs @@ -105,9 +105,8 @@ namespace FLocal.Common { Config.instance.mainConnection.LoadIdsByConditions( Upload.TableSpec.instance, condition, - Diapasone.unlimited, - new JoinSpec[0] - )[0] + Diapasone.unlimited + ).Single() ) ); } diff --git a/Common/dataobjects/Account.cs b/Common/dataobjects/Account.cs index 57b4f6f..fe54d0b 100644 --- a/Common/dataobjects/Account.cs +++ b/Common/dataobjects/Account.cs @@ -81,8 +81,7 @@ namespace FLocal.Common.dataobjects { ComparisonType.EQUAL, name ), - Diapasone.unlimited, - new JoinSpec[0] + Diapasone.unlimited ); if(ids.Count > 1) { throw new CriticalException("not unique"); diff --git a/Common/dataobjects/AccountIndicator.cs b/Common/dataobjects/AccountIndicator.cs index 4c2c7c2..fc20457 100644 --- a/Common/dataobjects/AccountIndicator.cs +++ b/Common/dataobjects/AccountIndicator.cs @@ -72,8 +72,7 @@ namespace FLocal.Common.dataobjects { ComparisonType.EQUAL, account.id.ToString() ), - Diapasone.unlimited, - new JoinSpec[0] + Diapasone.unlimited ); if(ids.Count > 1) { throw new CriticalException("not unique"); diff --git a/Common/dataobjects/AccountSettings.cs b/Common/dataobjects/AccountSettings.cs index 9864dc8..1eb289e 100644 --- a/Common/dataobjects/AccountSettings.cs +++ b/Common/dataobjects/AccountSettings.cs @@ -118,8 +118,7 @@ namespace FLocal.Common.dataobjects { ComparisonType.EQUAL, account.id.ToString() ), - Diapasone.unlimited, - new JoinSpec[0] + Diapasone.unlimited ); if(ids.Count > 1) { throw new CriticalException("not unique"); diff --git a/Common/dataobjects/Board.cs b/Common/dataobjects/Board.cs index df0b19c..08abe09 100644 --- a/Common/dataobjects/Board.cs +++ b/Common/dataobjects/Board.cs @@ -156,8 +156,7 @@ namespace FLocal.Common.dataobjects { FLocal.Core.DB.conditions.ComparisonType.EQUAL, this.id.ToString() ), - Diapasone.unlimited, - new JoinSpec[0] + Diapasone.unlimited ) select int.Parse(stringId); Board.LoadByIds(ids); return ids; diff --git a/Common/dataobjects/Category.cs b/Common/dataobjects/Category.cs index a7e0368..5a07c9c 100644 --- a/Common/dataobjects/Category.cs +++ b/Common/dataobjects/Category.cs @@ -54,8 +54,7 @@ namespace FLocal.Common.dataobjects { IEnumerable ids = from stringId in Config.instance.mainConnection.LoadIdsByConditions( TableSpec.instance, new FLocal.Core.DB.conditions.EmptyCondition(), - Diapasone.unlimited, - new JoinSpec[0] + Diapasone.unlimited ) select int.Parse(stringId); Category.LoadByIds(ids); return ids; @@ -84,8 +83,7 @@ namespace FLocal.Common.dataobjects { FLocal.Core.DB.conditions.ComparisonType.EQUAL, this.id.ToString() ), - Diapasone.unlimited, - new JoinSpec[0] + Diapasone.unlimited ) select int.Parse(stringId); Board.LoadByIds(ids); return ids; diff --git a/Common/dataobjects/User.cs b/Common/dataobjects/User.cs index 7220abc..37c3e16 100644 --- a/Common/dataobjects/User.cs +++ b/Common/dataobjects/User.cs @@ -133,8 +133,7 @@ namespace FLocal.Common.dataobjects { ComparisonType.EQUAL, name ), - Diapasone.unlimited, - new JoinSpec[0] + Diapasone.unlimited ); if(ids.Count > 1) { throw new CriticalException("not unique"); diff --git a/Core/DB/JoinSpec.cs b/Core/DB/JoinSpec.cs index 65dc034..0cf903c 100644 --- a/Core/DB/JoinSpec.cs +++ b/Core/DB/JoinSpec.cs @@ -6,13 +6,32 @@ using System.Text; namespace FLocal.Core.DB { public class JoinSpec { + private class TableSpec : ITableSpec { + private readonly string _name; + public TableSpec(string name) { + this._name = name; + } + public string name { + get { + return this._name; + } + } + public string idName { + get { + throw new NotImplementedException(); + } + } + } + public readonly ColumnSpec mainColumn; public readonly ITableSpec additionalTable; + public readonly ITableSpec additionalTableJoin; - public JoinSpec(ColumnSpec mainColumn, ITableSpec additionalTable) { + public JoinSpec(ColumnSpec mainColumn, ITableSpec additionalTable, string alias) { this.mainColumn = mainColumn; - this.additionalTable = additionalTable; + this.additionalTableJoin = additionalTable; + this.additionalTable = new TableSpec(alias); } }