Underground.ORM
0.0.0-preview
This is a prerelease version of Underground.ORM.
dotnet add package Underground.ORM --version 0.0.0-preview
NuGet\Install-Package Underground.ORM -Version 0.0.0-preview
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="Underground.ORM" Version="0.0.0-preview" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Underground.ORM --version 0.0.0-preview
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Underground.ORM, 0.0.0-preview"
#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.
// Install Underground.ORM as a Cake Addin #addin nuget:?package=Underground.ORM&version=0.0.0-preview&prerelease // Install Underground.ORM as a Cake Tool #tool nuget:?package=Underground.ORM&version=0.0.0-preview&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Underground.ORM
Example code:
Initialization:
MySqlConnectionStringBuilder sb = new();
sb.Server = "localhost";
sb.Port = 3306;
sb.UserID = "root";
sb.Password = "12345678";
sb.Database = "underground_orm_tests";
sb.AllowUserVariables = true;
var orm = new OrmEngine(sb) { EnsureCreateDatabase = true };
Method declared in CSharp syntax to translate:
[MySqlFunctionScope("MySqlFunctionName")]
private int SumMethodFunction(int a, int b)
{
// Simples
int var1;
int? var2 = null;
int var3 = 1;
// Usando expressões
int var4 = 1 + a;
int var5 = 1 + a + b;
int var6 = (1 + (a - b)) * 3;
// Usando múltiplas variáveis
int var7, var8, var9 = 4;
int var10 = 1, var11 = 2, var12 = 3;
int? var13 = 4, var14 = 5, var15 = null;
int? var16 = null, var17, var18 = 9;
int var19 = a, var20 = b;
// Usando conversões cast
int var21 = (int)1;
int var22 = (int)1 + (int)2;
int var23 = (int)1 + ((int)2 - ((int)3 + 5) - (int)3);
// Usando conversões cast estranhas
int var24 = (int)(((5)));
int var25 = (int)(1 + 2 + 3);
int var26 = (int)(((1 + 2 + 3))) - 2;
int var27 = (int)(((1 + (2) + ((3))))) - ((int)((2)));
int result = var3 + var4 + var5 + var6 + var20;
return result;
}
Build the function statement:
var builtFunction = orm.BuildFunctionCreateStatement<int, int, int>(SumMethodFunction);
Update function in database:
await orm.UpdateDatabaseAsync(builtFunction);
Invoke method in server-side:
var result = await orm.RunFunctionAsync(SumMethodFunction, 10, 5);
Result in MySql syntax:
CREATE FUNCTION `MySqlFunctionName` (`a` INT, `b` INT)
RETURNS INT
BEGIN
# Simples
DECLARE `var1` INT;
DECLARE `var2` INT DEFAULT null;
DECLARE `var3` INT DEFAULT 1;
# Usando expressões
DECLARE `var4` INT DEFAULT 1+`a`;
DECLARE `var5` INT DEFAULT 1+`a`+`b`;
DECLARE `var6` INT DEFAULT (1+(`a`-`b`))*3;
# Usando múltiplas variáveis
DECLARE `var7` INT;
DECLARE `var8` INT;
DECLARE `var9` INT DEFAULT 4;
DECLARE `var10` INT DEFAULT 1;
DECLARE `var11` INT DEFAULT 2;
DECLARE `var12` INT DEFAULT 3;
DECLARE `var13` INT DEFAULT 4;
DECLARE `var14` INT DEFAULT 5;
DECLARE `var15` INT DEFAULT null;
DECLARE `var16` INT DEFAULT null;
DECLARE `var17` INT;
DECLARE `var18` INT DEFAULT 9;
DECLARE `var19` INT DEFAULT `a`;
DECLARE `var20` INT DEFAULT `b`;
# Usando conversões cast
DECLARE `var21` INT DEFAULT CAST(1 AS SIGNED INT);
DECLARE `var22` INT DEFAULT CAST(1 AS SIGNED INT)+CAST(2 AS SIGNED INT);
DECLARE `var23` INT DEFAULT CAST(1 AS SIGNED INT)+(CAST(2 AS SIGNED INT)-(CAST(3 AS SIGNED INT)+5)-CAST(3 AS SIGNED INT));
# Usando conversões cast estranhas
DECLARE `var24` INT DEFAULT CAST((((5))) AS SIGNED INT);
DECLARE `var25` INT DEFAULT CAST((1+2+3) AS SIGNED INT);
DECLARE `var26` INT DEFAULT CAST((((1+2+3))) AS SIGNED INT)-2;
DECLARE `var27` INT DEFAULT CAST((((1+(2)+((3))))) AS SIGNED INT)-(CAST(((2)) AS SIGNED INT));
DECLARE `result` INT DEFAULT `var3`+`var4`+`var5`+`var6`+`var20`;
RETURN `result`;
END;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.CodeAnalysis.CSharp (>= 4.6.0)
- MySqlConnector (>= 2.2.6)
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 |
---|---|---|
0.0.0-preview | 116 | 6/1/2023 |
Release of the first version for testing. Currently this package is limited to performing syntax conversions of variable declarations from csharp to mysql 8 with int, uint, long, ulong as can be seen in the unit tests of the package.