Update Questdb

This commit is contained in:
sunkaixuan
2024-03-31 20:03:40 +08:00
parent 24738f3a3c
commit 21c911842e

View File

@@ -1,4 +1,5 @@
using CsvHelper; using CsvHelper;
using CsvHelper.Configuration;
using CsvHelper.TypeConversion; using CsvHelper.TypeConversion;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
@@ -13,7 +14,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
using System.Xml.Linq; using System.Xml.Linq;
using System.Linq;
namespace SqlSugar namespace SqlSugar
{ {
/// <summary> /// <summary>
@@ -136,6 +137,7 @@ namespace SqlSugar
{ {
var options = new TypeConverterOptions { Formats = new[] { GetDefaultFormat() } }; var options = new TypeConverterOptions { Formats = new[] { GetDefaultFormat() } };
csv.Context.TypeConverterOptionsCache.AddOptions<DateTime>(options); csv.Context.TypeConverterOptionsCache.AddOptions<DateTime>(options);
CsvCreating<T>(csv);
await csv.WriteRecordsAsync(insertList); await csv.WriteRecordsAsync(insertList);
} }
@@ -182,6 +184,20 @@ namespace SqlSugar
return result; return result;
} }
private void CsvCreating<T>(CsvWriter csv) where T : class, new()
{
var entityColumns = db.EntityMaintenance.GetEntityInfo<T>().Columns;
if (entityColumns.Any(it => it.IsIgnore))
{
var customMap = new DefaultClassMap<T>();
foreach (var item in entityColumns.Where(it => !it.IsIgnore))
{
customMap.Map(typeof(T), item.PropertyInfo).Name(item.PropertyName);
}
csv.Context.RegisterClassMap(customMap);
}
}
private static string GetDefaultFormat() private static string GetDefaultFormat()
{ {
return "yyyy-MM-ddTHH:mm:ss.fffffff"; return "yyyy-MM-ddTHH:mm:ss.fffffff";