-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Mo edited this page Feb 23, 2025
·
1 revision
This guide will help you get up and running with ProxyR in your .NET application.
- .NET 8.0 or later
- SQL Server (any edition)
- Visual Studio 2022 or VS Code
- Create a new ASP.NET Core Web API project or open an existing one
- Install the ProxyR NuGet package:
dotnet add package ProxyR.MiddlewareFirst, create a dedicated schema for your API endpoints:
CREATE SCHEMA [ProxyR] AUTHORIZATION [dbo]In your Startup.cs or Program.cs, add ProxyR to your services:
public void ConfigureServices(IServiceCollection services)
{
services.AddProxyR(options => options
.UseConnectionString("your_connection_string")
.UseDefaultSchema("ProxyR")
.UseFunctionNamePrefix("Api_")
);
// Optional: Add OpenAPI/Swagger support
services.AddOpenApi(options =>
{
options.CopyFrom(Configuration.GetSection("OpenAPI"));
options.UseProxyR(Configuration.GetSection("ProxyR"));
});
}Add ProxyR to your application pipeline:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// ... other middleware
app.UseProxyR();
// Optional: Add OpenAPI/Swagger UI
if (env.IsDevelopment())
{
app.UseOpenApiDocumentation();
app.UseOpenApiUi();
}
}Add ProxyR settings to your appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=YourDatabase;Trusted_Connection=True;"
},
"ProxyR": {
"Prefix": "Api_",
"Suffix": "",
"Seperator": "_",
"DefaultSchema": "ProxyR",
"IncludeSchemaInPath": false,
"ExcludedParameters": [],
"RequiredParameterNames": []
},
"OpenAPI": {
"ApiName": "Your API Name",
"ApiDescription": "Your API Description",
"ApiVersion": "v1",
"DocumentName": "v1",
"UseBearerAuthentication": false
}
}Following our naming conventions, create your database objects:
-- Create base tables
CREATE TABLE dbo.User (
Id INT IDENTITY(1,1) PRIMARY KEY,
Username NVARCHAR(50) NOT NULL,
Email NVARCHAR(100) NOT NULL
);
-- Create view for basic data access
CREATE VIEW ProxyR.Api_Users_View AS
SELECT Id, Username, Email
FROM dbo.User;
-- Create function for searchable grid
CREATE FUNCTION ProxyR.Api_Users_Grid
(
@SearchTerm NVARCHAR(50) = NULL,
@SortBy NVARCHAR(50) = 'Username',
@SortDirection NVARCHAR(4) = 'ASC'
)
RETURNS TABLE
AS
RETURN
(
SELECT
Id,
Username,
Email
FROM dbo.User
WHERE
(@SearchTerm IS NULL OR
Username LIKE '%' + @SearchTerm + '%' OR
Email LIKE '%' + @SearchTerm + '%')
);Your database objects are now automatically exposed as REST endpoints:
| Endpoint | Method | Description | Example |
|---|---|---|---|
/users |
GET | Get all users | GET /users |
/users/grid |
GET | Get filtered users | GET /users/grid?searchTerm=john&sortBy=Email |
If you've enabled OpenAPI/Swagger, visit:
https://your-app/swagger
ProxyR uses a convention-based approach to map database objects to API endpoints:
-
Schema: Use the
ProxyRschema for all API-exposed objects -
Prefix: Use
Api_prefix for all objects - Resource: Use plural nouns (Users, Roles, etc.)
-
Operation: Use suffixes like
_View,_Grid,_Details
For detailed naming guidelines, see our Naming Conventions Guide.
- Learn about Configuration Options
- Explore Security Best Practices
- Check out Examples
- Read the API Reference