using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class ConnectionConfig
{
///
///Connection unique code
///
public object ConfigId { get; set; }
///
///DbType.SqlServer Or Other
///
public DbType DbType { get; set; }
///
///Database Connection string
///
public string ConnectionString { get; set; }
///
/// QueryableWithAttr queries go to DbLinkName, which is commonly used for cross-library queries
///
public string DbLinkName { get; set; }
///
/// true does not need to close the connection
///
public bool IsAutoCloseConnection { get; set; }
///
/// Default Attribute
///
public InitKeyType InitKeyType = InitKeyType.Attribute;
///
/// Exception prompt language
///
public LanguageType LanguageType { get=>ErrorMessage.SugarLanguageType; set=>ErrorMessage.SugarLanguageType=value; }
///
///If true, there is only one connection instance in the same thread within the same connection string
//[Obsolete("use SqlSugar.Ioc")]
/////
//public bool IsShardSameThread { get; set; }
///
/// Configure External Services replace default services,For example, Redis storage
///
[JsonIgnore]
public ConfigureExternalServices ConfigureExternalServices = new ConfigureExternalServices();
///
/// If SlaveConnectionStrings has value,ConnectionString is write operation, SlaveConnectionStrings is read operation.
/// All operations within a transaction is ConnectionString
///
public List SlaveConnectionConfigs { get; set; }
///
/// More Gobal Settings
///
public ConnMoreSettings MoreSettings { get; set; }
/////
///// Used for debugging errors or BUG,Used for debugging, which has an impact on Performance
/////
//public SugarDebugger Debugger { get; set; }
public string IndexSuffix { get; set; }
[JsonIgnore]
public AopEvents AopEvents { get;set; }
///
///
///
public SqlMiddle SqlMiddle { get; set; }
}
public class SqlMiddle
{
public bool? IsSqlMiddle { get; set; }
public Func GetScalar { get; set; } = (s,p) => throw new Exception("SqlMiddle.GetScalar is null");
public Func ExecuteCommand { get; set; } = (s, p) => throw new Exception("SqlMiddle.ExecuteCommand is null");
public Func GetDataReader { get; set; } = (s, p) => throw new Exception("SqlMiddle.GetDataReader is null");
public Func GetDataSetAll { get; set; } = (s, p) => throw new Exception("SqlMiddle.GetDataSetAll is null");
public Func> GetScalarAsync { get; set; } = (s, p) => throw new Exception("SqlMiddle.GetScalarAsync is null");
public Func> ExecuteCommandAsync { get; set; } = (s, p) => throw new Exception("SqlMiddle.ExecuteCommandAsync is null");
public Func> GetDataReaderAsync { get; set; } = (s, p) => throw new Exception("SqlMiddle.GetDataReaderAsync is null");
public Func> GetDataSetAllAsync { get; set; } = (s, p) => throw new Exception("SqlMiddle.GetDataSetAllAsync is null");
}
public class AopEvents
{
public Action OnDiffLogEvent { get; set; }
public Action OnError { get; set; }
public Action OnLogExecuting { get; set; }
public Action OnLogExecuted { get; set; }
public Func> OnExecutingChangeSql { get; set; }
public Action