mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-18 06:10:56 +08:00
- 修复 PgCopy DateTime 映射 date 失败的情况;
This commit is contained in:
@@ -7,7 +7,6 @@ using NpgsqlTypes;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -208,10 +207,12 @@ public static partial class FreeSqlPostgreSQLGlobalExtensions
|
|||||||
var trycol = insert._table.Columns[col.ColumnName];
|
var trycol = insert._table.Columns[col.ColumnName];
|
||||||
var tp = insert._orm.CodeFirst.GetDbInfo(trycol.Attribute.MapType)?.type;
|
var tp = insert._orm.CodeFirst.GetDbInfo(trycol.Attribute.MapType)?.type;
|
||||||
if (tp != null) npgsqlDbType = (NpgsqlDbType)tp.Value;
|
if (tp != null) npgsqlDbType = (NpgsqlDbType)tp.Value;
|
||||||
if (npgsqlDbType.HasValue && npgsqlDbType != NpgsqlDbType.Unknown)
|
if (npgsqlDbType == null || npgsqlDbType == NpgsqlDbType.Unknown)
|
||||||
writer.Write(item[col.ColumnName], npgsqlDbType.Value);
|
|
||||||
else
|
|
||||||
writer.Write(item[col.ColumnName]);
|
writer.Write(item[col.ColumnName]);
|
||||||
|
else if (npgsqlDbType == NpgsqlDbType.Date && item[col.ColumnName] != null && (item[col.ColumnName] is DateTime || item[col.ColumnName] is DateTime?))
|
||||||
|
writer.Write(((DateTime)item[col.ColumnName]).ToString("yyyy-MM-dd"), npgsqlDbType.Value);
|
||||||
|
else
|
||||||
|
writer.Write(item[col.ColumnName], npgsqlDbType.Value);
|
||||||
}
|
}
|
||||||
//writer.WriteRow(item.ItemArray); #1532
|
//writer.WriteRow(item.ItemArray); #1532
|
||||||
}
|
}
|
||||||
@@ -307,10 +308,12 @@ public static partial class FreeSqlPostgreSQLGlobalExtensions
|
|||||||
var trycol = insert._table.Columns[col.ColumnName];
|
var trycol = insert._table.Columns[col.ColumnName];
|
||||||
var tp = insert._orm.CodeFirst.GetDbInfo(trycol.Attribute.MapType)?.type;
|
var tp = insert._orm.CodeFirst.GetDbInfo(trycol.Attribute.MapType)?.type;
|
||||||
if (tp != null) npgsqlDbType = (NpgsqlDbType)tp.Value;
|
if (tp != null) npgsqlDbType = (NpgsqlDbType)tp.Value;
|
||||||
if (npgsqlDbType.HasValue && npgsqlDbType != NpgsqlDbType.Unknown)
|
if (npgsqlDbType == null || npgsqlDbType == NpgsqlDbType.Unknown)
|
||||||
await writer.WriteAsync(item[col.ColumnName], npgsqlDbType.Value, cancellationToken);
|
|
||||||
else
|
|
||||||
await writer.WriteAsync(item[col.ColumnName], cancellationToken);
|
await writer.WriteAsync(item[col.ColumnName], cancellationToken);
|
||||||
|
else if (npgsqlDbType == NpgsqlDbType.Date && item[col.ColumnName] != null && (item[col.ColumnName] is DateTime || item[col.ColumnName] is DateTime?))
|
||||||
|
await writer.WriteAsync(((DateTime)item[col.ColumnName]).ToString("yyyy-MM-dd"), npgsqlDbType.Value, cancellationToken);
|
||||||
|
else
|
||||||
|
await writer.WriteAsync(item[col.ColumnName], npgsqlDbType.Value, cancellationToken);
|
||||||
}
|
}
|
||||||
//await writer.WriteRowAsync(cancellationToken, item.ItemArray); #1532
|
//await writer.WriteRowAsync(cancellationToken, item.ItemArray); #1532
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user