@@ -118,7 +118,7 @@ public DynamicModel(string connectionStringName, string tableName = "",
118118 string primaryKeyField = "" , string descriptorField = "" , string sequence = "" ) {
119119 TableName = tableName == "" ? this . GetType ( ) . Name : tableName ;
120120 PrimaryKeyField = string . IsNullOrEmpty ( primaryKeyField ) ? "ID" : primaryKeyField ;
121-
121+ DescriptorField = descriptorField ;
122122 _sequence = sequence == "" ? ConfigurationManager . AppSettings [ "default_seq" ] : sequence ;
123123 _factory = DbProviderFactories . GetFactory ( "System.Data.OracleClient" ) ;
124124 if ( ConfigurationManager . ConnectionStrings [ connectionStringName ] == null )
@@ -177,12 +177,7 @@ public dynamic Prototype {
177177 return result ;
178178 }
179179 }
180- private string _descriptorField ;
181- public string DescriptorField {
182- get {
183- return _descriptorField ;
184- }
185- }
180+ public string DescriptorField { get ; protected set ; }
186181 /// <summary>
187182 /// List out all the schema bits for use with ... whatever
188183 /// </summary>
@@ -369,7 +364,9 @@ public virtual IDictionary<string, object> KeyValues(string orderBy = "") {
369364 var sql = string . Format ( "SELECT {0},{1} FROM {2} " , PrimaryKeyField , DescriptorField , TableName ) ;
370365 if ( ! String . IsNullOrEmpty ( orderBy ) )
371366 sql += "ORDER BY " + orderBy ;
372- return ( IDictionary < string , object > ) Query ( sql ) ;
367+
368+ var results = Query ( sql ) . ToList ( ) . Cast < IDictionary < string , object > > ( )
369+ return results. ToDictionary ( key => key [ PrimaryKeyField ] . ToString ( ) , value => value [ DescriptorField ] ) ;
373370 }
374371
375372 /// <summary>
0 commit comments