using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity.Infrastructure.Interception;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace CG.App.EFContext
{
///
/// Sqlite拦截器.
/// contains或indexOf成的CHARINDEX函数在sqlite里面并不支持,需要拦截转换成LIKE语句
///
public class SqliteInterceptor : IDbCommandInterceptor
{
private static Regex replaceRegex = new Regex(@"\(CHARINDEX\((.*?),\s?(.*?)\)\)\s*?>\s*?0");
public void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext interceptionContext)
{
}
public void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext interceptionContext)
{
}
public void ReaderExecuted(DbCommand command, DbCommandInterceptionContext interceptionContext)
{
}
public void ReaderExecuting(DbCommand command, DbCommandInterceptionContext interceptionContext)
{
ReplaceCharIndexFunc(command);
}
public void ScalarExecuted(DbCommand command, DbCommandInterceptionContext