private static String GetPropName(ColumnSchema column, MemberOption option) { String result = column.Name; if (CSHelper.IsNotBlank(option.PrefixToTrim)) { result = CSHelper.StripPrefix(result, option.PrefixToTrim); } if (option.TrimTablePrefix) { string prefix = column.Table.Name; if (CSHelper.IsNotBlank(option.TablePrePrefix)) { prefix = CSHelper.StripPrefix(prefix, option.TablePrePrefix); } result = CSHelper.StripPrefix(result, prefix); } if (CSHelper.IsNotBlank(option.SuffixToTrim)) { result = CSHelper.StripSuffix(result, column.Table.Name); } if (option.TrimTableSuffix) { string suffix = column.Table.Name; if (CSHelper.IsNotBlank(option.TablePostSuffix)) { suffix = CSHelper.StripSuffix(suffix, option.TablePostSuffix.Trim()); } result = CSHelper.StripPrefix(result, suffix); } if (option.PropInPascalCase) { result = CSHelper.GetPascalCase(result); } result = CSHelper.GetCSharpIdentifier(result); return result; }
private static String GetVarName(String propName, MemberOption option) { String result = propName; if (option.VarInCamelCase) result = CSHelper.GetCamelCase(result); result = option.VarPrefix + result; return result; }
public ColumnInfo(ColumnSchema column, MemberOption memberOption, SqlOption sqlOption, IDbVendor dbVendor) { if (column == null) throw new ArgumentNullException("column"); if (memberOption == null) throw new ArgumentNullException("memberOption"); if (dbVendor == null) throw new ArgumentNullException("dbVendor"); //Assign parameters to member variables. m_Column = column; m_MemberOption = memberOption; m_SqlOption = sqlOption; m_DbVendor = dbVendor; m_ClrType = DbVendor.GetClrType(column, MemberOption.UseNullable); m_ClrPrimitiveType = Nullable.GetUnderlyingType(m_ClrType); m_ClrPrimitiveType = (m_ClrPrimitiveType != null) ? m_ClrPrimitiveType : m_ClrType; m_IsClrNullable = Nullable.GetUnderlyingType(m_ClrType) != null; //m_ClrTypeDecl = GetClrTypeDecl(m_ClrType); m_ClrTypeDecl = CSHelper.CSharpType(m_Column); m_IsLob = DbVendor.IsLob(Column); m_PropName = GetPropName(Column, MemberOption); m_VarName = GetVarName(PropName, MemberOption); m_ClrParamName = CSHelper.GetCamelCase(PropName); m_ClrParamDecl = ClrTypeDecl + " " + ClrParamName; m_InitialValueDecl = m_IsClrNullable ? " = null" : String.Empty; m_PropAccessDecl = CSHelper.GetMemberAccessName(MemberOption.PropAccess); m_VarAccessDecl = CSHelper.GetMemberAccessName(MemberOption.VarAccess); m_ProviderDbType = DbVendor.GetProviderDbType(Column); m_ProviderDbTypeName = DbVendor.GetProviderDbTypeName(m_ProviderDbType); m_IsExpilicit = DbVendor.IsExplicit(Column); m_ResultColumnName = Column.Name; m_SqlColumnName = DbVendor.QuotedStr(Column.Name); m_SqlQualifiedColumnName = DbVendor.QuotedStr(column.Table.Name) + "." + m_SqlColumnName; m_SqlInlineParameterMap = GetSqlInlineParameterMap(PropName, ClrTypeDecl, ProviderDbTypeName, IsExpilicit, SqlOption); m_SqlParameterClass = m_ClrPrimitiveType.Name; }