This commit is contained in:
2025-04-24 18:31:27 +08:00
commit 9340f5253e
2796 changed files with 1387124 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial interface IAdo
{
string SqlParameterKeyWord { get; }
IDbConnection Connection { get; set; }
IDbTransaction Transaction { get; set; }
IDataParameter[] ToIDbDataParameter(params SugarParameter[] pars);
SugarParameter[] GetParameters(object obj, PropertyInfo[] propertyInfo = null);
SqlSugarClient Context { get; set; }
void ExecuteBefore(string sql, SugarParameter[] pars);
void ExecuteAfter(string sql, SugarParameter[] pars);
IDataParameterCollection DataReaderParameters { get; set; }
CommandType CommandType { get; set; }
bool IsEnableLogEvent { get; set; }
Action<string, SugarParameter []> LogEventStarting { get; set; }
Action<string, SugarParameter []> LogEventCompleted { get; set; }
Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> ProcessingEventStartingSQL { get; set; }
Action<Exception> ErrorEvent { get; set; }
bool IsClearParameters { get; set; }
int CommandTimeOut { get; set; }
IDbBind DbBind { get; }
void SetCommandToAdapter(IDataAdapter adapter, IDbCommand command);
IDataAdapter GetAdapter();
IDbCommand GetCommand(string sql, SugarParameter[] parameters);
DataTable GetDataTable(string sql, object parameters);
DataTable GetDataTable(string sql, params SugarParameter[] parameters);
DataTable GetDataTable(string sql, List<SugarParameter> parameters);
DataSet GetDataSetAll(string sql, object parameters);
DataSet GetDataSetAll(string sql, params SugarParameter[] parameters);
DataSet GetDataSetAll(string sql, List<SugarParameter> parameters);
IDataReader GetDataReader(string sql, object parameters);
IDataReader GetDataReader(string sql, params SugarParameter[] parameters);
IDataReader GetDataReader(string sql, List<SugarParameter> parameters);
object GetScalar(string sql, object parameters);
object GetScalar(string sql, params SugarParameter[] parameters);
object GetScalar(string sql, List<SugarParameter> parameters);
int ExecuteCommand(string sql, object parameters);
int ExecuteCommand(string sql, params SugarParameter[] parameters);
int ExecuteCommand(string sql, List<SugarParameter> parameters);
string GetString(string sql, object parameters);
string GetString(string sql, params SugarParameter[] parameters);
string GetString(string sql, List<SugarParameter> parameters);
int GetInt(string sql, object pars);
int GetInt(string sql, params SugarParameter[] parameters);
int GetInt(string sql, List<SugarParameter> parameters);
Double GetDouble(string sql, object parameters);
Double GetDouble(string sql, params SugarParameter[] parameters);
Double GetDouble(string sql, List<SugarParameter> parameters);
decimal GetDecimal(string sql, object parameters);
decimal GetDecimal(string sql, params SugarParameter[] parameters);
decimal GetDecimal(string sql, List<SugarParameter> parameters);
DateTime GetDateTime(string sql, object parameters);
DateTime GetDateTime(string sql, params SugarParameter[] parameters);
DateTime GetDateTime(string sql, List<SugarParameter> parameters);
List<T> SqlQuery<T>(string sql, object parameters = null);
List<T> SqlQuery<T>(string sql, params SugarParameter[] parameters);
List<T> SqlQuery<T>(string sql, List<SugarParameter> parameters);
T SqlQuerySingle<T>(string sql, object whereObj = null);
T SqlQuerySingle<T>(string sql, params SugarParameter[] parameters);
T SqlQuerySingle<T>(string sql, List<SugarParameter> parameters);
dynamic SqlQueryDynamic(string sql, object whereObj = null);
dynamic SqlQueryDynamic(string sql, params SugarParameter[] parameters);
dynamic SqlQueryDynamic(string sql, List<SugarParameter> parameters);
void Dispose();
void Close();
void Open();
void CheckConnection();
void BeginTran();
void BeginTran(IsolationLevel iso);
void BeginTran(string transactionName);
void BeginTran(IsolationLevel iso, string transactionName);
void RollbackTran();
void CommitTran();
DbResult<bool> UseTran(Action action);
DbResult<T> UseTran<T>(Func<T> action);
void UseStoredProcedure(Action action);
T UseStoredProcedure<T>(Func<T> action);
IAdo UseStoredProcedure();
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public partial interface ICodeFirst
{
SqlSugarClient Context { get; set; }
ICodeFirst BackupTable(int maxBackupDataRows=int.MaxValue);
void InitTables(string entitiesNamespace);
void InitTables(string [] entitiesNamespaces);
void InitTables(params Type [] entityTypes);
void InitTables(Type entityType);
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public interface IContextMethods
{
SqlSugarClient Context { get; set; }
ExpandoObject DataReaderToExpandoObject(IDataReader reader);
List<ExpandoObject> DataReaderToExpandoObjectList(IDataReader reader);
List<T> DataReaderToDynamicList<T>(IDataReader reader);
string SerializeObject(object value);
T DeserializeObject<T>(string value);
T TranslateCopy<T>(T sourceObject);
SqlSugarClient CopyContext(bool isCopyEvents = false);
dynamic DataTableToDynamic(DataTable table);
ICacheService GetReflectionInoCacheInstance();
void RemoveCacheAll();
void RemoveCacheAll<T>();
void RemoveCache<T>(string key);
KeyValuePair<string, SugarParameter[]> ConditionalModelToSql(List<IConditionalModel> models,int beginIndex=0);
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public partial interface IDMLBuilder
{
string SqlTemplate { get; }
List<SugarParameter> Parameters { get; set; }
SqlSugarClient Context { get; set; }
StringBuilder sql { get; set; }
string ToSqlString();
void Clear();
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public partial interface IDbBind
{
SqlSugarClient Context { get; set; }
List<string> GuidThrow { get; }
List<string> IntThrow { get; }
List<string> StringThrow { get; }
List<string> DecimalThrow { get; }
List<string> DoubleThrow { get; }
List<string> DateThrow { get; }
List<string> ShortThrow { get; }
string GetPropertyTypeName(string dbTypeName);
string GetConvertString(string dbTypeName);
string GetDbTypeName(string csharpTypeName);
string GetCsharpTypeName(string dbTypeName);
List<KeyValuePair<string, CSharpDataType>> MappingTypes { get; }
List<T> DataReaderToList<T>(Type type, IDataReader reader);
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public partial interface IDbFirst
{
SqlSugarClient Context { get; set; }
IDbFirst SettingClassTemplate(Func<string, string> func);
IDbFirst SettingClassDescriptionTemplate(Func<string, string> func);
IDbFirst SettingPropertyTemplate(Func<string, string> func);
IDbFirst SettingPropertyDescriptionTemplate(Func<string, string> func);
IDbFirst SettingConstructorTemplate(Func<string, string> func);
IDbFirst SettingNamespaceTemplate(Func<string, string> func);
IDbFirst IsCreateAttribute(bool isCreateAttribute = true);
IDbFirst IsCreateDefaultValue(bool isCreateDefaultValue=true);
IDbFirst Where(params string[] objectNames);
IDbFirst Where(Func<string,bool> func);
IDbFirst Where(DbObjectType dbObjectType);
void CreateClassFile(string directoryPath, string nameSpace = "Models",string tableName = "");
Dictionary<string, string> ToClassStringList(string nameSpace = "Models");
void Init();
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public partial interface IDbMaintenance
{
SqlSugarClient Context { get; set; }
#region DML
List<DbTableInfo> GetViewInfoList(bool isCache=true);
List<DbTableInfo> GetTableInfoList(bool isCache=true);
List<DbColumnInfo> GetColumnInfosByTableName(string tableName,bool isCache=true);
List<string> GetIsIdentities(string tableName);
List<string> GetPrimaries(string tableName);
List<string> SetListTalbeName(List<string> listTalbeName2);
#endregion
#region Check
bool IsAnyTable(string tableName, bool isCache = true);
bool IsAnyColumn(string tableName, string column);
bool IsPrimaryKey(string tableName, string column);
bool IsIdentity(string tableName, string column);
bool IsAnyConstraint(string ConstraintName);
bool IsAnySystemTablePermissions();
#endregion
#region DDL
bool DropTable(string tableName);
bool TruncateTable(string tableName);
bool CreateTable(string tableName, List<DbColumnInfo> columns,bool isCreatePrimaryKey=true);
bool AddColumn(string tableName, DbColumnInfo column);
bool UpdateColumn(string tableName, DbColumnInfo column);
bool AddPrimaryKey(string tableName,string columnName);
bool DropConstraint(string tableName, string constraintName);
bool BackupDataBase(string databaseName,string fullFileName);
bool BackupTable(string oldTableName, string newTableName, int maxBackupDataRows = int.MaxValue);
bool DropColumn(string tableName,string columnName);
bool RenameColumn(string tableName, string oldColumnName, string newColumnName);
#endregion
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public interface IDeleteable<T> where T : class, new()
{
DeleteBuilder DeleteBuilder { get; set; }
int ExecuteCommand();
bool ExecuteCommandHasChange();
Task<int> ExecuteCommandAsync();
Task<bool> ExecuteCommandHasChangeAsync();
IDeleteable<T> AS(string tableName);
IDeleteable<T> With(string lockString);
IDeleteable<T> Where(T deleteObj);
IDeleteable<T> Where(Expression<Func<T, bool>> expression);
IDeleteable<T> Where(List<T> deleteObjs);
IDeleteable<T> In<PkType>(PkType primaryKeyValue);
IDeleteable<T> In<PkType>(PkType[] primaryKeyValues);
IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues);
IDeleteable<T> Where(string whereString,object parameters=null);
IDeleteable<T> Where(string whereString, SugarParameter parameter);
IDeleteable<T> Where(string whereString, SugarParameter[] parameters);
IDeleteable<T> Where(string whereString, List<SugarParameter> parameters);
IDeleteable<T> RemoveDataCache();
KeyValuePair<string, List<SugarParameter>> ToSql();
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public interface IFilter
{
IFilter Add(SqlFilterItem filter);
void Remove(string filterName);
List<SqlFilterItem> GeFilterList { get; }
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial interface ILambdaExpressions
{
MappingColumnList MappingColumns { get; set; }
MappingTableList MappingTables { get; set; }
IgnoreColumnList IgnoreComumnList { get; set; }
List<SqlFuncExternal> SqlFuncServices { get; set; }
List<JoinQueryInfo> JoinQueryInfos { get; set; }
bool IsSingle { get; set; }
SqlSugarClient Context { get; set; }
IDbMethods DbMehtods { get; set; }
Expression Expression { get; set; }
int Index { get; set; }
int ParameterIndex { get; set; }
List<SugarParameter> Parameters { get; set; }
ExpressionResult Result { get; set; }
string SqlParameterKeyWord { get; }
string SingleTableNameSubqueryShortName { get; set; }
Action<Type> InitMappingInfo { get; set; }
Action RefreshMapping { get; set; }
string GetAsString(string fieldName, string fieldValue);
void Resolve(Expression expression, ResolveExpressType resolveType);
void Clear();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial interface ISqlBuilder
{
SqlSugarClient Context { get; set; }
CommandType CommandType { get; set; }
String AppendWhereOrAnd(bool isWhere, string sqlString);
string AppendHaving(string sqlString);
SqlQueryBuilder SqlQueryBuilder { get; set; }
QueryBuilder QueryBuilder { get; set; }
InsertBuilder InsertBuilder { get; set; }
DeleteBuilder DeleteBuilder { get; set; }
UpdateBuilder UpdateBuilder { get; set; }
string SqlParameterKeyWord { get; }
string SqlFalse { get; }
string SqlDateNow { get; }
string FullSqlDateNow { get; }
string SqlTranslationLeft { get; }
string SqlTranslationRight { get; }
string SqlSelectAll { get; }
string GetTranslationTableName(string name);
string GetTranslationColumnName(string entityName, string propertyName);
string GetTranslationColumnName(string propertyName);
string GetNoTranslationColumnName(string name);
string GetPackTable(string sql,string shortName);
string GetDefaultShortName();
string GetWhere(string fieldName, string conditionalType, int? parameterIndex = null);
string GetUnionAllSql(List<string> sqlList);
string GetUnionSql(List<string> sqlList);
void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex);
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public interface IUpdateable<T> where T : class, new()
{
UpdateBuilder UpdateBuilder { get; set; }
int ExecuteCommand();
bool ExecuteCommandHasChange();
Task<int> ExecuteCommandAsync();
Task<bool> ExecuteCommandHasChangeAsync();
IUpdateable<T> AS(string tableName);
IUpdateable<T> With(string lockString);
[Obsolete("Use IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);")]
IUpdateable<T> Where(bool isNoUpdateNull,bool IsOffIdentity = false);
IUpdateable<T> Where(Expression<Func<T, bool>> expression);
IUpdateable<T> Where(string whereSql,object parameters=null);
/// <summary>
///
/// </summary>
/// <param name="fieldName"></param>
/// <param name="conditionalType">for example : = </param>
/// <param name="fieldValue"></param>
/// <returns></returns>
IUpdateable<T> Where(string fieldName, string conditionalType, object fieldValue);
/// <summary>
/// Non primary key entity update function
/// </summary>
/// <param name="columns"></param>
/// <returns></returns>
IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns);
IUpdateable<T> UpdateColumns(Expression<Func<T, object>> columns);
IUpdateable<T> UpdateColumns(Expression<Func<T, bool>> columns);
IUpdateable<T> UpdateColumns(Func<string, bool> updateColumMethod);
IUpdateable<T> UpdateColumns(Expression<Func<T, T>> columns);
IUpdateable<T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false);
IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod);
IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression);
IUpdateable<T> RemoveDataCache();
KeyValuePair<string,List<SugarParameter>> ToSql();
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public interface IInsertable<T>
{
InsertBuilder InsertBuilder { get; set; }
int ExecuteCommand();
Task<int> ExecuteCommandAsync();
int ExecuteReturnIdentity();
Task<int> ExecuteReturnIdentityAsync();
T ExecuteReturnEntity();
Task<T> ExecuteReturnEntityAsync();
bool ExecuteCommandIdentityIntoEntity();
Task<bool> ExecuteCommandIdentityIntoEntityAsync();
long ExecuteReturnBigIdentity();
Task<long> ExecuteReturnBigIdentityAsync();
IInsertable<T> AS(string tableName);
IInsertable<T> With(string lockString);
IInsertable<T> InsertColumns(Expression<Func<T, object>> columns);
IInsertable<T> InsertColumns(Func<string, bool> insertColumMethod);
IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IInsertable<T> IgnoreColumns(Func<string,bool> ignoreColumMethod);
IInsertable<T> Where(bool isInsertNull, bool isOffIdentity = false);
IInsertable<T> RemoveDataCache();
KeyValuePair<string, List<SugarParameter>> ToSql();
}
}