Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            var model = EdmModelBuilder.GetEdmModel();

            app.UseMvc(builder =>
            {
                builder.Select().Expand().Filter().OrderBy().MaxTop(100).Count();

                builder.MapRoute(
                    name: "default",
                    template: "",
                    defaults: new { controller = "Home", action = "Index" });
                builder.EnableDependencyInjection();

                builder.MapODataServiceRoute("odata1", "efcore", model);

                builder.MapODataServiceRoute("odata2", "inmem", model);

                builder.MapODataServiceRoute("odata3", "composite", EdmModelBuilder.GetCompositeModel());

                builder.MapODataServiceRoute("odata4", "odata", EdmModelBuilder.GetCustomerOrderModel());
            });
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseAuthorization();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.EnsureMigrationOfContext <ContactDbContext>();

            app.UseODataMvc(EdmModelBuilder.GetEdmModel());
        }
Example #3
0
        static TestModelSource()
        {
            BoundedContextElement context = BoundedContextElement.Config
                .Name("Context")
                .ConceptualModel(
                    StructuralModelElement.Config
                    .Types((EnumTypeElement)EnumTypeElement.Config.Name("EnumType").Member("Member1", 0).Member("Member2", 1))
                    .Elements(
                        EntityElement.Config
                            .Name("MasterClass")
                            .HasKey("Id")
                            .Property(EntityPropertyElement.Config.Name("Id").OfType(ElementaryTypeKind.Int32))
                            .Property(EntityPropertyElement.Config.Name("Name").OfType(ElementaryTypeKind.String))
                            .Property(EntityPropertyElement.Config.Name("EnumType").OfType<EnumTypeElement>(EnumTypeElement.Config.Name("EnumType")))
                            .Relation(EntityRelationElement.Config
                                .Name("NestedClass")
                                .DirectTo(
                                    EntityElement.Config
                                        .Name("NestedClass")
                                        .HasKey("Id")
                                        .Property(EntityPropertyElement.Config.Name("Id").OfType(ElementaryTypeKind.Int32))
                                        .Property(EntityPropertyElement.Config.Name("Name").OfType(ElementaryTypeKind.String)))
                             .AsOne())));

            var provider = CreateProvider(MockSource(context));
            var contextId = context.Identity.Id;

            var edmModelBuilder = new EdmModelBuilder(provider, new EdmModelAnnotator(ClrTypes));
            EdmModel = edmModelBuilder.Build()[contextId];
        }
Example #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            IEdmModel model = EdmModelBuilder.GetEdmModel();

            app.UseRouting();

            app.UseAuthorization();

            app.UseODataBatching();

            app.UseEndpoints(endpoints =>
            {
                endpoints.Select().Expand().Filter().OrderBy().MaxTop(100).Count();

                endpoints.MapODataRoute("nullPrefix", null, model);

                endpoints.MapODataRoute("odataPrefix", "odata", model);

                endpoints.MapODataRoute("myPrefix", "my/{data}", model);

                endpoints.MapODataRoute("msPrefix", "ms", model, new DefaultODataBatchHandler());
            });

            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("v1/swagger.json", "Test API (V1)");
            });
        }
Example #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              EdmModelBuilder modelBuilder,
                              AppDbContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            DbInitializer.Initialize(context, env);

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                // OData.
                routes.MapODataServiceRoute("ODataRoutes",
                                            "odata",
                                            modelBuilder.GetEdmModel(app.ApplicationServices));
            });
        }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseMvc(routeBuilder =>
            {
                routeBuilder.Select().Expand().Filter().OrderBy().MaxTop(100).Count();
                routeBuilder.EnableDependencyInjection();
                IEdmModel model = EdmModelBuilder.GetEdmModel();
                routeBuilder.MapODataServiceRoute("odata", "odata", model);
            });
        }
Example #7
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            CustomerGeoContext.Init();

            config.MapODataServiceRoute("odata", "odata", EdmModelBuilder.BuildCustomerEdmModel());
        }
Example #8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            IEdmModel model = EdmModelBuilder.GetEdmModel();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseMvc(routeBuilder =>
            {
                routeBuilder.Select().Expand().Filter().OrderBy();
                routeBuilder.MapODataServiceRoute("odata", "odata", model);
            });

            //app.UseEndpoints(endpoints =>
            //{
            //    //endpoints.MapControllers();
            //    endpoints.MapODataRoute("odataPrefix", "odata", model);
            //});
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });


            app.UseMvc(builder =>
            {
                builder.Select().Expand().Filter().OrderBy().MaxTop(80).Count();

                builder.MapODataServiceRoute("odata", "odata", EdmModelBuilder.GetEdmModel());
            });
        }
