Skip to content

Commit cbe44fa

Browse files
author
“llt”
committed
Better AOTDLL parameterization
1 parent 2e1fa37 commit cbe44fa

9 files changed

Lines changed: 296 additions & 200 deletions

File tree

frameworks/CSharp/appmpower/src/appMpower.Orm/Data/DbConnection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Concurrent;
22
using System.Collections.Generic;
33
using System.Data;
4+
using System.Threading.Tasks;
45

56
namespace appMpower.Orm.Data
67
{
@@ -129,15 +130,13 @@ public void Open()
129130
}
130131
}
131132

132-
/*
133133
public async Task OpenAsync()
134134
{
135135
if (_dbConnection.State == ConnectionState.Closed)
136136
{
137137
await _dbConnection.OpenAsync();
138138
}
139139
}
140-
*/
141140

142141
public void Dispose()
143142
{

frameworks/CSharp/appmpower/src/appMpower.Orm/DotnetMethods.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Text.Json;
6+
using System.Threading.Tasks;
67
using appMpower.Orm.Data;
78
using appMpower.Orm.Objects;
89
using appMpower.Orm.Serializers;
@@ -35,9 +36,9 @@ public static void DbProvider(int dbProvider)
3536
DbFactory.SetInstance();
3637
}
3738

38-
public static byte[] Db()
39+
public static async Task<byte[]> Db()
3940
{
40-
var world = RawDb.LoadSingleQueryRow();
41+
var world = await RawDb.LoadSingleQueryRowAsync();
4142

4243
var memoryStream = new MemoryStream();
4344
using var utf8JsonWriter = new Utf8JsonWriter(memoryStream, _jsonWriterOptions);
@@ -47,9 +48,9 @@ public static byte[] Db()
4748
return memoryStream.ToArray();
4849
}
4950

50-
public static byte[] DbById(int id)
51+
public static async Task<byte[]> DbById(int id)
5152
{
52-
var world = RawDb.LoadSingleQueryRowById(id);
53+
var world = await RawDb.LoadSingleQueryRowByIdAsync(id);
5354

5455
var memoryStream = new MemoryStream();
5556
using var utf8JsonWriter = new Utf8JsonWriter(memoryStream, _jsonWriterOptions);
@@ -59,9 +60,9 @@ public static byte[] DbById(int id)
5960
return memoryStream.ToArray();
6061
}
6162

62-
public static byte[] Query(int queries)
63+
public static async Task<byte[]> Query(int queries)
6364
{
64-
World[] worlds = RawDb.ReadMultipleRows(queries);
65+
World[] worlds = await RawDb.ReadMultipleRowsAsync(queries);
6566

6667
var memoryStream = new MemoryStream();
6768
using var utf8JsonWriter = new Utf8JsonWriter(memoryStream, _jsonWriterOptions);
@@ -71,9 +72,9 @@ public static byte[] Query(int queries)
7172
return memoryStream.ToArray();
7273
}
7374

74-
public static byte[] Updates(int count)
75+
public static async Task<byte[]> Updates(int count)
7576
{
76-
World[] worlds = RawDb.LoadMultipleUpdatesRows(count);
77+
World[] worlds = await RawDb.LoadMultipleUpdatesRowsAsync(count);
7778

7879
var memoryStream = new MemoryStream();
7980
using var utf8JsonWriter = new Utf8JsonWriter(memoryStream, _jsonWriterOptions);
@@ -83,9 +84,9 @@ public static byte[] Updates(int count)
8384
return memoryStream.ToArray();
8485
}
8586

86-
public static byte[] Fortunes()
87+
public static async Task<byte[]> Fortunes()
8788
{
88-
List<Fortune> fortunes = RawDb.LoadFortunesRows();
89+
List<Fortune> fortunes = await RawDb.LoadFortunesRowsAsync();
8990
string fortunesView = FortunesView.Render(fortunes);
9091
byte[] byteArray = Encoding.UTF8.GetBytes(fortunesView);
9192

0 commit comments

Comments
 (0)