Alemvik 1.0.5

Install-Package Alemvik -Version 1.0.5
dotnet add package Alemvik --version 1.0.5
<PackageReference Include="Alemvik" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Alemvik --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Alemvik, 1.0.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Alemvik as a Cake Addin
#addin nuget:?package=Alemvik&version=1.0.5

// Install Alemvik as a Cake Tool
#tool nuget:?package=Alemvik&version=1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Alemvik

Packs many [mostly] static features

Demo for the Db class

appsettings.json

{
"DataSources": [
  { "MySqlSrvA": { "MySql.Data.MySqlClient": "DataSource=localhost;port=3306;Database=Skillango;uid=root;pwd=secret" } }
]
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.IO;
using System.Linq;
using Microsoft.Extensions.Configuration;
using Alemvik;

public static readonly IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();

static void InitDatabase() {
DbProviderFactories.RegisterFactory("MySql.Data.MySqlClient", MySql.Data.MySqlClient.MySqlClientFactory.Instance);

List<(string nme, string ado, string con)> dataSources = config.GetSection("DataSources")
  .Get<Dictionary<string, Dictionary<string, string>>[]>() // make sure you included Microsoft.Extensions.Configuration.Binder
  .SelectMany(i => i)
  .Select(i => ValueTuple.Create(i.Key, i.Value.First().Key, i.Value.First().Value))
  .ToList();
Db.Init(dataSources); // or direct: Db.Init(new Emvie.DataSource[] { new("MySqlSrvA", "MySql.Data.MySqlClient", "DataSource=localhost;port=3306;Database=Skillango;uid=root;pwd=secret") });
}

static void TestMySql() {
var tbl = Db.ToTbl("MySqlSrvA", 0, "select Name, Manager, Title from Skillango.User order by Name limit 25;", EFillOption.Data, 0, 15);
foreach (DataRow dr in tbl.Rows) Console.WriteLine($"{dr[0]}{new String(' ', Math.Max(40 - ((string)dr[0]).Length, 3))}{dr[1]}{new String(' ', Math.Max(30 - ((string)dr[1]).Length, 3))}{dr[2]}");

Db.BeginTransaction("MySqlSrvA");
int i = (int)Db.ExecNonQry("MySqlSrvA", 0, "update Skillango.User set Title='Cyber Security Specialist' where Name='Alain Trépanier';", 0);
Db.CommitTransaction("MySqlSrvA");

long count = (long)Db.ExecScalar("MySqlSrvA", 0, "select count(*) from Skillango.User where Name like @NameMask;", 0, "@NameMask", "a%");

tbl = Db.ToTbl("MySqlSrvA", 0, $"insert into Skillango.log (Type,Host,ApplicationUser,Application,Process,Message) values ('Warning','{Environment.MachineName} ({Environment.OSVersion})','{Environment.UserName}','Test','TestMySql','Msg6'), ('Message','{Environment.MachineName} ({Environment.OSVersion})','{Environment.UserName}','Test','TestMySql',@msg7); select ROW_COUNT(), LAST_INSERT_ID() as FirstAutoInc;", EFillOption.Data, 0, 0, "@msg7", "Message 7");

Console.WriteLine($"\n{i};{Db.ServerAndDbName("MySqlSrvA")};count={count}; RowCount: {tbl.Rows[0][0]}; FirstAutoInc: {tbl.Rows[0]["FirstAutoInc"]}");
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 0 1/18/2022
1.0.4 131 10/19/2021

Initial release