Navigation: <Root level>

Getting Started

 

 

 

 

 

Installing from Nuget

 

You should install DbNetSuiteCore with NuGet

 

Install-Package DbNetSuiteCore

 

Or via the .NET Core command line interface:

 

dotnet add package DbNetSuiteCore

 

 

Adding DbNetSuiteCore to your application

 

Update the program.cs file in your web application as follows

 

using DbNetLink.Middleware;             // <= Add this line

 

var builder = WebApplication.CreateBuilder(args);

 

// Add services to the container.

builder.Services.AddRazorPages();

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

 

var app = builder.Build();

 

app.UseHttpsRedirection();

app.UseStaticFiles();

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

app.UseRouting();

 

app.UseAuthorization();

 

app.MapRazorPages();

 

app.Run();

 

A simple Razor view

 

Now add the component to your Razor view

 

@page

@{

    Layout = null;

}

@using DbNetSuiteCore.Components;

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="utf-8" />

    <title>Customers</title>

@{

    // Styles required by DbNetGridCore

    @DbNetSuiteCore.StyleSheet()

}

</head>

<body>

    <h1>Customers</h1>

@{

    // Configure the grid and render

    DbNetGridCore customersGrid = new DbNetGridCore(

       "northwind",

       "customers"

    );

    @customersGrid.Render()

}

@{

    // Client-script required by DbNetGridCore

    @DbNetSuiteCore.ClientScript()

}

</body>

</html>

 

 

@DbNetSuiteCore.StyleSheet() adds the the styles used by the component to the page. If you are using the component on multiple pages you would typically include this in your layout page. The method takes 2 optional arguments of fontSize and fontFamily which allow the font size and font family to be changed for any grid that consumes the rendered stylesheet. e.g.

...

@DbNetSuiteCore.StyleSheet("Large","CourierNew")

...


 

DbNetGridCore customersGrid = new DbNetGridCore( "northwind", "customers" );  configures the component, at it's simplest the configuration of the grid is to pass the name of the connection string (defined in your appsettings.json file) followed by the name of a table or view in the database to the constructor.

@customersGrid.Render() renders the grid and should be place at the point in the view where you want the grid to appear

@DbNetSuiteCore.ClientScript() adds the client-side script used by the component to the page. Like the styles if you are using the component on multiple pages you would typically include this in your layout page.

 

appSettings.json

 

DbNetSuiteCore can be configured via the appsettings.json file by adding the following section


...

  "DbNetSuiteCore": {

    "FontSize": "small",

    "FontFamily": "Arial",

    "Debug" :  true,

    "ReadOnly" : false

  }

...

 

The following properties can be configured

 

FontSize - Can be used to set the font size for all DbNetSuiteCore controls e.g. Small, Medium or Large

FontFamily - Can be used to set the font family for all DbNetSuiteCore controls e.g. Verdana, Arial, Tahoma etc

Debug - Set to true to put DbNetSuiteCore in Debug mode

ReadOnly - If set to true then any updates the the database are suppressed and a message returned to the user


 

Database Support

 

DbNetSuiteCore supports connection to the following databases:

MSSqlServer (default)

MySQL

PostgreSQL

SQLite

MariaDB


A control will make an attempt to automatically determine the type of database you are connecting to from the connection string but if this fails you can specify the DatabaseType explicitly either as a property or in the constructor. For connections to MS SQL Server and SQLite the Data Provider is included in the framework but for the following databases you will need to install the data provider from a Nuget package into your application:
 

MySQL - https://www.nuget.org/packages/MySql.Data/

PostgreSQL - https://www.nuget.org/packages/Npgsql/

MariaDB - https://www.nuget.org/packages/mysqlconnector/
 

JSON Support

In addition to direct database support DbNetGridCore and DbNetEditCore can be used with JSON based data sources delivered from external API's. The JSON can either be supplied in a raw format or as a List of objects that can be serialized to JSON.
Demo

 

 

 

Copyright © 2023 DbNetLink