/// <summary> /// Initializes a new <see cref="EntityProperty"/>. /// </summary> /// <param name="conceptualModel">The model a property belongs to.</param> /// <param name="element">The backing property element.</param> /// <param name="name">The property name.</param> /// <param name="type">The property type.</param> public EntityProperty(INamespacedOperations conceptualModel, XElement element, string name, EntityPropertyType type) { _conceptualModel = conceptualModel ?? throw new ArgumentNullException(nameof(conceptualModel)); _element = element; Name = name; Type = type; }
/// <summary> /// Initialized a new <see cref="EntityType"/>. /// </summary> /// <param name="conceptualModel">The conceptual model the entity belongs to.</param> /// <param name="element">The backing entity type element.</param> /// <param name="conceptualName">The name of an entity in the conceptual model.</param> /// <param name="storageName">The name of an entity in the storage model.</param> public EntityType(INamespacedOperations conceptualModel, XElement element, string conceptualName, string storageName) { _conceptualModel = conceptualModel ?? throw new ArgumentNullException(nameof(conceptualModel)); _element = element ?? throw new ArgumentNullException(nameof(element)); ConceptualName = conceptualName ?? throw new ArgumentNullException(nameof(conceptualName)); StorageName = storageName ?? throw new ArgumentNullException(nameof(storageName)); }
/// <summary> /// Initializes a new <see cref="EntityDataModel"/>. /// </summary> /// <param name="edmxDocument">The edmx file containing the model.</param> public EntityDataModel(XDocument edmxDocument) { _conceptualModel = edmxDocument?.Edm() ?? throw new ArgumentNullException(nameof(edmxDocument)); _conceptualTypeNamespace = _conceptualModel.Descendants("Schema") .Single() .Attribute("Namespace").Value; // The conceptual model entity type that is being mapped is specified by the // TypeName attribute of the EntityTypeMapping element. The table or view // that is being mapped is specified by the StoreEntitySet attribute of the // child MappingFragment element. _mappings = edmxDocument.Cs().Descendants("EntitySetMapping") .SelectMany(es => es.Cs().Elements("EntityTypeMapping")) .ToDictionary(et => Sanitize(et.Attribute("TypeName").Value), et => et.Cs().Element("MappingFragment") .Attribute("StoreEntitySet").Value); }