/// <summary> /// Visits the field. /// </summary> /// <param name="model">The model.</param> public override void VisitField(FieldModel model) { FieldAttribute att = model.FieldAtt; if (AppliesToCurrentTable(att)) { WriteProperty(model.Field.Name, model.Field.FieldType, att.AccessString, att.ColumnType, att.Insert, att.Update, att.Formula, att.Column, att.Length, att.NotNull, att.Unique, att.UniqueKey, att.SqlType, att.Index, att.Check, att.Default); } }
/// <summary> /// Visits the field. /// </summary> /// <remarks> /// Infer column name and nullablity /// </remarks> /// <param name="model">The model.</param> public override void VisitField(FieldModel model) { if (model.FieldAtt.Column == null) { model.FieldAtt.Column = model.Field.Name; } // Append column prefix model.FieldAtt.Column = columnPrefix + model.FieldAtt.Column; Type fieldType = model.Field.FieldType; if (NHibernateNullablesSupport.IsNHibernateNullableType(fieldType) && (model.FieldAtt.ColumnType == null || model.FieldAtt.ColumnType.Length == 0)) { model.FieldAtt.NotNull = false; model.FieldAtt.ColumnType = NHibernateNullablesSupport.GetITypeTypeNameForNHibernateNullable(fieldType); } if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof (Nullable<>) && String.IsNullOrEmpty(model.FieldAtt.ColumnType)) { model.FieldAtt.NotNull = false; model.FieldAtt.ColumnType = ObtainNullableTypeNameForCLRNullable(fieldType); } JoinedTableModel joinedTable = ObtainJoinedTableIfPresent(model.Field, model.FieldAtt); if (joinedTable != null) { joinedTable.Fields.Add(model); } }
/// <summary> /// Visits the field. /// </summary> /// <param name="model">The model.</param> public virtual void VisitField(FieldModel model) { }
/// <summary> /// Visits the field. /// </summary> /// <param name="model">The model.</param> public override void VisitField(FieldModel model) { FieldAttribute att = model.FieldAtt; WriteProperty(model.Field.Name, model.Field.FieldType, att.AccessString, att.ColumnType, att.Insert, att.Update, att.Formula, att.Column, att.Length, att.NotNull, att.Unique, att.UniqueKey, att.SqlType, att.Index, att.Check); }
public bool CanHandle(FieldModel field) { return CanHandleType(field.Field.FieldType); }
public String CreateControl(ActiveRecordModel model, String prefix, FieldModel fieldModel, object instance) { stringBuilder.Length = 0; FieldInfo fieldInfo = fieldModel.Field; String propName = CreatePropName(model, prefix, fieldInfo.Name); if (fieldInfo.FieldType == typeof(DateTime)) { stringBuilder.Append(LabelFor(propName + "day", TextHelper.PascalCaseToWord(fieldInfo.Name) + ": ")); } else { stringBuilder.Append(LabelFor(propName, TextHelper.PascalCaseToWord(fieldInfo.Name) + ": ")); } FieldAttribute propAtt = fieldModel.FieldAtt; RenderAppropriateControl(model, fieldInfo.FieldType, propName, null, null, propAtt.Unique, propAtt.NotNull, propAtt.ColumnType, propAtt.Length); return stringBuilder.ToString(); }