changes
This commit is contained in:
parent
76418aee19
commit
6a0424d9f1
31
DbService.cs
31
DbService.cs
@ -1,14 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MySqlConnector;
|
||||
using de.hottis.genericdatabaseapiservice.Models;
|
||||
|
||||
namespace de.hottis.genericdatabaseapiservice.Services {
|
||||
public interface IDbService {
|
||||
void JustDoSomething(string msg);
|
||||
void JustDoSomething<T>(string msg);
|
||||
|
||||
}
|
||||
|
||||
public class DbService : IDbService {
|
||||
public void JustDoSomething(string msg) {
|
||||
async public void JustDoSomething<T>(string msg) {
|
||||
Console.WriteLine(msg);
|
||||
|
||||
var item = Activator.CreateInstance<T>();
|
||||
|
||||
using (var conn = new MySqlConnection("Server=172.16.10.18;User ID=apiservicetestdb;Password=geheim123;Database=apiservicetestdb")) {
|
||||
await conn.OpenAsync();
|
||||
|
||||
using (var cmd = conn.CreateCommand()) {
|
||||
// cmd.CommandText = "INSERT INTO test1 (txt, nr) VALUES (@txt, @nr)";
|
||||
// cmd.Parameters.AddWithValue("txt", "txt1");
|
||||
// cmd.Parameters.AddWithValue("nr", 12);
|
||||
// await cmd.ExecuteNonQueryAsync();
|
||||
cmd.CommandText = "SELECT id, txt, nr FROM test1";
|
||||
using (var reader = await cmd.ExecuteReaderAsync()) {
|
||||
while (await reader.ReadAsync()) {
|
||||
foreach (var propertyInfo in typeof(T).GetProperties()) {
|
||||
Console.WriteLine(propertyInfo);
|
||||
}
|
||||
Console.WriteLine(reader.GetString("txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ echo "generate server code and endpoint stubs from openapi.yaml"
|
||||
docker run -it --rm -v $PWD:/work -u $UID openapitools/openapi-generator:cli-v5.1.0 \
|
||||
generate -i /work/openapi.yaml -g aspnetcore -o /work/output \
|
||||
--package-name $PACKAGE_NAME \
|
||||
--additional-properties="packageVersion=0.0.1,aspnetCoreVersion=5.0,operationIsAsync=true,modelPropertyNaming=camelCase,\
|
||||
--additional-properties="packageVersion=0.0.1,aspnetCoreVersion=5.0,operationIsAsync=true,\
|
||||
generateBody=false,classModifier=abstract,operationModifier=abstract"
|
||||
|
||||
echo "patch DbService registering into generated startup code"
|
||||
|
@ -65,6 +65,9 @@ paths:
|
||||
from test1
|
||||
where nr = ?
|
||||
STATEMENTEND
|
||||
INPUTMAPPINGBEGIN
|
||||
nr = Nummer
|
||||
INPUTMAPPINGEND
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
||||
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
|
||||
|
Loading…
x
Reference in New Issue
Block a user