private static ORMappingItemCollection GetMappingItems(RelativeAttributes attrs, MemberInfo mi) { ORMappingItemCollection items = new ORMappingItemCollection(); ORMappingItem item = new ORMappingItem(); item.PropertyName = mi.Name; item.DataFieldName = mi.Name; if (attrs.FieldMapping != null) { FillMappingItemByAttr(item, attrs.FieldMapping); } if (attrs.SqlBehavior != null) { FillMappingItemByBehaviorAttr(item, attrs.SqlBehavior); } item.MemberInfo = mi; items.Add(item); return(items); }
private static void MergeMappingItems(ORMappingItemCollection dest, ORMappingItemCollection src) { foreach (ORMappingItem item in src) { if (dest.Contains(item.DataFieldName) == false) { dest.Add(item); } } }
/// <summary> /// 复制Mapping的集合 /// </summary> /// <returns></returns> public ORMappingItemCollection Clone() { ORMappingItemCollection items = new ORMappingItemCollection(); items.tableName = this.tableName; foreach (ORMappingItem item in this) { items.Add(item.Clone()); } return(items); }
private static ORMappingItemCollection GetMappingItemsBySubClass(RelativeAttributes attrs, MemberInfo sourceMI) { ORMappingItemCollection items = new ORMappingItemCollection(); System.Type subType = attrs.SubClassType != null ? attrs.SubClassType.Type : GetRealType(sourceMI); MemberInfo[] mis = GetTypeMembers(subType); foreach (SubClassORFieldMappingAttribute attr in attrs.SubClassFieldMappings) { MemberInfo mi = GetMemberInfoByName(attr.SubPropertyName, mis); if (mi != null) { if (items.Contains(attr.DataFieldName) == false) { ORMappingItem item = new ORMappingItem(); item.PropertyName = sourceMI.Name; item.SubClassPropertyName = attr.SubPropertyName; item.MemberInfo = mi; if (attrs.SubClassType != null) { item.SubClassTypeDescription = attrs.SubClassType.TypeDescription; } FillMappingItemByAttr(item, attr); items.Add(item); } } } foreach (SubClassSqlBehaviorAttribute attr in attrs.SubClassFieldSqlBehaviors) { ORMappingItem item = FindItemBySubClassPropertyName(attr.SubPropertyName, items); if (item != null) { FillMappingItemByBehaviorAttr(item, attr); } } return(items); }