private static IEdmModel CreateImplicitModel(HttpConfiguration configuration, Type elementClrType) { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(configuration, isQueryCompositionMode: true); // Add the type to the model as an entity and add an entity set with the same name. EntityTypeConfiguration entityTypeConfiguration = builder.AddEntityType(elementClrType); builder.AddEntitySet(elementClrType.Name, entityTypeConfiguration); // Build the model and add the AuthorizedRolesAnnotation. IEdmModel edmModel = builder.GetEdmModel(); Contract.Assert(edmModel != null); edmModel.AddAuthorizedRolesAnnotations(); return(edmModel); }
public static IEdmModel GetModel() { // Define the model. ODataModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet <Customer>("Customers"); builder.EntitySet <Order>("Orders"); builder.EntitySet <Address>("Addresses"); builder.EntitySet <OrderLine>("OrdersLines"); // Build the model and add the authorized roles annotation that will be consumed by the // Authorization query validator. IEdmModel model = builder.GetEdmModel(); // Inspect the CLR types associated with this model for CanExpandAttribute instances and // add AuthorizedRolesAnnotation instances as appropiate. model.AddAuthorizedRolesAnnotations(); return(model); }