UskokDB.MySql 2.4.5

Additional Details

UskokDB 3.+ no longer supports this package

dotnet add package UskokDB.MySql --version 2.4.5
                    
NuGet\Install-Package UskokDB.MySql -Version 2.4.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UskokDB.MySql" Version="2.4.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UskokDB.MySql" Version="2.4.5" />
                    
Directory.Packages.props
<PackageReference Include="UskokDB.MySql" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UskokDB.MySql --version 2.4.5
                    
#r "nuget: UskokDB.MySql, 2.4.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UskokDB.MySql@2.4.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UskokDB.MySql&version=2.4.5
                    
Install as a Cake Addin
#tool nuget:?package=UskokDB.MySql&version=2.4.5
                    
Install as a Cake Tool

UskokDB

And extension library for UskokDB used for runtime table creating and inserting/replacing to the table, some examples:

Example

[TableName("tableName");
class Person : MySqlTable<Person>
{
    public string Name { get; set; }
    public string LastName { get; set; }
}
Console.WriteLine(Person.MySqlTableInitString);
//Same as above since it is a static property
Console.WriteLine(MySqlTable<Person>.MySqlTableInitString);

The resulting mysql string is

Create Table IF NOT EXISTS `tableName` (Name Text, LastName Text)

Example 2

//If no TableName attribute is found type name is used
class Person : MySqlTable<Person>
{
    [Key]
    public Guid Id;

    [MaxLength(20)]
    public string Name { get; set; }
    //Unless the length is specified the 
    public string LastName { get; set; }

    [AutoIncrement]//not how ages works but...
    public int Age {get;set;}

    [NotMapped]
    public string FullName
    {
        get 
        {
            return $"{Name} {LastName}"
        }
    }
}
//
Person person1 = new Person {
    Id = Guid.NewGuid(),
    Name = "Vuk",
    LastName = "Uskokovic",
    Age = 0
};
Person person2 = new Person {
    Id = Guid.NewGuid(),
    Name = "Vuk",
    LastName = "Uskokovic",
    Age = 0
};
using var connection = SomeConnectionFactory.New();
table.Insert(connection, person1);
await table.InsertAsync(connection, person2);
person1.Age = 21;//Lets say I aged 21 years
person2.Age = 22;
await table.ReplaceAsync(connection, person1);
table.Replace(connection, person2);

The resulting mysql for the table is

Create Table IF NOT EXISTS `Person` (Id VARHCAR(36) PRIMARY KEY, Name VARCHAR(20), LastName TEXT, Age INT AUTO_INCREMENT)

Example foreign key

[TableName("people")]
class Person : MySqlTable<Person>
{
    [Key]
    public Guid PersonKey { get; set; }
    
    public string Name {get; set; }
}

class Child : MySqlTable<Child>
{
    [ForeignKey<Person>]
    public Guid ParentId { get; set; }
    public string Name { get; set; }
}

The sql insert for Child type would be

CREATE TABLE IF NOT EXISTS `Child` (ParentId VARCHAR(36), Name TEXT, FOREIGN KEY (ParentId) REFERENCES people(PersonKey))
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.4.5 207 5/26/2024 2.4.5 is deprecated because it is no longer maintained.
2.4.4 153 5/25/2024
2.4.3 143 5/25/2024
2.4.2 138 5/25/2024
2.4.1 150 5/24/2024
2.4.0 157 5/24/2024
2.3.2 153 2/29/2024
2.3.1 148 2/28/2024
2.3.0 151 2/28/2024
2.2.0 208 8/16/2023
2.1.1 180 8/31/2023
2.1.0 198 8/7/2023
2.0.2 210 7/28/2023
2.0.1 204 7/28/2023
2.0.0 204 7/28/2023
1.9.0 205 7/19/2023
1.8.0 222 7/19/2023
1.7.0 275 4/21/2023
1.6.0 228 4/21/2023
1.5.0 244 4/21/2023
1.4.0 232 4/20/2023
1.3.0 246 4/12/2023
1.2.0 250 4/12/2023
1.1.0 229 4/10/2023
1.0.0 264 4/9/2023

Added TableInitUtil so now you can creates all tables in the code with a one liner