Ejemplo n.º 1
0
 /// <summary>
 /// Search for a Mapping metadata with the specified type key.
 /// </summary>
 /// <param name="identity">identity of the type</param>
 /// <param name="typeSpace">The dataspace that the type for which map needs to be returned belongs to</param>
 /// <param name="ignoreCase">true for case-insensitive lookup</param>
 /// <param name="map"></param>
 /// <returns>Returns false if no match found.</returns>
 internal virtual bool TryGetMap(string identity, DataSpace typeSpace, bool ignoreCase, out Map map)
 {
     //will only be implemented by Mapping Item Collections
     throw System.Data.Entity.Error.NotSupported();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Given a map, dereference the EdmItem, ensure that it is
 /// an EdmType and return a TypeUsage for the type, otherwise
 /// return null.
 /// </summary>
 /// <param name="map">The OC map to use to get the EdmType</param>
 /// <returns>A TypeUsage for the mapped EdmType or null if no EdmType was mapped</returns>
 private static TypeUsage GetMappedTypeUsage(Map map)
 {
     TypeUsage typeUsage = null;
     if (null != map)
     {
         MetadataItem item = map.EdmItem;
         EdmType edmItem = item as EdmType;
         if (null != item && edmItem!=null)
         {
             typeUsage = TypeUsage.Create(edmItem);
         }
     }
     return typeUsage;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Search for a Mapping metadata with the specified type key.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="map"></param>
 /// <returns>Returns false if no match found.</returns>
 internal virtual bool TryGetMap(GlobalItem item, out Map map)
 {
     //will only be implemented by Mapping Item Collections
     throw System.Data.Entity.Error.NotSupported();
 }
        /// <summary>
        /// Search for a Mapping metadata with the specified type key.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="map"></param>
        /// <returns>Returns false if no match found.</returns>
        internal override bool TryGetMap(GlobalItem item, out Map map)
        {
            if (item == null)
            {
                map = null;
                return false;
            }

            DataSpace typeSpace = item.DataSpace;

            //For transient types just create a map on fly and return
            EdmType edmType = item as EdmType;
            if (edmType != null)
            {
                if (Helper.IsTransientType(edmType))
                {
                    map = GetOCMapForTransientType(edmType, typeSpace);
                    if (map != null)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            return this.TryGetMap(item.Identity, typeSpace, out map);
        }
        /// <summary>
        /// Search for a Mapping metadata with the specified type key.
        /// </summary>
        /// <param name="identity">identity of the type</param>
        /// <param name="typeSpace">The dataspace that the type for which map needs to be returned belongs to</param>
        /// <param name="ignoreCase">true for case-insensitive lookup</param>
        /// <param name="map"></param>
        /// <returns>Returns false if no match found.</returns>
        internal override bool TryGetMap(string identity, DataSpace typeSpace, bool ignoreCase, out Map map)
        {
            EdmType cdmType = null;
            EdmType clrType = null;
            if (typeSpace == DataSpace.CSpace)
            {
                if (ignoreCase)
                {
                    // Get the correct casing of the identity first if we are asked to do ignore case
                    if (!m_edmCollection.TryGetItem<EdmType>(identity, true, out cdmType))
                    {
                        map = null;
                        return false;
                    }

                    identity = cdmType.Identity;
                }

                int index;
                if (cdmTypeIndexes.TryGetValue(identity, out index))
                {
                    map = (Map)this[index];
                    return true;
                }

                if (cdmType != null ||
                    m_edmCollection.TryGetItem<EdmType>(identity, ignoreCase, out cdmType))
                {
                    // If the mapping is not already loaded, then get the mapping ospace type
                    m_objectCollection.TryGetOSpaceType(cdmType, out clrType);
                }
            }
            else if (typeSpace == DataSpace.OSpace)
            {
                if (ignoreCase)
                {
                    // Get the correct casing of the identity first if we are asked to do ignore case
                    if (!m_objectCollection.TryGetItem<EdmType>(identity, true, out clrType))
                    {
                        map = null;
                        return false;
                    }

                    identity = clrType.Identity;
                }

                int index;
                if (clrTypeIndexes.TryGetValue(identity, out index))
                {
                    map = (Map)this[index];
                    return true;
                }

                if (clrType != null ||
                    m_objectCollection.TryGetItem<EdmType>(identity, ignoreCase, out clrType))
                {
                    // If the mapping is not already loaded, get the mapping cspace type
                    string cspaceTypeName = ObjectItemCollection.TryGetMappingCSpaceTypeIdentity(clrType);
                    m_edmCollection.TryGetItem<EdmType>(cspaceTypeName, out cdmType);
                }
            }

            if ((clrType == null) || (cdmType == null))
            {
                map = null;
                return false;
            }
            else
            {
                map = this.GetDefaultMapping(cdmType, clrType);
                return true;
            }
        }
 /// <summary>
 /// Search for a Mapping metadata with the specified type key.
 /// </summary>
 /// <param name="identity">identity of the type</param>
 /// <param name="typeSpace">The dataspace that the type for which map needs to be returned belongs to</param>
 /// <param name="map"></param>
 /// <returns>Returns false if no match found.</returns>
 internal override bool TryGetMap(string identity, DataSpace typeSpace, out Map map)
 {
     return this.TryGetMap(identity, typeSpace, false /*ignoreCase*/, out map);
 }
 // Add to the cache. If it is already present, then throw an exception
 private void AddInternal(Map storageMap)
 {
     storageMap.DataSpace = DataSpace.CSSpace;
     try
     {
         base.AddInternal(storageMap);
     }
     catch (ArgumentException e)
     {
         throw new MappingException(System.Data.Entity.Strings.Mapping_Duplicate_Type(storageMap.EdmItem.Identity), e);
     }
 }
 /// <summary>
 /// Search for a Mapping metadata with the specified type key.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="map"></param>
 /// <returns>Returns false if no match found.</returns>
 internal override bool TryGetMap(GlobalItem item, out Map map)
 {
     if (item == null)
     {
         map = null;
         return false;
     }
     DataSpace typeSpace = item.DataSpace;
     if (typeSpace != DataSpace.CSpace)
     {
         map = null;
         return false;
     }
     return this.TryGetMap(item.Identity, typeSpace, out map);
 }
 /// <summary>
 /// Search for a Mapping metadata with the specified type key.
 /// </summary>
 /// <param name="identity">identity of the type</param>
 /// <param name="typeSpace">The dataspace that the type for which map needs to be returned belongs to</param>
 /// <param name="ignoreCase">true for case-insensitive lookup</param>
 /// <param name="map"></param>
 /// <returns>Returns false if no match found.</returns>
 internal override bool TryGetMap(string identity, DataSpace typeSpace, bool ignoreCase, out Map map)
 {
     if (typeSpace != DataSpace.CSpace)
     {
         throw EntityUtil.InvalidOperation(System.Data.Entity.Strings.Mapping_Storage_InvalidSpace(typeSpace));
     }
     return TryGetItem<Map>(identity, ignoreCase, out map);
 }
 /// <summary>
 /// Search for a Mapping metadata with the specified type key.
 /// </summary>
 /// <param name="identity">identity of the type</param>
 /// <param name="typeSpace">The dataspace that the type for which map needs to be returned belongs to</param>
 /// <param name="ignoreCase">true for case-insensitive lookup</param>
 /// <param name="map"></param>
 /// <returns>Returns false if no match found.</returns>
 internal override bool TryGetMap(string identity, DataSpace typeSpace, bool ignoreCase, out Map map)
 {
     if (typeSpace != DataSpace.CSpace)
     {
         throw new InvalidOperationException(Strings.Mapping_Storage_InvalidSpace(typeSpace));
     }
     return TryGetItem(identity, ignoreCase, out map);
 }