- 修复 MySqlProvider .NetFramework 下可能报初始化类型错误;

This commit is contained in:
2881099
2023-05-20 17:02:07 +08:00
parent e7177991ad
commit 76b18d84a7
6 changed files with 300 additions and 270 deletions

View File

@ -9,9 +9,13 @@ namespace FreeSql.Sqlite
public class SqliteProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
{
static SqliteProvider()
static int _firstInit = 1;
static void InitInternal()
{
Select0Provider._dicMethodDataReaderGetValue[typeof(Guid)] = typeof(DbDataReader).GetMethod("GetGuid", new Type[] { typeof(int) });
if (Interlocked.Exchange(ref _firstInit, 0) == 1) //不能放在 static ctor .NetFramework 可能报初始化类型错误
{
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);
@ -22,6 +26,7 @@ namespace FreeSql.Sqlite
public SqliteProvider(string masterConnectionString, string[] slaveConnectionString, Func<DbConnection> connectionFactory = null)
{
InitInternal();
this.InternalCommonUtils = new SqliteUtils(this);
this.InternalCommonExpression = new SqliteExpression(this.InternalCommonUtils);