internal static string DetermineColumnName(IQueryBuilder query, string propertyName) { string[] properties = propertyName.Split('.'); string table = String.Empty; string column = String.Empty; TypeSchema schema = SchemaCache.Current.GetSchema(query.QueriedType); for (int i = 0; i < properties.Length; i++) { if (i == properties.Length - 1) { PropertySchema propertySchema = schema.FindPropertySchema(properties[i]); if (propertySchema != null) { column = String.Format(CultureInfo.CurrentCulture, query.Context.ColumnFormat, propertySchema.ColumnName); } else { ParentSchema parentSchema = schema.FindParentSchema(properties[i]); if (parentSchema != null) { column = String.Format(CultureInfo.CurrentCulture, query.Context.ColumnFormat, parentSchema.ColumnName); } else { throw new ObjectServerException(String.Format(CultureInfo.CurrentCulture, "Could not locate schema for {0}.{1}", schema.Type.FullName, properties[i])); } } table = String.Format(CultureInfo.CurrentCulture, query.Context.TableFormat, schema.TableName); } else { ParentSchema parentSchema = schema.FindParentSchema(properties[i]); if (parentSchema == null) { throw new ObjectServerException(String.Format(CultureInfo.CurrentCulture, "Could not locate schema for {0}.{1}", schema.Type.FullName, properties[i])); } schema = SchemaCache.Current.GetSchema(parentSchema.Property.PropertyType); query.AddParentJoin(parentSchema); } } return(String.Format(CultureInfo.CurrentCulture, query.Context.TableColumnFormat, table, column)); }