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); } if (attrs.PropertyEncryption != null) { FillMappingItemByEncryptionAttr(item, attrs.PropertyEncryption); } item.MemberInfo = mi; item.DeclaringType = mi.DeclaringType; items.Add(item); 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.ContainsKey(attr.DataFieldName) == false) { ORMappingItem item = new ORMappingItem(); item.PropertyName = sourceMI.Name; item.SubClassPropertyName = attr.SubPropertyName; item.MemberInfo = mi; item.DeclaringType = sourceMI.DeclaringType; 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); } } foreach (SubClassPropertyEncryptionAttribute attr in attrs.SubClassPropertyEncryptions) { ORMappingItem item = FindItemBySubClassPropertyName(attr.SubPropertyName, items); if (item != null) { FillMappingItemByEncryptionAttr(item, attr); } } return(items); }
private static void MergeMappingItems(ORMappingItemCollection dest, ORMappingItemCollection src) { foreach (ORMappingItem item in src) { if (dest.ContainsKey(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); }
/// <summary> /// 根据映射关系的中的对象类型来过滤 /// </summary> /// <param name="type"></param> /// <returns></returns> public ORMappingItemCollection FilterMappingInfoByDeclaringType(System.Type type) { ORMappingItemCollection result = new ORMappingItemCollection(); result.TableName = this.TableName; foreach (ORMappingItem item in this) { if (item.DeclaringType == type) { result.Add(item); } } return(result); }