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); }
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]; }
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); }
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); }
public IEdmModel Build(Uri uri) { var edmModel = _edmModelBuilder.Build(uri); edmModel.AddMetadataIdentityAnnotation(uri); var connection = _connectionFactory.CreateConnection(uri); var edmxModel = _edmxModelBuilder.Build(connection, uri); var clrTypes = edmxModel.GetClrTypes(); edmModel.AnnotateByClrTypes(clrTypes); edmModel.AddDbCompiledModelAnnotation(edmxModel.Compile()); return(edmModel); }
private static IDictionary <Uri, IEdmModel> BuildModels(IMetadataProvider provider, params Uri[] identities) { var models = new Dictionary <Uri, IEdmModel>(); var builder = new EdmModelBuilder(provider); foreach (var identity in identities) { BoundedContextElement context; provider.TryGetMetadata(identity, out context); if (context != null) { var clrTypes = EmitClrTypes(context); var model = builder.Build(identity).AnnotateByClrTypes(elementId => clrTypes[MetadataIdUtils.AsIdentity(elementId)]); models.Add(identity, model); } } return(models); }
// 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.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ODataEFCore v1")); } var model = EdmModelBuilder.Build(); app.UseOData(model); app.UseMvc(builder => { builder.Select().Expand().Filter().OrderBy().MaxTop(1000).Count(); builder.MapODataServiceRoute("odata", "odata", model); builder.MapRoute( name: "Default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { // set which functionalities are supported endpoints.Select().Expand().Filter().OrderBy().MaxTop(1000).Count(); // map the OData Route endpoints.MapODataRoute("odata", "odata", model); // map the default controller route endpoints.MapDefaultControllerRoute(); }); }
private static IReadOnlyDictionary <Uri, IEdmModel> BuildModels(IMetadataProvider provider) { var builder = new EdmModelBuilder(provider, new EmitEdmModelAnnotator(provider)); return(builder.Build()); }
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; }