Example #10
0
        //[EnableQuery]
        public IActionResult Get(ODataQueryOptions <Customer> queryOptions)
        {
            if (queryOptions.Filter != null)
            {
                var              model     = EdmModelBuilder.GetEdmModel2();
                IEdmEntitySet    entitySet = model.EntityContainer.FindEntitySet("Customers");
                EntitySetSegment segment   = new EntitySetSegment(entitySet);
                ODataPath        path      = new ODataPath(segment);
                //        Request.ODataFeature().Model = model; // if you have these codes, the output is different
                //       Request.ODataFeature().Path = path;
                ODataQueryContext context = new ODataQueryContext(model, typeof(Customer), path);

                // I hard code the rawValue, you should retrieve the filter clause from queryOptions to construct the it.
                string rawValue = "contains(CustomMetadata, 'CustomPropA')";

                ODataQueryOptionParser parser = new ODataQueryOptionParser(model, path, new Dictionary <string, string>
                {
                    { "$filter", rawValue }
                });

                FilterQueryOption filter = new FilterQueryOption(rawValue, context, parser);
                return(Ok(filter.ApplyTo(_context.Customers, new ODataQuerySettings())));
            }

            return(Ok(_context.Customers));
        }
Example #11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <MyDataContext>(opt => opt.UseLazyLoadingProxies().UseInMemoryDatabase("MyDataContextList"));

            IEdmModel model0 = EdmModelBuilder.GetEdmModel();
            IEdmModel model1 = EdmModelBuilder.GetEdmModelV1();
            IEdmModel model2 = EdmModelBuilder.GetEdmModelV2();

            services.AddControllers(options => {
                //{
                //    options.Conventions.Add(new MetadataApplicationModelConventionAttribute());
                //    options.Conventions.Add(new MetadataActionModelConvention());
            });

            /*services.AddConvention<MyConvention>();
             *
             * services.AddOData()
             *  .AddODataRouting(options => options
             *      .AddModel(EdmModelBuilder.GetEdmModel())
             *      .AddModel("v1", EdmModelBuilder.GetEdmModelV1())
             *      .AddModel("v2{data}", EdmModelBuilder.GetEdmModelV2()));
             *
             * services.AddODataFormatter();
             * services.AddODataQuery(options => options.Count().Filter().Expand().Select().OrderBy().SetMaxTop(5));
             */

            services.AddOData(opt => opt.Count().Filter().Expand().Select().OrderBy().SetMaxTop(5)
                              .AddModel(model0)
                              .AddModel("v1", model1)
                              .AddModel("v2{data}", model2, builder => builder.AddService <ODataBatchHandler, DefaultODataBatchHandler>(Microsoft.OData.ServiceLifetime.Singleton))
                              );
        }
Example #12
0
        static TestModel()
        {
            BoundedContextElement context = BoundedContextElement.Config
                                            .Name("Context")
                                            .ConceptualModel(
                StructuralModelElement.Config
                .Types((EnumTypeElement)EnumTypeElement.Config.Name("EnumType").Member("Member1", 0).Member("Member2", 1))
                .Elements(
                    EntityElement.Config
                    .Name("MasterClass")
                    .HasKey("Id")
                    .Property(EntityPropertyElement.Config.Name("Id").OfType(ElementaryTypeKind.Int32))
                    .Property(EntityPropertyElement.Config.Name("Name").OfType(ElementaryTypeKind.String))
                    .Property(EntityPropertyElement.Config.Name("EnumType").OfType <EnumTypeElement>(EnumTypeElement.Config.Name("EnumType")))
                    .Relation(EntityRelationElement.Config
                              .Name("NestedClass")
                              .DirectTo(
                                  EntityElement.Config
                                  .Name("NestedClass")
                                  .HasKey("Id")
                                  .Property(EntityPropertyElement.Config.Name("Id").OfType(ElementaryTypeKind.Int32))
                                  .Property(EntityPropertyElement.Config.Name("Name").OfType(ElementaryTypeKind.String))
                                  )
                              .AsOne())
                    ));

            var provider  = CreateProvider(MockSource(context));
            var contextId = context.Identity.Id;

            var edmModelBuilder = new EdmModelBuilder(provider);

            EdmModel = edmModelBuilder.Build(contextId).AnnotateByClrTypes(ClrTypes);
        }
