mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
增加Microsoft.Data.Sqlite.Core的实现
This commit is contained in:
@ -5,7 +5,11 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
#if MicrosoftData
|
||||
using Microsoft.Data.Sqlite;
|
||||
#else
|
||||
using System.Data.SQLite;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
@ -72,7 +76,12 @@ namespace FreeSql.Sqlite
|
||||
cmd.Connection = null;
|
||||
return cmd;
|
||||
}
|
||||
return new SQLiteCommand();
|
||||
#if MicrosoftData
|
||||
return new SqliteCommand();
|
||||
#else
|
||||
return new SQLiteCommand();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public override void ReturnConnection(IObjectPool<DbConnection> pool, Object<DbConnection> conn, Exception ex)
|
||||
|
@ -4,7 +4,11 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
#if MicrosoftData
|
||||
using Microsoft.Data.Sqlite;
|
||||
#else
|
||||
using System.Data.SQLite;
|
||||
#endif
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -34,7 +38,11 @@ namespace FreeSql.Sqlite
|
||||
|
||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||
{
|
||||
#if MicrosoftData
|
||||
if (exception != null && exception is SqliteException)
|
||||
#else
|
||||
if (exception != null && exception is SQLiteException)
|
||||
#endif
|
||||
{
|
||||
try { if (obj.Value.Ping() == false) obj.Value.OpenAndAttach(policy.Attaches); } catch { base.SetUnavailable(exception); }
|
||||
}
|
||||
@ -128,7 +136,11 @@ namespace FreeSql.Sqlite
|
||||
|
||||
public DbConnection OnCreate()
|
||||
{
|
||||
#if MicrosoftData
|
||||
var conn = new SqliteConnection(_connectionString);
|
||||
#else
|
||||
var conn = new SQLiteConnection(_connectionString);
|
||||
#endif
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
@ -366,8 +366,21 @@ namespace FreeSql.Sqlite
|
||||
{
|
||||
case "Abs": return $"abs({getExp(exp.Arguments[0])})";
|
||||
case "Sign": return $"sign({getExp(exp.Arguments[0])})";
|
||||
#if MicrosoftData
|
||||
case "Floor":
|
||||
{
|
||||
var funExp = getExp(exp.Arguments[0]);
|
||||
return $"cast({funExp} as int) - ({funExp} < cast({funExp} as int))";
|
||||
};
|
||||
case "Ceiling":
|
||||
{
|
||||
var funExp = getExp(exp.Arguments[0]);
|
||||
return $"cast ({funExp} as int ) + ({funExp} > cast ({funExp} as int ))";
|
||||
};
|
||||
#else
|
||||
case "Floor": return $"floor({getExp(exp.Arguments[0])})";
|
||||
case "Ceiling": return $"ceiling({getExp(exp.Arguments[0])})";
|
||||
#endif
|
||||
case "Round":
|
||||
if (exp.Arguments.Count > 1 && exp.Arguments[1].Type.FullName == "System.Int32") return $"round({getExp(exp.Arguments[0])}, {getExp(exp.Arguments[1])})";
|
||||
return $"round({getExp(exp.Arguments[0])})";
|
||||
|
@ -4,7 +4,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
#if MicrosoftData
|
||||
using Microsoft.Data.Sqlite;
|
||||
#else
|
||||
using System.Data.SQLite;
|
||||
#endif
|
||||
using System.Globalization;
|
||||
|
||||
namespace FreeSql.Sqlite
|
||||
@ -33,7 +37,11 @@ namespace FreeSql.Sqlite
|
||||
dbtype = DbType.Int64;
|
||||
break;
|
||||
}
|
||||
#if MicrosoftData
|
||||
var ret = new SqliteParameter();
|
||||
#else
|
||||
var ret = new SQLiteParameter();
|
||||
#endif
|
||||
ret.ParameterName = QuoteParamterName(parameterName);
|
||||
ret.DbType = dbtype;
|
||||
ret.Value = value;
|
||||
@ -62,7 +70,11 @@ namespace FreeSql.Sqlite
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if MicrosoftData
|
||||
var ret = new SqliteParameter();
|
||||
#else
|
||||
var ret = new SQLiteParameter();
|
||||
#endif
|
||||
ret.ParameterName = $"@{name}";
|
||||
if (dbtype != null) ret.DbType = dbtype.Value;
|
||||
ret.Value = value;
|
||||
|
Reference in New Issue
Block a user