Skip to content

Commit

Permalink
More work
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Sep 7, 2024
1 parent 26f0caf commit 5fc3f54
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions GangsImpl/SQL/SQLInstanceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,17 @@ public void ClearCache() { }
$"SELECT {(typeof(TV).IsPrimitive ? statId : getFieldNames<TV>())} FROM {table_prefix}_{statId} WHERE GangId = @GangId",
new { GangId = key });
return (true, result);
} catch (InvalidOperationException e) {
Console.WriteLine(e);
return (false, default);
}
} catch (InvalidOperationException) { return (false, default); }
}

public async Task<bool> SetForGang<TV>(int gangId, string statId, TV value) {
await createTable<TV>(statId);
// var fields = typeof(TV).GetRuntimeFields().ToList();
var fields = typeof(TV)
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.ToList();

// var fieldNames = fields.Select(f => f.Name).ToList();

// var columns = string.Join(", ", fieldNames);
var columns = getFieldNames<TV>();
// var values = string.Join(", ", fieldNames.Select(f => $"@{f}"));
var values = getFieldNames<TV>("@");
var values = getFieldNames<TV>("@");

if (typeof(TV).IsPrimitive) {
columns = statId;
Expand Down Expand Up @@ -111,7 +103,6 @@ virtual protected string GetDBType(Type type) {
}

private async Task createTable<TV>(string id) {
// Get public fields of TV
var fields = typeof(TV)
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.ToList();
Expand Down

0 comments on commit 5fc3f54

Please sign in to comment.