/// <summary> /// Loads metadata and mapping information from the given path into an <see cref="EdmxV3"/> instance. /// </summary> /// <param name="edmx">The <see cref="EdmxV3"/> 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 EdmxV3 Load(EdmxV3 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 <EdmxV3, 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 EdmxV3 Load(EdmxV3 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 EdmxV3 LoadFromEmbeddedResource(EdmxV3 edmx, string splitPath) { return(GetStreamsFromResourcePath(splitPath) .Aggregate(edmx, (edmxResult, fileNameAndStream) => Load(edmxResult, MapToMetadataFileType(fileNameAndStream.Key).Value, fileNameAndStream.Value))); }
private void GetColumnsV3(LinqToEdmx.Model.StorageV3.EntityTypeStore item, DatabaseTable dbTable /*, IReadOnlyDictionary<string, (string storeType, string typeName)> typeAliases, List<TSqlDefaultConstraint> defaultConstraints,*/, LinqToEdmx.EdmxV3 model) { var tableColumns = item.Properties; foreach (var col in tableColumns) { string storeType = GetStoreTypeV3(col); string defaultValue = null; var dbColumn = new DatabaseColumn { Table = dbTable, Name = col.Name, IsNullable = col.Nullable, StoreType = storeType, DefaultValueSql = defaultValue, }; if (storeType == "rowversion") { dbColumn["ConcurrencyToken"] = true; } dbTable.Columns.Add(dbColumn); } }