Exemplo n.º 1
0
        Get_GetMembers_Computation(Dictionary <MemberInfo, SimpleType> memberQuerableTypes, SimpleType trackedType, MaterializationData data)
        {
            var members = new Dictionary <MemberInfo, KeyValuePair <Func <object, object>, Func <object, TableEntityRow, object> > >();

            foreach (var memberInfo in memberQuerableTypes.Keys)
            {
                members.Add(memberInfo, new KeyValuePair <Func <object, object>, Func <object, TableEntityRow, object> >
                                (trackedType.GetTranslatedMemberValue(memberInfo, entityContext._InternalServices.TypeTranslationUtil),
                                Get_GetOrCreateEntityOrCollection_Computation(memberQuerableTypes[memberInfo], data)));
            }
            return(members);
        }
Exemplo n.º 2
0
        private Func <object, object> Get_FindValueInTreeMatchingTrackedType_Computation(SimpleType sourceType, SimpleType trackedType)
        {
            if (sourceType == trackedType)
            {
                return(tableEntity => tableEntity);
            }

            foreach (var kvp in sourceType.GetAllMembers())
            {
                var memberGetter = Get_FindValueInTreeMatchingTrackedType_Computation(kvp.Value, trackedType);
                if (memberGetter != null)
                {
                    var translatedValueGetter = sourceType.GetTranslatedMemberValue(kvp.Key,
                                                                                    entityContext._InternalServices.TypeTranslationUtil);
                    return(tableEntity => memberGetter(translatedValueGetter(tableEntity)));
                }
            }

            if (sourceType.NonPrimitiveEnumerableItemType != null)
            {
                var collectionItemGetter = Get_FindValueInTreeMatchingTrackedType_Computation(sourceType.NonPrimitiveEnumerableItemType, trackedType);
                if (collectionItemGetter != null)
                {
                    return(tableEntity =>
                    {
                        var list = new List <object>();
                        foreach (var item in (tableEntity as IEnumerable))
                        {
                            list.Add(collectionItemGetter(item));
                        }
                        return list;
                    });
                }
            }

            return(null);
        }