Getting Started


To get DbNetSuiteCore up and running in your solution just follow these steps

Install the DbNetSuiteCore Nuget package

Using the package manager console

Install-Package DbNetSuiteCore

or via the .NET Core command line interface:

dotnet add package DbNetSuiteCore
Add DbNetSuiteCore middleware to your application pipeline

Add the lines indicated below to your program.cs file

using DbNetSuiteCore.Middleware;        // <-- Add this line

using Microsoft.AspNetCore.Builder;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();

builder.Services.AddDbNetSuiteCore(); // <-- Add this line

builder.Services.AddHttpClient();
WebApplication app = builder.Build();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();

app.UseDbNetSuiteCore();                // <-- Add this line

app.Run();

Add the DbNetSuiteCore component to your Razor Page or MVC View


  • Include the styles used by the component with the @DbNetSuiteCore.Resources.StyleSheet() statement
  • Include the client-script used by the component with the @DbNetSuiteCore.Resources.ClientScript() statement
  • Build the GridModel by specifying the data source type, the connection string alias and the table or view to render
  • Call the GridControl Render() method passing in the GridModel

@using DbNetSuiteCore.Enums
@using DbNetSuiteCore.Models
@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
    @DbNetSuiteCore.Resources.StyleSheet()
</head>
<body>
    <main>
        @{
            GridModel customerGrid = new GridModel(DataSourceType.MSSQL, "Northwind", "Customers");
            @(await new DbNetSuiteCore.Control(HttpContext).Render(customerGrid))
        }
    </main>
    @DbNetSuiteCore.Resources.ClientScript()
</body>
</html>

For MVC Views use Context instead of HttpContext

...
@(await new DbNetSuiteCore.Control(Context).Render(customerGrid))
...

To add a DbNetSuiteCore component to your Blazor page


First include the DbNetSuiteCore styles and client script as follows to your App.razor file

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="/" />
    @DbNetSuiteCore.Blazor.Resources.StyleSheet()
    <link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
    <link rel="stylesheet" href="app.css" />
    <link rel="stylesheet" href="DbNetSuiteCore.Blazor.styles.css" />
    <link rel="icon" type="image/png" href="favicon.png" />
    <HeadOutlet />
</head>

<body>
    <Routes />
    <script src="_framework/blazor.web.js"></script>
    @DbNetSuiteCore.Blazor.Resources.ClientScript()    
</body>

</html>

Next configure your DbNetSuiteCore component in the same way you would for Razor or MVC. To render the grid create a new instance of the DbNetSuiteCore.Blazor.Control class passing an injected instance of HttpContext to the constructor and call the Render method passing your component model.

@page "/Licenses"
@attribute [StreamRendering]
@using DbNetSuiteCore.Models
@using DbNetSuiteCore.Constants
@inject IHttpContextAccessor httpContextAccessor

<PageTitle>Open Source License Types</PageTitle>

<p data-summary>Sample using public JSON api listing open source license types</p>
@{
    GridModel gridModel = new GridModel(DbNetSuiteCore.Enums.DataSourceType.JSON, "https://opensource.org/api/license") { Cache = true, Caption = "Open Source License Types" };

    gridModel.Columns = new List<GridColumn>()
    {
        new GridColumn("Id"),
        new GridColumn("Name"),
        new GridColumn("Spdx_Id", "SPDX"),
        new GridColumn("Version"),
        new GridColumn("Submission_Date") {DataType = typeof(DateTime), ParseFormat="yyyyMMdd"},
        new GridColumn("Submission_Url"){Format = FormatType.Url},
        new GridColumn("Submitter_Name"),
        new GridColumn("Approved"),
        new GridColumn("Approval_Date") {DataType = typeof(DateTime), ParseFormat="yyyyMMdd"},
        new GridColumn("License_Steward_Version"),
        new GridColumn("License_Steward_Url"){Format = FormatType.Url},
        new GridColumn("Board_Minutes") {Format = FormatType.Url}
    };
}
@(new DbNetSuiteCore.Blazor.Control(httpContextAccessor.HttpContext).Render(gridModel).Result)