internal JoinableCohortAggregateConfigurationUse(ICatalogueRepository repository, DbDataReader r)
            : base(repository, r)
        {
            ExtractionJoinType joinType;

            if (ExtractionJoinType.TryParse(r["JoinType"].ToString(), true, out joinType))
            {
                JoinType = joinType;
            }

            JoinableCohortAggregateConfiguration_ID = Convert.ToInt32(r["JoinableCohortAggregateConfiguration_ID"]);
            AggregateConfiguration_ID = Convert.ToInt32(r["AggregateConfiguration_ID"]);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor to be used to create already existing JoinInfos out of the database only.
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="r"></param>
        internal JoinInfo(IRepository repository, DbDataReader r) : base(repository, r)
        {
            ForeignKey_ID = Convert.ToInt32(r["ForeignKey_ID"]);
            PrimaryKey_ID = Convert.ToInt32(r["PrimaryKey_ID"]);

            Collation = r["Collation"] as string;

            ExtractionJoinType joinType;

            if (ExtractionJoinType.TryParse(r["ExtractionJoinType"].ToString(), true, out joinType))
            {
                ExtractionJoinType = joinType;
            }
            else
            {
                throw new Exception("Did not recognise ExtractionJoinType:" + r["ExtractionJoinType"]);
            }

            if (ForeignKey_ID == PrimaryKey_ID)
            {
                throw new Exception("Join key 1 and 2 are the same, lookup is broken");
            }
        }
Esempio n. 3
0
        internal Lookup(ICatalogueRepository repository, DbDataReader r)
            : base(repository, r)
        {
            Description_ID = int.Parse(r["Description_ID"].ToString());
            ForeignKey_ID  = int.Parse(r["ForeignKey_ID"].ToString());
            PrimaryKey_ID  = int.Parse(r["PrimaryKey_ID"].ToString());
            Collation      = r["Collation"] as string;

            ExtractionJoinType joinType;

            if (ExtractionJoinType.TryParse(r["ExtractionJoinType"].ToString(), true, out joinType))
            {
                ExtractionJoinType = joinType;
            }
            else
            {
                throw new Exception("Did not recognise ExtractionJoinType:" + r["ExtractionJoinType"]);
            }

            if (ForeignKey_ID == PrimaryKey_ID)
            {
                throw new ArgumentException("Join Key 1 and Join Key 2 cannot be the same");
            }
        }
Esempio n. 4
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 }
            });
        }
Esempio n. 5
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 }
            });
        }