mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Synchronization code
This commit is contained in:
parent
44a15fdbfa
commit
5a1164e536
@ -385,7 +385,16 @@ WHERE tgrelid = '"+tableName+"'::regclass");
|
|||||||
}
|
}
|
||||||
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
||||||
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
|
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
|
||||||
connection = connection.Replace(oldDatabaseName, "postgres");
|
if (Regex.Matches(connection, oldDatabaseName).Count > 1)
|
||||||
|
{
|
||||||
|
var builder = new Npgsql.NpgsqlConnectionStringBuilder(connection);
|
||||||
|
builder.Database = "postgres";
|
||||||
|
connection = builder.ConnectionString;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connection = connection.Replace(oldDatabaseName, "postgres");
|
||||||
|
}
|
||||||
var newDb = new SqlSugarClient(new ConnectionConfig()
|
var newDb = new SqlSugarClient(new ConnectionConfig()
|
||||||
{
|
{
|
||||||
DbType = this.Context.CurrentConnectionConfig.DbType,
|
DbType = this.Context.CurrentConnectionConfig.DbType,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@ -93,6 +94,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return FormatDateTimeOffset(it.Value);
|
return FormatDateTimeOffset(it.Value);
|
||||||
}
|
}
|
||||||
|
else if (it.Value is decimal v)
|
||||||
|
{
|
||||||
|
return v.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
else if (it.IsArray&&it.Value!=null)
|
else if (it.IsArray&&it.Value!=null)
|
||||||
{
|
{
|
||||||
return FormatValue(it.Value,it.PropertyName,i,it);
|
return FormatValue(it.Value,it.PropertyName,i,it);
|
||||||
@ -172,6 +177,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return "'" + value.ToString().ToSqlFilter() + "'";
|
return "'" + value.ToString().ToSqlFilter() + "'";
|
||||||
}
|
}
|
||||||
|
else if (value is decimal v)
|
||||||
|
{
|
||||||
|
return v.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "'" + value.ToString() + "'";
|
return "'" + value.ToString() + "'";
|
||||||
@ -229,6 +238,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return N + "'" + Convert.ToDouble(value).ToString() + "'";
|
return N + "'" + Convert.ToDouble(value).ToString() + "'";
|
||||||
}
|
}
|
||||||
|
else if (value is decimal v)
|
||||||
|
{
|
||||||
|
return v.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return N + "'" + value.ToString() + "'";
|
return N + "'" + value.ToString() + "'";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@ -43,15 +44,15 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var type =UtilMethods.GetUnderType(value.GetType());
|
var type =UtilMethods.GetUnderType(value.GetType());
|
||||||
if (type == UtilConstants.ByteArrayType||type == UtilConstants.DateType||columnInfo.IsArray||columnInfo.IsJson)
|
if (type == UtilConstants.ByteArrayType || type == UtilConstants.DateType || columnInfo.IsArray || columnInfo.IsJson)
|
||||||
{
|
{
|
||||||
var parameterName = this.Builder.SqlParameterKeyWord + name +"_"+ i;
|
var parameterName = this.Builder.SqlParameterKeyWord + name + "_" + i;
|
||||||
var paramter = new SugarParameter(parameterName, value);
|
var paramter = new SugarParameter(parameterName, value);
|
||||||
if (columnInfo.IsJson)
|
if (columnInfo.IsJson)
|
||||||
{
|
{
|
||||||
paramter.IsJson = true;
|
paramter.IsJson = true;
|
||||||
}
|
}
|
||||||
if (columnInfo.IsArray)
|
if (columnInfo.IsArray)
|
||||||
{
|
{
|
||||||
paramter.IsArray = true;
|
paramter.IsArray = true;
|
||||||
}
|
}
|
||||||
@ -86,6 +87,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return "'" + value.ToString().ToSqlFilter() + "'";
|
return "'" + value.ToString().ToSqlFilter() + "'";
|
||||||
}
|
}
|
||||||
|
else if (value is decimal v)
|
||||||
|
{
|
||||||
|
return v.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "'" + value.ToString() + "'";
|
return "'" + value.ToString() + "'";
|
||||||
|
Loading…
Reference in New Issue
Block a user