Example #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <SecurityDbContext>(opt => opt.UseInMemoryDatabase("Example"));

            services.AddScoped <IAccountRepository, AccountRepository>();
            services.AddScoped <IUserRepository, UserRepository>();

            services.AddHostedService <DataSeedService>();
            services.AddSingleton <IMapper, Mapper>();

            services.AddOData(opts => opts
                              .Count()
                              .Filter()
                              .Expand()
                              .Select()
                              .OrderBy()
                              .SetMaxTop(null)
                              .AddModel("v{version}", EdmModelBuilder.GetEdmModel()));

            services
            .AddAuthentication("Bearer")
            .AddScheme <AuthenticationSchemeOptions, FakeAuthenticationHandler>("Bearer", null);

            services.AddControllers();

            services.AddApiVersioning(opts =>
            {
                opts.ReportApiVersions = true;
            });
        }
Example #14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseOptions();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Faccio la mia bella hotfix!
            app.UseCors(opt => opt
                        .WithOrigins("http://localhost:4200", "http://localhost")
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowCredentials());

            app.UseMvc(routeBuilder =>
            {
                routeBuilder.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");

                // Enable full OData queries, you might want to consider which would be actually enabled in production scenaries
                routeBuilder.Count().Filter().OrderBy().Expand().Select().MaxTop(null);

                routeBuilder.MapODataServiceRoute("ODataRoute", "odata", EdmModelBuilder.CreateModel());
            });
        }
Example #15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            IEdmModel model = EdmModelBuilder.GetEdmModel();

            // Please add "UseODataBatching()" before "UseRouting()" to support OData $batch.
            app.UseODataBatching();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapODataRoute(
                    "nullPrefix", null,
                    b =>
                {
                    b.AddService(Microsoft.OData.ServiceLifetime.Singleton, sp => model);
                    b.AddService <ODataDeserializerProvider>(Microsoft.OData.ServiceLifetime.Singleton, sp => new EntityReferenceODataDeserializerProvider(sp));
                    b.AddService <IEnumerable <IODataRoutingConvention> >(Microsoft.OData.ServiceLifetime.Singleton,
                                                                          sp => ODataRoutingConventions.CreateDefaultWithAttributeRouting("nullPrefix", endpoints.ServiceProvider));
                });

                endpoints.MapODataRoute("odataPrefix", "odata", model);

                endpoints.MapODataRoute("myPrefix", "my/{data}", model);

                endpoints.MapODataRoute("msPrefix", "ms", model, new DefaultODataBatchHandler());
            });
        }
        /// <summary>
        /// Gets The model to use for the specified test configuration.
        /// </summary>
        /// <param name="testConfiguration">The test configuration to use.</param>
        /// <returns>The model to use for the test.</returns>
        protected override IEdmModel GetMetadataProvider(ReaderTestConfiguration testConfiguration)
        {
            IEdmModel model = base.GetMetadataProvider(testConfiguration);

            if (model == null)
            {
                // Try to set the cached model if it is null. If the PayloadEdmModel is null cached model will stay null.
                if (this.cachedModel == null)
                {
                    this.cachedModel = this.PayloadEdmModel;
                }

                if (this.cachedModel != null)
                {
                    if (this.Annotations != null)
                    {
                        this.cachedModel = EdmModelBuilder.BuildAnnotationModel(this.Annotations, this.cachedModel);
                    }
                }

                model = this.cachedModel;
            }

            return(model);
        }
Example #17
0
        public ContentQueryService(
            IAppProvider appProvider,
            IAssetUrlGenerator assetUrlGenerator,
            IContentRepository contentRepository,
            IContentVersionLoader contentVersionLoader,
            IScriptEngine scriptEngine,
            IOptions <ContentOptions> options,
            EdmModelBuilder modelBuilder)
        {
            Guard.NotNull(appProvider, nameof(appProvider));
            Guard.NotNull(assetUrlGenerator, nameof(assetUrlGenerator));
            Guard.NotNull(contentRepository, nameof(contentRepository));
            Guard.NotNull(contentVersionLoader, nameof(contentVersionLoader));
            Guard.NotNull(modelBuilder, nameof(modelBuilder));
            Guard.NotNull(options, nameof(options));
            Guard.NotNull(scriptEngine, nameof(scriptEngine));

            this.appProvider          = appProvider;
            this.assetUrlGenerator    = assetUrlGenerator;
            this.contentRepository    = contentRepository;
            this.contentVersionLoader = contentVersionLoader;
            this.modelBuilder         = modelBuilder;
            this.options      = options.Value;
            this.scriptEngine = scriptEngine;
        }
