Beispiel #1
0
        virtual public void InitializeDictionary()
        {
            conversionElements.Clear();

            // ac_table

            //
            #region Table Type
            Add(StrKeys.TableType, DbType);
            Add(StrKeys.tabletype, string.Format("{0}", DbType).ToLower());
            #endregion
            //
            #region Primary Key
            // see the primary key related tags below
            Add(StrKeys.PK, PrimaryKey);
            Add(StrKeys.pk, PrimaryKey == null ? string.Empty : PrimaryKey.ToLower());
            Add(StrKeys.PrimaryKey, PrimaryKey ?? string.Empty);
            Add(StrKeys.PrimaryKeyCleanC, PrimaryKey == null ? string.Empty : PrimaryKey.ToStringCapitolize().Clean());
            Add(StrKeys.primarykey, PrimaryKey == null ? string.Empty : PrimaryKey.ToLower());
            #endregion
            //
            #region TableName
            //
            Add(StrKeys.Name, Name);
            Add(StrKeys.Table, Name.Replace("-", "_"));

            try {
                Add(StrKeys.TableAlias, View != null ? View.Alias : Link != null ? Link.Alias : Name);
                Add(StrKeys._TableAlias, View != null ? View.Alias : Link != null ? Link.Alias : Name.Replace("-", "_"));
                Add(StrKeys.tablealias, (conversionElements[StrKeys.TableAlias] as string).ToLower());
                //
                Add(StrKeys.TableAliasC, conversionElements[StrKeys.TableAlias].ToStringCapitolize());
                Add(StrKeys.FriendlyTableAlias, (conversionElements[StrKeys.TableAlias] as string).Clean());
                Add(StrKeys.TableAliasClean, conversionElements[StrKeys.FriendlyTableAlias]);
                Add(StrKeys.tablealiasclean, (conversionElements[StrKeys.TableAlias] as string).ToLower());
                Add(StrKeys.TableAliasCClean, conversionElements[StrKeys.TableAlias].ToStringCapitolize());
                Add(StrKeys.TABLEALIASCLEAN, (conversionElements[StrKeys.TableAlias] as string).ToUpper());
                //
//				Add("AliasCClean", conversionElements["FriendlyAlias"].ToStringCapitolize());
                //
                Add(StrKeys.TableAliasCName, (conversionElements[StrKeys.TableAlias] as string).Clean());
                Add(StrKeys.TableAliasCNameC, (conversionElements[StrKeys.TableAliasCName] as string).ToStringCapitolize());
            } catch (Exception error) {
                Logger.Warn("Parse Exception", error.Message);
            }

            //
            Add(StrKeys.TableName, Name);
            Add(StrKeys.tablename, Name.ToLower());
            //
            Add(StrKeys.TableNameC, Name.ToStringCapitolize());
            Add(StrKeys.TableNameClean, FriendlyName);
            Add(StrKeys.tablenameclean, FriendlyName.ToLower());
            Add(StrKeys.TableNameCClean, FriendlyName.ToStringCapitolize());
            //
            Add(StrKeys.TableCleanName, Name.Clean());
            Add(StrKeys.TableCleanNameC, Name.Clean().ToStringCapitolize());
            #endregion
            //
            #region Namespace Types
            Add(StrKeys.AdapterNs, NsAdapter);
            Add(StrKeys.AdapterT, TAdapter);
            Add(StrKeys.AdapterNsT, TypeAdapter);
            //
            Add(StrKeys.CommandNs, NsCommand);
            Add(StrKeys.CommandT, TCommand);
            Add(StrKeys.CommandNsT, TypeCommand);
            //
            Add(StrKeys.ConnectionNs, NsConnection);
            Add(StrKeys.ConnectionT, TConnection);
            Add(StrKeys.ConnectionNsT, TypeConnection);
            //
            Add(StrKeys.ParameterT, TParameter);
            //
            Add(StrKeys.ReaderNs, NsReader);
            Add(StrKeys.ReaderT, TReader);
            Add(StrKeys.ReaderNsT, TypeReader);
            #endregion
            //
            GeneratorTypeProvider.GetTypes <GeneratorDateTimeFieldProvider>(conversionElements);

            #region Primary Key Automated Reference (NOT FOR VIEWS)
            //
            if (PrimaryKey == null)
            {
                ErrorMessage.Show("Table must provide a primary key", "Please check the table.");
                return;
            }
            else if (PrimaryKey != string.Empty && PrimaryKey != "%PKUNKNOWN%")
            {
                Add(StrKeys.PKDataName, PrimaryKeyElement.DataName);
                Add(StrKeys.PKDataType, PrimaryKeyElement.DataType);
                Add(StrKeys.PKDataTypeNative, PrimaryKeyElement.DataTypeNative);
                Add(StrKeys.PKNativeNullType, NullableTypeUtility.GetNativeNullType(PrimaryKeyElement[StrKeys.Native].ToString()));
                Add(StrKeys.PKNativeIsNullable, PrimaryKeyElement.IsNullable);
                Add(StrKeys.PKNativeNullValue, NullableTypeUtility.IsNativeNullable(PrimaryKeyElement[StrKeys.Native].ToString()) ? ".Value" : "");
                Add(StrKeys.PKNativeNullValueGo, PrimaryKeyElement.Params[StrKeys.NativeNullTypeGo].ToString());
                Add(StrKeys.PKNativeNullValueGoAddress, PrimaryKeyElement.IsNullable ? "&" : string.Empty);
                Add(StrKeys.PKNativeNullValueGoPointer, PrimaryKeyElement.IsNullable ? "*" : string.Empty);
//				Add("PKDataTypeNative",PrimaryKeyElement.DataTypeNative);
                Add(StrKeys.PKDescription, PrimaryKeyElement.Description);
                //
                Add(StrKeys.PKDataNameC, PrimaryKeyElement.DataName.ToStringCapitolize());
                Add(StrKeys.PKCleanName, PrimaryKeyElement.DataName.Replace("-", "_"));
                Add(StrKeys.PKCleanName_Nodash, PrimaryKeyElement.DataName.Clean());
                Add(StrKeys.PKFriendlyName, PrimaryKeyElement.DataName.Clean());
                Add(StrKeys.PKFriendlyNameC, PrimaryKeyElement.DataName.Clean().ToStringCapitolize());
            }
            else
            {
                Logger.Warn("TableElement.InitializeDictionary", Gen.Messages.TableElement_PrimaryKeyNotFound, Name);
            }
            #endregion

            if (Transform != null)
            {
                Transform(conversionElements);
            }
        }