Ejemplo n.º 1
0
        public static MetaContainer Parse(MetaModel mmodel, XElement node)
        {
            if(node.Name.LocalName != NodeName)
                throw new Exception("Invalid Node. To parse a " + NodeName + " you need to provide an XElement with the same name.");

            var c = new MetaContainer();

            c.Name = node.Att("Name");
            c.FullName = node.Parent.Att("Namespace") + '.' + c.Name;

            foreach (var eSet in node.Es("EntitySet"))
            {
                c.EntitySets.Add(MetaEntitySet.Parse(mmodel, c, eSet));
            }

            mmodel.Containers[c.FullName] = c;

            return c;
        }
Ejemplo n.º 2
0
        //   <EntitySet Name="Genres" EntityType="Movies.Genre" />
        //   <EntitySet Name="Movies" EntityType="Movies.Movie" />
        //   <EntitySet Name="People" EntityType="Movies.Person" />
        //   <EntitySet Name="Roles" EntityType="Movies.Role" />
        public static MetaEntitySet Parse(MetaModel mmodel, MetaContainer c, XElement node)
        {
            if (node.Name.LocalName != NodeName)
                throw new Exception("Invalid Node. To parse an " + NodeName + " you need to provide an XElement with the same node name.");

            var fullName = c.FullName + '.' + node.Att("Name");

            if (mmodel.EntitySets.ContainsKey(fullName))
                return mmodel.EntitySets[fullName];

            var m = new MetaEntitySet
                        {
                            FullName = fullName,
                            Name = node.Att("Name"),
                            Container = c
                        };

            mmodel.EntitySets.Add(fullName, m);
            m.EntityType = MetaEntityType.Parse(mmodel, node.Att("EntityType"), m);

            /* todo: process store
            // check for mapping
            var mapEnt = file.Mapping.d("EntitySetMapping").WithName(m.Name);

            if (mapEnt != null)
            {
                // we have a mapping! so we should have a MappingFrag...
                var mapFrag = mapEnt.d("MappingFragment").FirstOrDefault();

                if (mapFrag != null) // load the store
                    m.Store = MetaEntitySetStore.Parse(file, mapFrag.Att("StoreEntitySet"));
            }

            if (m.Store != null)
            {
                m.Store.EntityTypeStore = m.EntityType.Store;
            }
            */

            return m;
        }