コード例 #1
0
        public static bool ExistsMappingTypeName(Type dotNetEntityType, ObjectContext defaultContext)
        {
            // dotNetEntityType can be a POCO object with no ObjectContext. We are getting proxy for the POCO
            // object which will have the context needed for LINQ stuff
            Type objectType = ObjectContext.GetObjectType(dotNetEntityType);

            ObjectContext   context         = TypesToContexts.GetOrDefault(objectType.FullName, defaultContext);
            EntityContainer entityContainer = context.MetadataWorkspace.GetEntityContainer(context.DefaultContainerName, DataSpace.CSpace);
            EntitySetBase   entitySet       = entityContainer.BaseEntitySets.FirstOrDefault(es => es.ElementType.Name == objectType.Name);

            if (entitySet != null)
            {
                _typeNamesMapping.GetOrAdd(objectType.FullName,
                                           () =>
                {
                    return(entitySet.ElementType.FullName);
                });
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// This function checks if the entity meta data is already cached for the given context. If it is not
        /// then it does it by looking into the assembly file.
        /// </summary>
        /// <param name="context">Object context</param>
        public static void EnsureStorageMetaData(ObjectContext context)
        {
            Assembly assembly = Assembly.GetAssembly(context.GetType());

            _assembliesLoaded.GetOrAdd(assembly.FullName, () => LoadMetaDataFromAssembly(assembly));
        }