<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>John Sheehan : Blog - Latest Comments in How I Use SubSonic, Part 2</title><link>http://justsayinmorewords.disqus.com/</link><description>A blog by John Sheehan</description><atom:link href="https://justsayinmorewords.disqus.com/how_i_use_subsonic_part_2/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 17 Apr 2009 12:30:00 -0000</lastBuildDate><item><title>Re: How I Use SubSonic, Part 2</title><link>http://johnsheehan.me/blog/how-i-use-subsonic-part-2/#comment-8298529</link><description>&lt;p&gt;Hi Hamed. You should submit an issue at &lt;br&gt;&lt;a href="http://code.google.com/p/subsonicproject" rel="nofollow noopener" target="_blank" title="http://code.google.com/p/subsonicproject"&gt;http://code.google.com/p/su...&lt;/a&gt; for that issue.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">John Sheehan</dc:creator><pubDate>Fri, 17 Apr 2009 12:30:00 -0000</pubDate></item><item><title>Re: How I Use SubSonic, Part 2</title><link>http://johnsheehan.me/blog/how-i-use-subsonic-part-2/#comment-8296043</link><description>&lt;p&gt;Thanks for your nice template&lt;/p&gt;&lt;p&gt;I was generating code using your proposed template for Repository Pattern against Oracle database 10.&lt;/p&gt;&lt;p&gt;The problem that I faced was that when you use tbl.ForeighnKeys to get the list of the foreign tables, it was not not working. This was due to a problem in GetTableSchema in OracleDataProvider. To be more specific, in the implementation of GetTableSchema for OracleDataProvider, when columns are retrieved, ForeignKeys property is not initialized and foreignkey tables are not added into it. Thus, when code generation is being done, it cannot find foreignkey tables to make the properties for them in the generated code. I suggest modify the GetTableSchema to the following one:&lt;/p&gt;&lt;p&gt;public override TableSchema.Table GetTableSchema(string tableName, TableType tableType)&lt;br&gt;        {&lt;br&gt;            TableSchema.TableColumnCollection columns = new TableSchema.TableColumnCollection();&lt;br&gt;            TableSchema.Table tbl = new TableSchema.Table(tableName, tableType, this);&lt;br&gt;            //tbl.ClassName = Convention.ClassName(tableName);&lt;br&gt;            //string sql = TABLE_COLUMN_SQL;&lt;br&gt;            QueryCommand cmd = new QueryCommand(TABLE_COLUMN_SQL, Name);&lt;br&gt;            cmd.AddParameter(TABLE_NAME_PARAMETER, tableName, DbType.AnsiString);&lt;br&gt;            TableSchema.TableColumn column;&lt;/p&gt;&lt;p&gt;            using(IDataReader rdr = DataService.GetReader(cmd))&lt;br&gt;            {&lt;br&gt;                //get information about both the table and it's columns                &lt;br&gt;                while(rdr.Read())&lt;br&gt;                {&lt;br&gt;                    tbl.SchemaName = rdr["USER"].ToString();&lt;/p&gt;&lt;p&gt;                    column = new TableSchema.TableColumn(tbl);&lt;br&gt;                    column.ColumnName = rdr[OracleSchemaVariable.COLUMN_NAME].ToString();&lt;/p&gt;&lt;p&gt;                    string scale = rdr[OracleSchemaVariable.NUMBER_SCALE].ToString();&lt;br&gt;                    string precision = rdr[OracleSchemaVariable.NUMBER_PRECISION].ToString();&lt;/p&gt;&lt;p&gt;                    column.NumberScale = 0;&lt;br&gt;                    column.NumberPrecision = 0;&lt;/p&gt;&lt;p&gt;                    if(!String.IsNullOrEmpty(scale) &amp;amp;&amp;amp; scale != "0")&lt;br&gt;                        column.NumberScale = int.Parse(scale);&lt;/p&gt;&lt;p&gt;                    if(!String.IsNullOrEmpty(precision) &amp;amp;&amp;amp; precision != "0")&lt;br&gt;                        column.NumberPrecision = int.Parse(precision);&lt;/p&gt;&lt;p&gt;                    // column.DataType = GetDbType(rdr[OracleSchemaVariable.DATA_TYPE].ToString().ToLower());&lt;br&gt;                    column.DataType = GetDbTypeOracle(rdr[OracleSchemaVariable.DATA_TYPE].ToString().ToLower(), column.NumberScale, column.NumberPrecision);&lt;br&gt;                    column.AutoIncrement = false;&lt;br&gt;                    int maxLength;&lt;br&gt;                    int.TryParse(rdr[OracleSchemaVariable.MAX_LENGTH].ToString(), out maxLength);&lt;br&gt;                    column.MaxLength = maxLength;&lt;br&gt;                    column.IsNullable = Utility.IsMatch(rdr[OracleSchemaVariable.IS_NULLABLE].ToString(), "Y");&lt;br&gt;                    column.IsReadOnly = false;&lt;br&gt;                    columns.Add(column);&lt;br&gt;                }&lt;br&gt;            }&lt;/p&gt;&lt;p&gt;            cmd.CommandSql = INDEX_SQL;&lt;br&gt;            //cmd.AddParameter(TABLE_NAME_PARAMETER, tableName);&lt;br&gt;            tbl.ForeignKeys = new TableSchema.ForeignKeyTableCollection();&lt;/p&gt;&lt;p&gt;            using(IDataReader rdr = DataService.GetReader(cmd))&lt;br&gt;            {&lt;br&gt;                while(rdr.Read())&lt;br&gt;                {&lt;br&gt;                    string colName = rdr[OracleSchemaVariable.COLUMN_NAME].ToString();&lt;br&gt;                    string constraintType = rdr[OracleSchemaVariable.CONSTRAINT_TYPE].ToString();&lt;br&gt;                    column = columns.GetColumn(colName);&lt;/p&gt;&lt;p&gt;                    if(constraintType == SqlSchemaVariable.PRIMARY_KEY)&lt;br&gt;                        column.IsPrimaryKey = true;&lt;br&gt;                    else if(constraintType == SqlSchemaVariable.FOREIGN_KEY)&lt;br&gt;                        column.IsForeignKey = true;&lt;/p&gt;&lt;p&gt;                    //HACK: Allow second pass naming adjust based on whether a column is keyed&lt;br&gt;                    column.ColumnName = column.ColumnName;&lt;/p&gt;&lt;p&gt;                    //Hamed&lt;/p&gt;&lt;p&gt;                    if (column.IsForeignKey)&lt;br&gt;                    {&lt;br&gt;                        TableSchema.ForeignKeyTable fkTable = new TableSchema.ForeignKeyTable(this);&lt;br&gt;                        TableSchema.Table ftbl = this.GetForeignKeyTable(column, tbl);&lt;br&gt;                        column.ForeignKeyTableName = ftbl.TableName;&lt;br&gt;                        fkTable.ColumnName = column.ColumnName;&lt;br&gt;                        fkTable.TableName = ftbl.TableName;&lt;/p&gt;&lt;p&gt;                        //not needed for now&lt;br&gt;                        //fkTable.PrimaryColumnName = drFK[i]["PK_Column"].ToString();&lt;br&gt;                        //fkTable.ForeignColumnName = drFK[i]["FK_Column"].ToString();&lt;/p&gt;&lt;p&gt;                        tbl.ForeignKeys.Add(fkTable);&lt;br&gt;                    }&lt;/p&gt;&lt;p&gt;                }&lt;br&gt;                rdr.Close();&lt;br&gt;            }&lt;br&gt;            if(columns.Count &amp;gt; 0)&lt;br&gt;            {&lt;br&gt;                tbl.Columns = columns;&lt;br&gt;                return tbl;&lt;br&gt;            }&lt;br&gt;            return null;&lt;br&gt;        }&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Hamed</dc:creator><pubDate>Fri, 17 Apr 2009 11:19:21 -0000</pubDate></item></channel></rss>