From ac72f6bdf00291a881665fd8c341490010012cfc Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 05:44:56 +0100 Subject: [PATCH] Continued refactoring of Db class --- Basic/DbColumnAwareBase.cs | 10 ++++++++++ Common/Attributes/DbColumnName.cs | 2 +- Common/Attributes/DbColumnTypeName.cs | 24 ++++++++++++++++++++++++ Common/Attributes/DbIdentity.cs | 14 ++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Common/Attributes/DbColumnTypeName.cs create mode 100644 Common/Attributes/DbIdentity.cs diff --git a/Basic/DbColumnAwareBase.cs b/Basic/DbColumnAwareBase.cs index 12c28213..3d58ba96 100644 --- a/Basic/DbColumnAwareBase.cs +++ b/Basic/DbColumnAwareBase.cs @@ -47,5 +47,15 @@ namespace Swarmops.Basic // every class that derives from DbColumnAwareBase ; } + + /* + * + * sample SELECT sequence: + * private const string financialAccountDocumentFieldSequence = + " FinancialAccountDocumentId,FinancialAccountId,FinancialAccountDocumentTypes.Name,UploadedDateTime,UploadedByPersonId, " + // 0-4 + " ConcernsPeriodStart,ConcernsPeriodEnd,RawDocumentText " + // 5-7 + " FROM FinancialAccountDocuments JOIN FinancialAccountDocumentTypes USING (FinancialAccountDocumentTypeId) "; + + */ } } diff --git a/Common/Attributes/DbColumnName.cs b/Common/Attributes/DbColumnName.cs index 836d054c..5b04cb1e 100644 --- a/Common/Attributes/DbColumnName.cs +++ b/Common/Attributes/DbColumnName.cs @@ -18,7 +18,7 @@ namespace Swarmops.Common.Attributes { public DbColumnName() { - // means the column name is the same as the property name that houses the attribute + // empty attr means the column name is the same as the property name that houses the attribute this.ColumnName = string.Empty; } public DbColumnName(string columnName) diff --git a/Common/Attributes/DbColumnTypeName.cs b/Common/Attributes/DbColumnTypeName.cs new file mode 100644 index 00000000..f4897130 --- /dev/null +++ b/Common/Attributes/DbColumnTypeName.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; + +namespace Swarmops.Common.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class DbColumnForeignTypeName: Attribute + { + public DbColumnForeignTypeName(string foreignTableName, string commonIdColumnName, string foreignTypeColumnName) + { + this.ForeignTableName = foreignTableName; + this.CommonIdColumnName = commonIdColumnName; + this.ForeignTypeColumnName = foreignTypeColumnName; + } + + public string ForeignTableName { get; private set; } + public string CommonIdColumnName { get; private set; } + public string ForeignTypeColumnName { get; private set; } + } +} diff --git a/Common/Attributes/DbIdentity.cs b/Common/Attributes/DbIdentity.cs new file mode 100644 index 00000000..9b64aac1 --- /dev/null +++ b/Common/Attributes/DbIdentity.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Swarmops.Common.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class DbIdentity: Attribute + { + public DbIdentity() { } + } +}