Restier Documentation

repository·main·Indexed 19 days ago

https://github.com/odata/restier

An API development framework for building standardized, OData V4 based RESTful services on .NET. Restier provides a modern successor to WCF Data Services, enabling developers to bootstrap queryable HTTP-based REST interfaces with built-in query interception. It supports ASP.NET Classic, ASP.NET Core, Entity Framework 6, and Entity Framework Core, with specialized packages for core logic, database translation, unit testing via Microsoft.Restier.Breakdance, and OpenAPI/Swagger documentation.

Tokens
82.6K
Snippets
242
Records
386
Agent score
66%

What's inside Restier

  1. Overview of the Microsoft.Restier.Core.Submit namespace

    main

    The Microsoft.Restier.Core.Submit namespace provides the core abstractions and implementations for handling data submission flows in Restier. It manages how multiple data modifications are grouped into change sets, validated, authorized, and executed.

    Core Concepts

    Change Sets

    • ChangeSet: Represents a collection of changes to be applied.
    • ChangeSetItem: Represents an individual item within a ChangeSet.
    • DataModificationItem: Represents the specific data modification logic for an item in a change set.
    • SubmitContext: Provides the context under which a submission flow operates.
    • SubmitResult: Encapsulates the outcome of a submission attempt.

    Submission Lifecycle and Extensibility

    Restier uses several interfaces to allow developers to hook into the submission process:

    • Initialization: Use IChangeSetInitializer (or the DefaultChangeSetInitializer class) to initialize a change set.
    • Authorization: Use IChangeSetItemAuthorizer to implement logic that determines if a user is authorized to perform a specific change set item operation.
    • Filtering: Use IChangeSetItemFilter to inject logic that runs before and after a change set item is processed.
    • Validation: Use IChangeSetItemValidator to validate change set entries. Results of these validations are returned as ChangeSetItemValidationResult objects.
    • Execution: Use ISubmitExecutor (or the DefaultSubmitExecutor class) to execute the actual submission process.
  2. Overview of the Microsoft.Restier.AspNet.Formatter namespace

    main
    The Microsoft.Restier.AspNet.Formatter namespace provides the necessary classes for serializing and deserializing Restier results within an ASP.NET environment. It includes specialized serializers for different types of OData results, such as collections, enums, primitives, and resource sets, as well as providers to manage these serialization processes.
  3. Overview of Microsoft.Restier.AspNetCore.Formatter namespace

    main
    The Microsoft.Restier.AspNetCore.Formatter namespace provides the necessary classes for serializing and deserializing Restier results within an ASP.NET Core environment. It includes specialized serializers for different types of OData results, such as collections, enums, primitives, and resource sets, as well as providers to manage these serializers.
  4. Overview of the Microsoft.Restier.Core.Query namespace

    main
    The Microsoft.Restier.Core.Query namespace provides the core abstractions and services required to manage the lifecycle of a query in Restier. This includes the execution of queries, the processing and expansion of query expressions, authorization of expressions, and the management of query context and model references.
  5. Explore Restier Namespaces

    main

    Restier is organized into several namespaces that separate core logic, data modeling, query processing, and provider implementations. Use these namespaces to locate specific functionality:

    Core Logic and Operations

    • Microsoft.Restier.Core: The primary namespace for the Restier engine.
    • Microsoft.Restier.Core.Authorization: Handles security and access control.
    • Microsoft.Restier.Core.Model: Defines the data models used by Restier.
    • Microsoft.Restier.Core.Operation: Manages the execution of operations.
    • Microsoft.Restier.Core.Query: Provides tools for building and parsing queries.
    • Microsoft.Restier.Core.Submit: Handles the submission of requests/queries.

    Data Providers and Integration

    • Microsoft.Restier.EntityFramework: Integration for Entity Framework.
    • Microsoft.Restier.EntityFrameworkCore: Integration for Entity Framework Core.

    External Dependencies

    Restier relies on several standard Microsoft namespaces for dependency injection, spatial data, and entity frameworks:

    • Microsoft.Extensions.DependencyInjection
    • Microsoft.EntityFrameworkCore
    • System.Data.Entity.Spatial
    • Microsoft.Spatial
  6. Use RestierTestHelpers for unit testing Restier components

    main

    The RestierTestHelpers class in the Microsoft.Restier.Breakdance namespace provides a suite of static methods designed to simplify the extraction of Restier runtime components for unit testing purposes. This is useful when you need to isolate specific parts of the Restier engine or its dependencies within a test environment.

    For concrete implementation examples, refer to the RestierTestHelperTests.cs file in the repository.

  7. Understand the Microsoft.Restier.Core.Operation namespace

    main

    The Microsoft.Restier.Core.Operation namespace provides the core abstractions for managing the lifecycle of an operation within Restier. It defines how operations are authorized, filtered, executed, and the context in which they run.

    Key components include:

    • OperationContext: A class representing the specific context of a single operation execution. A new instance is created for every individual operation execution.
    • IOperationAuthorizer: An interface used to implement authorization logic for operations.
    • IOperationExecutor: An interface representing the service responsible for the actual execution of an operation.
    • IOperationFilter: An interface for implementing operation processors that can intercept or modify operations.
  8. What is DataSourceStub and how is it used in query expressions

    main
    The DataSourceStub class provides static method stubs used within query expressions to identify API data sources. These stubs act as generic placeholders; they do not contain actual data but instead represent a reference to a data source (such as an entity set, singleton, or composable function). During the query pipeline execution, the data provider's sourcer replaces these stubs with the actual underlying data source.