コード例 #1
0
ファイル: MappingItem.cs プロジェクト: yuzukwok/disconf.net
		public MappingItem(Field field, Method setterMethod, Method getterMethod, Table.ColumnStyle columnStyle, bool columnsModified)
		{
			this.field = field;
			this.getter = getterMethod;
			this.setter = setterMethod;

			// 获取字段的注解,如果没有,则从getter或者setter上获取注解
			Column column = getColumnAnnotation(field, setter, getter);

			// 如果数据库映射字段不为空,则按照映射关系设置字段
			if (column == null)
			{
				// generate column name by ColumnStyle
				// 1:to lower case(default);2:camel to underscores;3:and may be
				// others
				this.dbColumn = columnStyle.convert(field.Name);
				modifiable = columnsModified;
			}
			else if (column.value().Equals("ignore") || column.ignore())
			{
				// ignore
				// 当annotation为ignore时,dbColumn的value为null,这时表示这个MappingItem是一个无效的item
			}
			else
			{
				this.dbColumn = column.value();
				modifiable = column.maybeModified();
			}
		}