src/EntityFramework/Core/Mapping/FunctionImportMappingComposableHelper.cs
// <summary>
// Attempts to infer key columns of the target function based on the function import mapping.
// </summary>
Attempts to infer key columns of the target function based on the function import mapping.
Attempts to infer key columns of the target function based on the function import mapping .
private static bool TryInferTVFKeys(
            List<Tuple<StructuralType, List<ConditionPropertyMapping>, List<PropertyMapping>>> structuralTypeMappings,
            out EdmProperty[] keys)
        {
            keys = null;
            Debug.Assert(structuralTypeMappings.Count > 0, "Function import returning entities must have non-empty structuralTypeMappings.");
            foreach (var typeMapping in structuralTypeMappings)
            {
                EdmProperty[] currentKeys;
                if (!TryInferTVFKeysForEntityType((EntityType)typeMapping.Item1, typeMapping.Item3, out currentKeys))
                {
                    keys = null;
                    return false;
                }
                if (keys == null)
                {
                    keys = currentKeys;
                }
                else
                {
                    Debug.Assert(keys.Length == currentKeys.Length, "All subtypes must have the same number of keys.");
                    for (var i = 0; i < keys.Length; ++i)
                    {
                        if (!keys[i].EdmEquals(currentKeys[i]))
                        {
                            keys = null;
                            return false;
                        }
                    }
                }
            }
            for (var i = 0; i < keys.Length; ++i)
            {
                if (keys[i].Nullable)
                {
                    keys = null;
                    return false;
                }
            }
            return true;
        }
private static bool TryInferTVFKeys ( List < Tuple < StructuralType , List < ConditionPropertyMapping > , List < PropertyMapping > > > structuralTypeMappings , out EdmProperty [ ] keys ) { keys = null ; Debug . Assert ( structuralTypeMappings . Count > 0 , " " ) ; foreach ( var typeMapping in structuralTypeMappings ) { EdmProperty [ ] currentKeys ; if ( ! TryInferTVFKeysForEntityType ( ( EntityType ) typeMapping . Item1 , typeMapping . Item3 , out currentKeys ) ) { keys = null ; return false ; } if ( keys == null ) { keys = currentKeys ; } else { Debug . Assert ( keys . Length == currentKeys . Length , " " ) ; for ( var i = 0 ; i < keys . Length ; ++ i ) { if ( ! keys [ i ] . EdmEquals ( currentKeys [ i ] ) ) { keys = null ; return false ; } } } } for ( var i = 0 ; i < keys . Length ; ++ i ) { if ( keys [ i ] . Nullable ) { keys = null ; return false ; } } return true ; }
Attempts to infer key columns of the target function based on the function import mapping.
Attempts to infer key columns of the target function based on the function import mapping .
// Make sure all keys are mapped to the same columns. // Make sure columns are non-nullable, otherwise it shouldn't be considered a key.
structuralTypeMappings
List<Tuple<StructuralType, List<ConditionPropertyMapping>, List<PropertyMapping>>>
EdmProperty[]
out