public static MetaEntityTypeStore Parse(EdmxFile file, string fullName, MetaEntitySetStore entitySetStore = null) { var xEl = file.Storage.D("EntityType").WithName(fullName.LastPart()); if (xEl != null) { var m = new MetaEntityTypeStore(); m.FullName = fullName; m.Name = fullName.LastPart(); m.EntitySetStore = entitySetStore; var keyNames = (from k in xEl.D("PropertyRef") select k.Att("Name")).ToList(); m.PropertiesStores = (from p in xEl.D("Property") select new MetaPropertyStore() { FullName = fullName + '.' + p.Att("Name"), Name = p.Att("Name"), Nullable = p.Att("Nullable") == "true", Type = p.Att("Type"), EntityTypeStore = m, isKey = keyNames.Contains(p.Att("Name")) }).ToList(); return m; } return null; }
/// <summary> /// Links a MetaEntityType with a MetaEntityTypeStore all the way down do the properties. /// </summary> /// <example> /// Mapping Xml: /// <![CDATA[ /// <EntityTypeMapping TypeName="Movies.Movie"> /// <MappingFragment StoreEntitySet="movies"> /// <ScalarProperty Name="GenreId" ColumnName="genre_id" /> /// <ScalarProperty Name="Published" ColumnName="published" /> /// <ScalarProperty Name="Synopsis" ColumnName="synopsis" /> /// <ScalarProperty Name="Name" ColumnName="name" /> /// <ScalarProperty Name="Id" ColumnName="movie_id" /> /// <ComplexProperty Name="Shooting"> /// <ScalarProperty Name="Country" ColumnName="shooting_country" /> /// <ScalarProperty Name="State" ColumnName="shooting_state" /> /// <ScalarProperty Name="City" ColumnName="shooting_city" /> /// </ComplexProperty> /// </MappingFragment> /// </EntityTypeMapping> /// ]]> /// </example> public static void Link(MetaEntityType et, MetaEntityTypeStore ets, XElement mapping) { /* var propDic = (from prop in et.Properties select prop).ToDictionary(k => k.Name); var stPropDic = (from prop in ets.PropertiesStores select prop).ToDictionary(k => k.Name); foreach (var scP in mapping.d("ScalarProperty")) { MetaScalarProperty.Link(propDic[scP.Att("Name")], stPropDic[scP.Att("ColumnName")]); } var cPropDic = (from prop in et.ComplexProperties select prop).ToDictionary(k => k.Name); var stCPropDic = (from prop in ets.PropertyStores select prop).ToDictionary(k => k.Name); foreach (var scP in mapping.d("ComplexProperty")) { MetaComplexProperty. MetaScalarProperty.Link(propDic[scP.Att("Name")], stPropDic[scP.Att("ColumnName")]); } * */ }