Update questdb bulkcopy

This commit is contained in:
sunkaixuan
2024-04-20 16:43:35 +08:00
parent e756b928fc
commit ec918466bc
2 changed files with 42 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
using CsvHelper.Configuration;
using CsvHelper.TypeConversion;
using CsvHelper;
using System;
using System.Collections.Generic;
using System.Text;
namespace SqlSugar
{
public class CsvHelperEnumToIntConverter : ITypeConverter
{
public string ConvertToString(object value, IWriterRow row, MemberMapData memberMapData)
{
if (value == null)
{
return "null";
}
else if (value is Enum enumValue)
{
return (Convert.ToInt32(enumValue)).ToString();
}
throw new NotSupportedException();
}
public object ConvertFromString(string text, IReaderRow row, MemberMapData memberMapData)
{
if (int.TryParse(text, out int intValue))
{
return text;
}
throw new NotSupportedException();
}
}
}