Пример #1
0
        /// <summary>
        /// Build Library Without Clr Type Mappings based on the EntityModelSchema given
        /// </summary>
        /// <param name="model">Entity Model Schema to create Query Model of</param>
        /// <returns>Query Type Library of Entity Model Schema</returns>
        public override QueryTypeLibrary BuildLibraryWithoutClrTypeMapping(EntityModelSchema model)
        {
            QueryTypeLibrary queryTypeLibrary = base.BuildLibraryWithoutClrTypeMapping(model);

            // add new properties for each of the named streams annotations to the query entity type to be used for verification
            foreach (var container in model.EntityContainers)
            {
                foreach (var entitySet in container.EntitySets)
                {
                    foreach (EntityType entityType in model.EntityTypes.Where(t => t.IsKindOf(entitySet.EntityType)))
                    {
                        QueryEntityType queryEntityType = queryTypeLibrary.GetQueryEntityType(entitySet, entityType);

                        // add the named streams properties
                        foreach (var streamProperty in queryEntityType.EntityType.Properties.Where(p => p.IsStream()))
                        {
                            queryEntityType.Add(new QueryProperty <AstoriaQueryStreamType>(streamProperty.Name, new AstoriaQueryStreamType(this.strategy)));
                            foreach (QueryEntityType qet in queryEntityType.DerivedTypes)
                            {
                                qet.Add(new QueryProperty <AstoriaQueryStreamType>(streamProperty.Name, new AstoriaQueryStreamType(this.strategy)));
                            }
                        }

                        // add the default stream property
                        if (entityType.HasStream())
                        {
                            var queryStreamType = new AstoriaQueryStreamType(this.strategy);
                            queryEntityType.Add(new QueryProperty <AstoriaQueryStreamType>(AstoriaQueryStreamType.DefaultStreamPropertyName, queryStreamType));
                            foreach (QueryEntityType qet in queryEntityType.DerivedTypes)
                            {
                                qet.Add(new QueryProperty <AstoriaQueryStreamType>(AstoriaQueryStreamType.DefaultStreamPropertyName, new AstoriaQueryStreamType(this.strategy)));
                            }
                        }
                    }
                }
            }

            return(queryTypeLibrary);
        }
        /// <summary>
        /// Build Library Without Clr Type Mappings based on the EntityModelSchema given
        /// </summary>
        /// <param name="model">Entity Model Schema to create Query Model of</param>
        /// <returns>Query Type Library of Entity Model Schema</returns>
        public override QueryTypeLibrary BuildLibraryWithoutClrTypeMapping(EntityModelSchema model)
        {
            QueryTypeLibrary queryTypeLibrary = base.BuildLibraryWithoutClrTypeMapping(model);
            
            // add new properties for each of the named streams annotations to the query entity type to be used for verification
            foreach (var container in model.EntityContainers)
            {
                foreach (var entitySet in container.EntitySets)
                {
                    foreach (EntityType entityType in model.EntityTypes.Where(t => t.IsKindOf(entitySet.EntityType)))
                    {
                        QueryEntityType queryEntityType = queryTypeLibrary.GetQueryEntityType(entitySet, entityType);

                        // add the named streams properties
                        foreach (var streamProperty in queryEntityType.EntityType.Properties.Where(p => p.IsStream()))
                        {
                            queryEntityType.Add(new QueryProperty<AstoriaQueryStreamType>(streamProperty.Name, new AstoriaQueryStreamType(this.strategy)));
                            foreach (QueryEntityType qet in queryEntityType.DerivedTypes)
                            {
                                qet.Add(new QueryProperty<AstoriaQueryStreamType>(streamProperty.Name, new AstoriaQueryStreamType(this.strategy)));
                            }
                        }

                        // add the default stream property
                        if (entityType.HasStream())
                        {
                            var queryStreamType = new AstoriaQueryStreamType(this.strategy);
                            queryEntityType.Add(new QueryProperty<AstoriaQueryStreamType>(AstoriaQueryStreamType.DefaultStreamPropertyName, queryStreamType));
                            foreach (QueryEntityType qet in queryEntityType.DerivedTypes)
                            {
                                qet.Add(new QueryProperty<AstoriaQueryStreamType>(AstoriaQueryStreamType.DefaultStreamPropertyName, new AstoriaQueryStreamType(this.strategy)));
                            }
                        }
                    }
                }
            }

            return queryTypeLibrary;
        }