DataTables / DataTables/NET

Add extensions for DI

Open
#27 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
19
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Usage:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllersWithViews();
builder.Services.AddDataTables("sqlite", "Data Source=./db.sqlite"); // <----------- NEW!

var app = builder.Build();

app.UseStaticFiles();

app.MapDefaultControllerRoute();

app.Run();

Usage:

public CarsController(Database db) : ControllerBase // new primary constructors
{
  [HttpGet("DataTable")]
  [HttpPost("DataTable")]
  public ActionResult<DtResponse> GetDataTable()
  {
    // db.XYZ
  }
}

I have created my own but I am having other issues with my approach in the context of integration tests with TestHost and a custom WebApplicationFactory.

DbProviderFactories.RegisterFactory("Microsoft.Data.Sqlite", SqlClientFactory.Instance);
services.AddScoped((sp) =>
{
    return new Database("sqlite", sqliteConnectionString, "Microsoft.Data.Sqlite");
});

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WebApplication.CreateBuilder and AddDataTables usage shown in the issue, then review the Database registration and the TestHost/custom WebApplicationFactory context. Confirm the intended dependency-injection extension surface and how it should behave in integration tests. Done means the registration works for the shown SQLite setup without the reported testing issues.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sqlite
Domain
backend, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.