Example #18
0
 public SelectExpandBinderTests()
 {
     _model       = EdmModelBuilder.GetEdmModel();
     _customer    = _model.SchemaElements.OfType <IEdmEntityType>().First(c => c.Name == "Customer");
     _vipCustomer = _model.SchemaElements.OfType <IEdmEntityType>().First(c => c.Name == "VipCustomer");
     _address     = _model.SchemaElements.OfType <IEdmComplexType>().First(c => c.Name == "Address");
     _customers   = _model.EntityContainer.FindEntitySet("Customers");
 }
Example #19
0
        private static HttpClient GetClient()
        {
            var config = new HttpConfiguration();

            config.MapODataServiceRoute("odata", "odata", EdmModelBuilder.GetEdmModel());

            return(new HttpClient(new HttpServer(config)));
        }
Example #20
0
        private static IEdmModel BuildModel(IMetadataProvider provider, Uri contextId)
        {
            var builder = new EdmModelBuilder(provider);
            var model   = builder.Build(contextId);

            model.Dump();

            return(model);
        }
        private static IEdmModel BuildModel(Uri contextId)
        {
            var builder = new EdmModelBuilder(TestMetadataProvider.Instance, new NullEdmModelAnnotator());
            var model   = builder.Build()[contextId];

            model.Dump();

            return(model);
        }
Example #22
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc(builder => builder.MapODataServiceRoute("odata", "odata", EdmModelBuilder.GetEdmModel()));
        }
Example #23
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <BookStoreContext>(opt => opt.UseInMemoryDatabase("BookLists"));
            services.AddDbContext <CustomerOrderContext>(opt => opt.UseInMemoryDatabase("CustomersLists"));

            services.AddControllers();
            services.AddOData(opt => opt.AddModel("odata", EdmModelBuilder.BuildBookModel()).
                              AddModel("v{version}", EdmModelBuilder.BuildCustomerModel()).Count() /*.EnableAttributeRouting = false*/);
        }
        private static IEdmModel BuildModel(IMetadataProvider provider, Uri contextId)
        {
            var builder = new EdmModelBuilder(provider, new EdmModelAnnotator(Enumerable.Empty <Type>()));
            var model   = builder.Build()[contextId];

            model.Dump();

            return(model);
        }
Example #25
0
        private static HttpClient GetCaseInsensitiveClient()
        {
            var config = new HttpConfiguration();

            config.EnableCaseInsensitive(true);
            config.EnableEnumPrefixFree(true);
            config.MapODataServiceRoute("odata3", "v3", EdmModelBuilder.GetEdmModel());
            return(new HttpClient(new HttpServer(config)));
        }
Example #26
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseOData(EdmModelBuilder.GetEdmModel());
        }
Example #27
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string connectionString = @"Data Source=(LocalDb)\MSSQLLocalDB;Integrated Security=True;Initial Catalog=FilterDbContextTest";

            services.AddDbContext <FilterDbContext>(opt => opt.UseLazyLoadingProxies().UseSqlServer(connectionString));

            services.AddControllers()
            .AddOData(opt => opt.AddRouteComponents("odata", EdmModelBuilder.GetEdmModel()).EnableQueryFeatures());
        }
Example #28
0
        public MongoContentRepository(IMongoDatabase database, ISchemaProvider schemas, EdmModelBuilder modelBuilder)
        {
            Guard.NotNull(database, nameof(database));
            Guard.NotNull(modelBuilder, nameof(modelBuilder));
            Guard.NotNull(schemas, nameof(schemas));

            this.schemas      = schemas;
            this.database     = database;
            this.modelBuilder = modelBuilder;
        }
Example #29
0
        public ODataQueryTests()
        {
            var builder = new EdmModelBuilder(new MemoryCache(Options.Create(new MemoryCacheOptions())));

            var schemaEntity = new Mock <ISchemaEntityWithSchema>();

            schemaEntity.Setup(x => x.Id).Returns(Guid.NewGuid());
            schemaEntity.Setup(x => x.Version).Returns(3);
            schemaEntity.Setup(x => x.Schema).Returns(schema);

            edmModel = builder.BuildEdmModel(schemaEntity.Object, languages);
        }
