mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 修复 MySqlProvider .NetFramework 下可能报初始化类型错误;
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user