Example #1
0
        /// <summary>
        /// Loads metadata and mapping information from the given path into an <see cref="Edmx"/> instance.
        /// </summary>
        /// <param name="edmx">The <see cref="Edmx"/> instance in which to load metadata from the given path.</param>
        /// <param name="splitPath">An non-delimited, i.e. split, path from which to load metadata.</param>
        /// <returns>An edmx instance loaded with metadata from the given <paramref name="splitPath"/>.</returns>
        private static Edmx Load(Edmx edmx, string splitPath)
        {
            if (splitPath.StartsWith(ResourceSchemeString))
            {
                return(LoadFromEmbeddedResource(edmx, splitPath));
            }

            if (MapToMetadataFileType(splitPath) == MetadataFileType.ConceptualModel)
            {
                edmx.Runtimes.First().ConceptualModels.ConceptualSchema = ConceptualSchema.Load(splitPath);
                return(edmx);
            }
            if (MapToMetadataFileType(splitPath) == MetadataFileType.StorageModel)
            {
                edmx.Runtimes.First().StorageModels.StorageSchema = StorageSchema.Load(splitPath);
                return(edmx);
            }
            if (MapToMetadataFileType(splitPath) == MetadataFileType.Mapping)
            {
                edmx.Runtimes.First().Mappings.Mapping = Mapping.Load(splitPath);
                return(edmx);
            }
            if (MapToMetadataFileType(splitPath) == MetadataFileType.Edmx)
            {
                return(XTypedServices.Load <Edmx, TEdmx>(splitPath, LinqToXsdTypeManager.Instance));
            }
            throw new ArgumentException(String.Format("The path argument '{0}' must represent a path to an edmx, csdl, ssdl or msl file.", splitPath));
        }
Example #2
0
        private static Edmx Load(Edmx edmx, MetadataFileType fileType, Stream metadataStream)
        {
            switch (fileType)
            {
            case MetadataFileType.ConceptualModel:
                edmx.Runtimes.First().ConceptualModels.ConceptualSchema = ConceptualSchema.Load(metadataStream);
                return(edmx);

            case MetadataFileType.StorageModel:
                edmx.Runtimes.First().StorageModels.StorageSchema = StorageSchema.Load(metadataStream);
                return(edmx);

            case MetadataFileType.Mapping:
                edmx.Runtimes.First().Mappings.Mapping = Mapping.Load(metadataStream);
                return(edmx);

            case MetadataFileType.Edmx:
                return(Load(metadataStream));

            default:
                throw new ArgumentException(String.Format("The fileType '{0}' must represent an edmx, csdl, ssdl or msl file.", fileType));
            }
        }
Example #3
0
 private static Edmx LoadFromEmbeddedResource(Edmx edmx, string splitPath)
 {
     return(GetStreamsFromResourcePath(splitPath)
            .Aggregate(edmx, (edmxResult, fileNameAndStream) => Load(edmxResult, MapToMetadataFileType(fileNameAndStream.Key).Value, fileNameAndStream.Value)));
 }