Example #30
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            #region Codes for backup and use to compare with preview design/implementation
            //services.AddControllers(options => {
            //{
            //    options.Conventions.Add(new MetadataApplicationModelConventionAttribute());
            //    options.Conventions.Add(new MetadataActionModelConvention());
            //});

            /*services.AddConvention<MyConvention>();
             *
             * services.AddOData()
             *  .AddODataRouting(options => options
             *      .AddModel(EdmModelBuilder.GetEdmModel())
             *      .AddModel("v1", EdmModelBuilder.GetEdmModelV1())
             *      .AddModel("v2{data}", EdmModelBuilder.GetEdmModelV2()));
             *
             * services.AddODataFormatter();
             * services.AddODataQuery(options => options.Count().Filter().Expand().Select().OrderBy().SetMaxTop(5));
             */
            #endregion

            services.AddDbContext <MyDataContext>(opt => opt.UseLazyLoadingProxies().UseInMemoryDatabase("MyDataContextList"));

            IEdmModel model0 = EdmModelBuilder.GetEdmModel();
            IEdmModel model1 = EdmModelBuilder.GetEdmModelV1();
            IEdmModel model2 = EdmModelBuilder.GetEdmModelV2();
            IEdmModel model3 = EdmModelBuilder.GetEdmModelV3();

            services.AddControllers()

            /*  If you want to remove $metadata endpoint, you can use ControllerFeatureProvider as follows
             * .ConfigureApplicationPartManager(manager =>
             * {
             *  manager.FeatureProviders.Remove(manager.FeatureProviders.OfType<ControllerFeatureProvider>().FirstOrDefault());
             *  manager.FeatureProviders.Add(new RemoveMetadataControllerFeatureProvider());
             * })
             *
             * or, remove MetadataRoutingConvention in AddOData as
             *   opt.Conventions.Remove(opt.Conventions.First(convention => convention is MetadataRoutingConvention));
             */
            .AddOData(opt => opt.Count().Filter().Expand().Select().OrderBy().SetMaxTop(5)
                      .AddRouteComponents(model0)
                      .AddRouteComponents("v1", model1)
                      .AddRouteComponents("v2{data}", model2, services => services.AddSingleton <ODataBatchHandler, DefaultODataBatchHandler>())
                      .AddRouteComponents("v3", model3)
                      .Conventions.Add(new MyConvention())
                      );

            services.AddSwaggerGen();
        }
Example #31
0
        public ODataQueryTests()
        {
            schemaDef.Update(new SchemaProperties {
                Hints = "The User"
            });

            schemaDef.AddField(new StringField(1, "firstName", Partitioning.Language,
                                               new StringFieldProperties {
                Label = "FirstName", IsRequired = true, AllowedValues = new[] { "1", "2" }
            }));
            schemaDef.AddField(new StringField(2, "lastName", Partitioning.Language,
                                               new StringFieldProperties {
                Hints = "Last Name", Editor = StringFieldEditor.Input
            }));

            schemaDef.AddField(new BooleanField(3, "isAdmin", Partitioning.Invariant,
                                                new BooleanFieldProperties()));

            schemaDef.AddField(new NumberField(4, "age", Partitioning.Invariant,
                                               new NumberFieldProperties {
                MinValue = 1, MaxValue = 10
            }));

            schemaDef.AddField(new DateTimeField(5, "birthday", Partitioning.Invariant,
                                                 new DateTimeFieldProperties()));

            schemaDef.AddField(new AssetsField(6, "pictures", Partitioning.Invariant,
                                               new AssetsFieldProperties()));

            schemaDef.AddField(new ReferencesField(7, "friends", Partitioning.Invariant,
                                                   new ReferencesFieldProperties()));

            schemaDef.AddField(new StringField(8, "dashed-field", Partitioning.Invariant,
                                               new StringFieldProperties()));

            var builder = new EdmModelBuilder(new MemoryCache(Options.Create(new MemoryCacheOptions())));

            var schema = A.Dummy <ISchemaEntity>();

            A.CallTo(() => schema.Id).Returns(Guid.NewGuid());
            A.CallTo(() => schema.Version).Returns(3);
            A.CallTo(() => schema.SchemaDef).Returns(schemaDef);

            var app = A.Dummy <IAppEntity>();

            A.CallTo(() => app.Id).Returns(Guid.NewGuid());
            A.CallTo(() => app.Version).Returns(3);
            A.CallTo(() => app.PartitionResolver).Returns(languagesConfig.ToResolver());

            edmModel = builder.BuildEdmModel(schema, app);
        }
        private static IEdmModel BuildModel(IMetadataProvider provider, Uri contextId)
        {
            var builder = new EdmModelBuilder(provider, new EdmModelAnnotator(Enumerable.Empty<Type>()));
            var model = builder.Build()[contextId];

            model.Dump();

            return model;
        }