Beispiel #1
0
        /// <summary>
        /// Declares that the columns provide form a foreign key join to lookup table relationship
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="description">The lookup table description column</param>
        /// <param name="foreignKey">The main dataset column that joins to the lookup e.g. Prescribing.DrugCode</param>
        /// <param name="primaryKey">The lookup table column that contains the code e.g. z_DrugLookup.Code</param>
        /// <param name="type"></param>
        /// <param name="collation"></param>
        public Lookup(ICatalogueRepository repository, ColumnInfo description, ColumnInfo foreignKey, ColumnInfo primaryKey, ExtractionJoinType type, string collation)
        {
            //do checks before it hits the database.
            if (foreignKey.ID == primaryKey.ID)
            {
                throw new ArgumentException("Join Key 1 and Join Key 2 cannot be the same");
            }

            if (foreignKey.TableInfo_ID == primaryKey.TableInfo_ID)
            {
                throw new ArgumentException("Join Key 1 and Join Key 2 are from the same table, this is not cool");
            }

            if (description.TableInfo_ID != primaryKey.TableInfo_ID)
            {
                throw new ArgumentException("Join Key 2 must be in the same table as the Description ColumnInfo (i.e. Primary Key)");
            }

            if (description.ID == primaryKey.ID)
            {
                throw new ArgumentException("Description Column and PrimaryKey Column cannot be the same column!");
            }

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Description_ID", description.ID },
                { "ForeignKey_ID", foreignKey.ID },
                { "PrimaryKey_ID", primaryKey.ID },
                { "ExtractionJoinType", type.ToString() },
                { "Collation", string.IsNullOrWhiteSpace(collation) ? DBNull.Value : (object)collation }
            });
        }
Beispiel #2
0
        public JoinInfo(ICatalogueRepository repository, ColumnInfo foreignKey, ColumnInfo primaryKey, ExtractionJoinType type, string collation)
        {
            if (foreignKey.ID == primaryKey.ID)
            {
                throw new ArgumentException("Joink Key 1 and Join Key 2 cannot be the same");
            }

            if (foreignKey.TableInfo_ID == primaryKey.TableInfo_ID)
            {
                throw new ArgumentException("Joink Key 1 and Join Key 2 are from the same table, this is not cool");
            }

            repository.InsertAndHydrate(this, new Dictionary <string, object>()
            {
                { "ForeignKey_ID", foreignKey.ID },
                { "PrimaryKey_ID", primaryKey.ID },
                { "ExtractionJoinType", type.ToString() },
                { "Collation", collation }
            });
        }