mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 修复 MySqlProvider .NetFramework 下可能报初始化类型错误;
This commit is contained in:
parent
e7177991ad
commit
76b18d84a7
@ -13,7 +13,10 @@ namespace FreeSql.MySql
|
|||||||
|
|
||||||
public class MySqlProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class MySqlProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
static MySqlProvider()
|
static int _firstInit = 1;
|
||||||
|
static void InitInternal()
|
||||||
|
{
|
||||||
|
if (Interlocked.Exchange(ref _firstInit, 0) == 1) //不能放在 static ctor .NetFramework 可能报初始化类型错误
|
||||||
{
|
{
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(MygisPoint)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(MygisPoint)] = true;
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(MygisLineString)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(MygisLineString)] = true;
|
||||||
@ -41,6 +44,7 @@ namespace FreeSql.MySql
|
|||||||
Select0Provider._dicMethodDataReaderGetValueOverride[DataType.MySql][typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
Select0Provider._dicMethodDataReaderGetValueOverride[DataType.MySql][typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
Select0Provider._dicMethodDataReaderGetValueOverride[DataType.MySql][typeof(DateTimeOffset)] = typeof(DbDataReader).GetMethod("GetDateTime", new Type[] { typeof(int) });
|
Select0Provider._dicMethodDataReaderGetValueOverride[DataType.MySql][typeof(DateTimeOffset)] = typeof(DbDataReader).GetMethod("GetDateTime", new Type[] { typeof(int) });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new MySqlSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new MySqlSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
public override IInsert<T1> CreateInsertProvider<T1>() => new MySqlInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
public override IInsert<T1> CreateInsertProvider<T1>() => new MySqlInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
@ -50,6 +54,7 @@ namespace FreeSql.MySql
|
|||||||
|
|
||||||
public MySqlProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
public MySqlProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
||||||
{
|
{
|
||||||
|
InitInternal();
|
||||||
this.InternalCommonUtils = new MySqlUtils(this);
|
this.InternalCommonUtils = new MySqlUtils(this);
|
||||||
this.InternalCommonExpression = new MySqlExpression(this.InternalCommonUtils);
|
this.InternalCommonExpression = new MySqlExpression(this.InternalCommonUtils);
|
||||||
|
|
||||||
|
@ -21,7 +21,10 @@ namespace FreeSql.PostgreSQL
|
|||||||
|
|
||||||
public class PostgreSQLProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class PostgreSQLProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
static PostgreSQLProvider()
|
static int _firstInit = 1;
|
||||||
|
static void InitInternal()
|
||||||
|
{
|
||||||
|
if (Interlocked.Exchange(ref _firstInit, 0) == 1) //不能放在 static ctor .NetFramework 可能报初始化类型错误
|
||||||
{
|
{
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
||||||
@ -107,6 +110,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
|
|
||||||
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new PostgreSQLSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new PostgreSQLSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
public override IInsert<T1> CreateInsertProvider<T1>() => new PostgreSQLInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
public override IInsert<T1> CreateInsertProvider<T1>() => new PostgreSQLInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
@ -116,6 +120,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
|
|
||||||
public PostgreSQLProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
public PostgreSQLProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
||||||
{
|
{
|
||||||
|
InitInternal();
|
||||||
this.InternalCommonUtils = new PostgreSQLUtils(this);
|
this.InternalCommonUtils = new PostgreSQLUtils(this);
|
||||||
this.InternalCommonExpression = new PostgreSQLExpression(this.InternalCommonUtils);
|
this.InternalCommonExpression = new PostgreSQLExpression(this.InternalCommonUtils);
|
||||||
|
|
||||||
|
@ -21,7 +21,10 @@ namespace FreeSql.QuestDb
|
|||||||
{
|
{
|
||||||
public class QuestDbProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class QuestDbProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
static QuestDbProvider()
|
static int _firstInit = 1;
|
||||||
|
static void InitInternal()
|
||||||
|
{
|
||||||
|
if (Interlocked.Exchange(ref _firstInit, 0) == 1) //不能放在 static ctor .NetFramework 可能报初始化类型错误
|
||||||
{
|
{
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
||||||
@ -120,6 +123,7 @@ namespace FreeSql.QuestDb
|
|||||||
service.AddHttpClient();
|
service.AddHttpClient();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) =>
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) =>
|
||||||
new QuestDbSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
new QuestDbSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
@ -139,6 +143,7 @@ namespace FreeSql.QuestDb
|
|||||||
public QuestDbProvider(string masterConnectionString, string[] slaveConnectionString,
|
public QuestDbProvider(string masterConnectionString, string[] slaveConnectionString,
|
||||||
Func<DbConnection> connectionFactory = null)
|
Func<DbConnection> connectionFactory = null)
|
||||||
{
|
{
|
||||||
|
InitInternal();
|
||||||
this.InternalCommonUtils = new QuestDbUtils(this);
|
this.InternalCommonUtils = new QuestDbUtils(this);
|
||||||
this.InternalCommonExpression = new QuestDbExpression(this.InternalCommonUtils);
|
this.InternalCommonExpression = new QuestDbExpression(this.InternalCommonUtils);
|
||||||
|
|
||||||
|
@ -9,10 +9,14 @@ namespace FreeSql.SqlServer
|
|||||||
|
|
||||||
public class SqlServerProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class SqlServerProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
static SqlServerProvider()
|
static int _firstInit = 1;
|
||||||
|
static void InitInternal()
|
||||||
|
{
|
||||||
|
if (Interlocked.Exchange(ref _firstInit, 0) == 1) //不能放在 static ctor .NetFramework 可能报初始化类型错误
|
||||||
{
|
{
|
||||||
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new SqlServerSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new SqlServerSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
public override IInsert<T1> CreateInsertProvider<T1>() => new SqlServerInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
public override IInsert<T1> CreateInsertProvider<T1>() => new SqlServerInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
@ -22,6 +26,7 @@ namespace FreeSql.SqlServer
|
|||||||
|
|
||||||
public SqlServerProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
public SqlServerProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
||||||
{
|
{
|
||||||
|
InitInternal();
|
||||||
this.InternalCommonUtils = new SqlServerUtils(this);
|
this.InternalCommonUtils = new SqlServerUtils(this);
|
||||||
this.InternalCommonExpression = new SqlServerExpression(this.InternalCommonUtils);
|
this.InternalCommonExpression = new SqlServerExpression(this.InternalCommonUtils);
|
||||||
|
|
||||||
|
@ -9,10 +9,14 @@ namespace FreeSql.Sqlite
|
|||||||
|
|
||||||
public class SqliteProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class SqliteProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
static SqliteProvider()
|
static int _firstInit = 1;
|
||||||
|
static void InitInternal()
|
||||||
|
{
|
||||||
|
if (Interlocked.Exchange(ref _firstInit, 0) == 1) //不能放在 static ctor .NetFramework 可能报初始化类型错误
|
||||||
{
|
{
|
||||||
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new SqliteSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new SqliteSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
public override IInsert<T1> CreateInsertProvider<T1>() => new SqliteInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
public override IInsert<T1> CreateInsertProvider<T1>() => new SqliteInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
@ -22,6 +26,7 @@ namespace FreeSql.Sqlite
|
|||||||
|
|
||||||
public SqliteProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
public SqliteProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
||||||
{
|
{
|
||||||
|
InitInternal();
|
||||||
this.InternalCommonUtils = new SqliteUtils(this);
|
this.InternalCommonUtils = new SqliteUtils(this);
|
||||||
this.InternalCommonExpression = new SqliteExpression(this.InternalCommonUtils);
|
this.InternalCommonExpression = new SqliteExpression(this.InternalCommonUtils);
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@ namespace FreeSql.Xugu
|
|||||||
|
|
||||||
public class XuguProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
public class XuguProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
|
||||||
{
|
{
|
||||||
static XuguProvider()
|
static int _firstInit = 1;
|
||||||
|
static void InitInternal()
|
||||||
|
{
|
||||||
|
if (Interlocked.Exchange(ref _firstInit, 0) == 1) //不能放在 static ctor .NetFramework 可能报初始化类型错误
|
||||||
{
|
{
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BigInteger)] = true;
|
||||||
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
Utils.dicExecuteArrayRowReadClassOrTuple[typeof(BitArray)] = true;
|
||||||
@ -93,6 +96,7 @@ namespace FreeSql.Xugu
|
|||||||
|
|
||||||
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new XuguSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new XuguSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
|
||||||
public override IInsert<T1> CreateInsertProvider<T1>() => new XuguInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
public override IInsert<T1> CreateInsertProvider<T1>() => new XuguInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
|
||||||
@ -102,6 +106,7 @@ namespace FreeSql.Xugu
|
|||||||
|
|
||||||
public XuguProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
public XuguProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
|
||||||
{
|
{
|
||||||
|
InitInternal();
|
||||||
this.InternalCommonUtils = new XuguUtils(this);
|
this.InternalCommonUtils = new XuguUtils(this);
|
||||||
this.InternalCommonExpression = new XuguExpression(this.InternalCommonUtils);
|
this.InternalCommonExpression = new XuguExpression(this.InternalCommonUtils);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user