mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-03-21 09:11:20 +00:00
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
31 lines
826 B
C#
Executable file
31 lines
826 B
C#
Executable file
using Dapper;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
|
|
namespace FSO.Server.Database.DA.Utils
|
|
{
|
|
public static class BufferedInsert
|
|
{
|
|
public static void ExecuteBufferedInsert(this DbConnection connection, string query, IEnumerable<object> param, int batches)
|
|
{
|
|
var buffer = new List<object>();
|
|
var enumerator = param.GetEnumerator();
|
|
|
|
while (enumerator.MoveNext())
|
|
{
|
|
buffer.Add(enumerator.Current);
|
|
|
|
if(buffer.Count >= batches)
|
|
{
|
|
connection.Execute(query, buffer);
|
|
buffer.Clear();
|
|
}
|
|
}
|
|
|
|
if(buffer.Count > 0)
|
|
{
|
|
connection.Execute(query, buffer);
|
|
}
|
|
}
|
|
}
|
|
}
|