/// <summary> /// /// </summary> /// <param name="member"></param> /// <returns></returns> public override string GetColumnName(MemberInfo member) { // For each attribute for the member foreach (object attribute in member.DeclaringType.GetProperty(member.Name).GetCustomAttributes(true)) { // If the attribute is the nequeo datatable // attribute then get the table name. if (attribute is Nequeo.Data.Custom.DataColumnAttribute) { // Cast the current attribute. Nequeo.Data.Custom.DataColumnAttribute att = (Nequeo.Data.Custom.DataColumnAttribute)attribute; return(DataTypeConversion.GetSqlConversionDataType(_connectionDataType, att.ColumnName.TrimStart('_'))); } } return(member.Name); }
/// <summary> /// Get the translated foreign key reference data. /// </summary> /// <param name="property">The current property information</param> /// <param name="foreignKeyValue">The foreign key value for the referenced data entity.</param> /// <param name="data">The data column foreign key reference attribute data.</param> /// <returns>The translated data entity object.</returns> private object SetForeginKeyReferenceData(PropertyInfo property, object foreignKeyValue, Nequeo.Data.Custom.DataColumnForeignKeyAttribute data) { // Get the get method of the property. MethodInfo method = property.GetGetMethod(); string tableName = DataTypeConversion.GetSqlConversionDataType(dataContext.ProviderConnectionDataType, data.Name.TrimStart('_').Replace(".", "].[")); string colunmName = DataTypeConversion.GetSqlConversionDataType(dataContext.ProviderConnectionDataType, data.ReferenceColumnName.TrimStart('_')); DataTypeConversion dataTypeConversion = new DataTypeConversion(dataContext.ProviderConnectionDataType); // Execute the queryable provider and return the constructed // sql statement and return the data. string statement = dataTypeConversion.GetSqlStringValue(LinqTypes.GetDataType(data.ColumnType, dataContext.ProviderConnectionDataType), foreignKeyValue); DataTable table = dataContext.ExecuteQuery("SELECT * FROM " + tableName + " WHERE " + colunmName + " = " + statement); // Get the anonymous type translator from datarow // to the foreign key reference property return type. Nequeo.Data.Control.AnonymousTypeFunction typeFunction = new Nequeo.Data.Control.AnonymousTypeFunction(); return((table.Rows.Count > 0) ? typeFunction.TypeTranslator(table.Rows[0], method.ReturnType) : null); }
/// <summary> /// /// </summary> /// <param name="rowType"></param> /// <returns></returns> public override string GetTableName(Type rowType) { // Get the current member. MemberInfo member = rowType; // For each attribute for the member foreach (object attribute in member.GetCustomAttributes(true)) { // If the attribute is the nequeo datatable // attribute then get the table name. if (attribute is Nequeo.Data.Custom.DataTableAttribute) { // Cast the current attribute. Nequeo.Data.Custom.DataTableAttribute att = (Nequeo.Data.Custom.DataTableAttribute)attribute; return(DataTypeConversion.GetSqlConversionDataType(_connectionDataType, att.TableName.TrimStart('_').Replace(".", "].["))); } } // Return a null. return(this.Language.Quote(rowType.Name)); }