/// <summary> /// Loads metadata and mapping information from the given path into an <see cref="EdmxV2"/> instance. /// </summary> /// <param name="edmx">The <see cref="EdmxV2"/> 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 EdmxV2 Load(EdmxV2 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 <EdmxV2, 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)); }
private static EdmxV2 Load(EdmxV2 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)); } }
private static EdmxV2 LoadFromEmbeddedResource(EdmxV2 edmx, string splitPath) { return(GetStreamsFromResourcePath(splitPath) .Aggregate(edmx, (edmxResult, fileNameAndStream) => Load(edmxResult, MapToMetadataFileType(fileNameAndStream.Key).Value, fileNameAndStream.Value))); }