public static IEnumerable <CommonProperty> GetCommonProperties(Type sourceType, Type targetType) { string key = sourceType.ToString() + targetType.ToString(); if (!PropertyCache.CommonPropertyDictionary.ContainsKey(key)) { lock (syncCommon) { if (!PropertyCache.CommonPropertyDictionary.ContainsKey(key)) //双重检查 { PropertyInfo[] sourceTypeProperties = PropertyCache.GetPropertyInfoArray(sourceType); //获取源对象所有属性 PropertyInfo[] targetTypeProperties = PropertyCache.GetPropertyInfoArray(targetType); //获取目标对象所有属性 return(from SP in sourceTypeProperties join TP in targetTypeProperties on SP.Name.ToLower() equals TP.Name.ToLower() //根据属性名进行对应(不区分大小写) select new CommonProperty { SourceProperty = SP, TargetProperty = TP }); } } } return(PropertyCache.CommonPropertyDictionary[key]); }