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,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class CacheKey
{
public string Database { get; set; }
public List<string> Tables { get; set; }
public List<string> IdentificationList { get; set; }
public new string ToString()
{
return "SqlSugarDataCache" + UtilConstants.Dot + string.Join(UtilConstants.Dot, this.Tables) +UtilConstants.Dot+ string.Join(UtilConstants.Dot, this.IdentificationList.Where(it=>it.HasValue()));
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public interface IConditionalModel {
}
public class ConditionalCollections : IConditionalModel
{
public List<KeyValuePair<WhereType, ConditionalModel>> ConditionalList { get; set; }
}
public class ConditionalModel: IConditionalModel
{
public ConditionalModel()
{
this.ConditionalType = ConditionalType.Equal;
}
public string FieldName { get; set; }
public string FieldValue { get; set; }
public ConditionalType ConditionalType { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class ConnMoreSettings
{
public bool IsAutoRemoveDataCache { get; set; }
public bool IsWithNoLockQuery { get; set; }
}
}

View File

@@ -0,0 +1,94 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class ConnectionConfig
{
/// <summary>
///DbType.SqlServer Or Other
/// </summary>
public DbType DbType { get; set; }
/// <summary>
///Database Connection string
/// </summary>
public string ConnectionString { get; set; }
/// <summary>
/// true does not need to close the connection
/// </summary>
public bool IsAutoCloseConnection { get; set; }
/// <summary>
/// Default SystemTable,If you do not have system table permissions, use attribute
/// </summary>
public InitKeyType InitKeyType = InitKeyType.SystemTable;
/// <summary>
///If true, there is only one connection instance in the same thread within the same connection string
/// </summary>
public bool IsShardSameThread { get; set; }
/// <summary>
/// Configure External Services replace default services,For example, Redis storage
/// </summary>
[JsonIgnore]
public ConfigureExternalServices ConfigureExternalServices = _DefaultServices;
private static ConfigureExternalServices _DefaultServices = new ConfigureExternalServices();
/// <summary>
/// If SlaveConnectionStrings has value,ConnectionString is write operation, SlaveConnectionStrings is read operation.
/// All operations within a transaction is ConnectionString
/// </summary>
public List<SlaveConnectionConfig> SlaveConnectionConfigs { get; set; }
/// <summary>
/// More Gobal Settings
/// </summary>
public ConnMoreSettings MoreSettings { get; set; }
}
public class ConfigureExternalServices
{
private ISerializeService _SerializeService;
private ICacheService _ReflectionInoCache;
private ICacheService _DataInfoCache;
public ISerializeService SerializeService
{
get
{
if (_SerializeService == null)
return DefaultServices.Serialize;
else
return _SerializeService;
}
set{ _SerializeService = value;}
}
public ICacheService ReflectionInoCacheService
{
get
{
if (_ReflectionInoCache == null)
return DefaultServices.ReflectionInoCache;
else
return _ReflectionInoCache;
}
set{_ReflectionInoCache = value;}
}
public ICacheService DataInfoCacheService
{
get
{
if (_DataInfoCache == null)
return DefaultServices.DataInoCache;
else
return _DataInfoCache;
}
set { _DataInfoCache = value; }
}
public List<SqlFuncExternal> SqlFuncServices { get; set; }
public List<KeyValuePair<string, CSharpDataType>> AppendDataReaderTypeMappings { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class DbColumnInfo
{
public string TableName { get; set; }
public int TableId { get; set; }
public string DbColumnName { get; set; }
public string PropertyName { get; set; }
public string DataType { get; set; }
public Type PropertyType { get; set; }
public int Length { get; set; }
public string ColumnDescription { get; set; }
public string DefaultValue { get; set; }
public bool IsNullable { get; set; }
public bool IsIdentity { get; set; }
public bool IsPrimarykey { get; set; }
public object Value { get; set; }
public int DecimalDigits { get; set; }
public int Scale { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class DbResult<T>
{
public bool IsSuccess { get; set; }
public Exception ErrorException { get; set; }
public string ErrorMessage { get; set; }
public T Data { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class DbTableInfo
{
public string Name { get; set; }
public string Description { get; set; }
public DbObjectType DbObjectType { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class DefaultServices
{
public static ICacheService ReflectionInoCache= new ReflectionInoCacheService();
public static ICacheService DataInoCache = null;
public static ISerializeService Serialize= new SerializeService();
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class EntityColumnInfo
{
public PropertyInfo PropertyInfo { get; set; }
public string PropertyName { get; set; }
public string DbColumnName { get; set; }
public string OldDbColumnName { get; set; }
public int Length { get; set; }
public string ColumnDescription { get; set; }
public string DefaultValue { get; set; }
public bool IsNullable { get; set; }
public bool IsIdentity { get; set; }
public bool IsPrimarykey { get; set; }
public string EntityName { get; set; }
public string DbTableName { get; set; }
public bool IsIgnore { get; set; }
public string DataType { get; set; }
public int DecimalDigits { get; set; }
public string OracleSequenceName { get; set; }
public bool IsOnlyIgnoreInsert { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class EntityInfo
{
private string _DbTableName;
public string EntityName { get; set; }
public string DbTableName { get { return _DbTableName == null ? EntityName : _DbTableName; } set { _DbTableName = value; } }
public Type Type { get; set; }
public List<EntityColumnInfo> Columns { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class JoinQueryInfo
{
public JoinType JoinType{ get; set; }
public string TableName { get; set; }
public string ShortName { get; set; }
public int JoinIndex { get; set; }
public string JoinWhere { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class IgnoreColumn
{
public string EntityName { get; set; }
public string PropertyName { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class MappingColumn
{
public string PropertyName { get; set; }
public string DbColumnName { get; set; }
public string EntityName { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class MappingTable
{
public string EntityName { get; set; }
public string DbTableName { get; set; }
public string DbShortTaleName { get; set; }
}
}

View File

@@ -0,0 +1,110 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System;
namespace SqlSugar
{
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public class SugarTable : Attribute {
private SugarTable() { }
public string TableName { get; set; }
public SugarTable(string tableName) {
this.TableName = tableName;
}
}
[AttributeUsage(AttributeTargets.Property , Inherited = true)]
public class SugarColumn : Attribute
{
private string _ColumnName;
public string ColumnName
{
get { return _ColumnName; }
set { _ColumnName = value; }
}
private bool _IsIgnore;
public bool IsIgnore
{
get { return _IsIgnore; }
set { _IsIgnore = value; }
}
private bool _IsPrimaryKey;
public bool IsPrimaryKey
{
get { return _IsPrimaryKey; }
set { _IsPrimaryKey = value; }
}
private bool _IsIdentity;
public bool IsIdentity
{
get { return _IsIdentity; }
set { _IsIdentity = value; }
}
private string _MappingKeys;
public string MappingKeys
{
get { return _MappingKeys; }
set { _MappingKeys = value; }
}
private string _ColumnDescription;
public string ColumnDescription
{
get { return _ColumnDescription; }
set { _ColumnDescription = value; }
}
private int _Length;
public int Length
{
get { return _Length; }
set { _Length = value; }
}
private bool _IsNullable;
public bool IsNullable
{
get { return _IsNullable; }
set { _IsNullable = value; }
}
private string _OldColumnName;
public string OldColumnName
{
get { return _OldColumnName; }
set { _OldColumnName = value; }
}
private string _ColumnDataType;
public string ColumnDataType
{
get { return _ColumnDataType; }
set { _ColumnDataType = value; }
}
private int _DecimalDigits;
public int DecimalDigits {
get { return _DecimalDigits; }
set { _DecimalDigits = value; }
}
private string _OracleSequenceName;
public string OracleSequenceName {
get { return _OracleSequenceName; }
set { _OracleSequenceName = value; }
}
private bool _IsOnlyIgnoreInsert;
public bool IsOnlyIgnoreInsert
{
get { return _IsOnlyIgnoreInsert; }
set { _IsOnlyIgnoreInsert = value; }
}
}
}

View File

@@ -0,0 +1,23 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class ModelContext
{
[SugarColumn(IsIgnore = true)]
[JsonIgnore]
public SqlSugarClient Context { get; set; }
public ISugarQueryable<T> CreateMapping<T>() where T : class, new()
{
Check.ArgumentNullException(Context, "Please use Sqlugar.ModelContext");
using (Context)
{
return Context.Queryable<T>();
}
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class PageModel
{
public int PageIndex { get; set; }
public int PageSize { get; set; }
/// <summary>
/// output
/// </summary>
public int PageCount { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class SchemaInfo
{
public string TableName { get; set; }
public string SchemaName { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class SlaveConnectionConfig
{
/// <summary>
///Default value is 1
///If value is 0 means permanent non execution
/// </summary>
public int HitRate = 1;
public string ConnectionString { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class SqlFilterItem
{
/// <summary>
/// Equal to NULL representing global
/// </summary>
public string FilterName { get; set; }
public Func<SqlSugarClient,SqlFilterResult> FilterValue { get; set; }
/// <summary>
/// Is it a multiple table query?
/// </summary>
public bool IsJoinQuery { get; set; }
}
public class SqlFilterResult
{
public string Sql { get; set; }
public object Parameters { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial class SqlWith
{
public const string NoLock = "WITH(NOLOCK) ";
public const string HoldLock = "WITH(HOLDLOCK)";
public const string PagLock = "WITH(PAGLOCK)";
public const string ReadCommitted = "WITH(READCOMMITTED)";
public const string TabLockX = "WITH(TABLOCKX)";
public const string UpdLock = "WITH(UPDLOCK)";
public const string RowLock = "WITH(ROWLOCK)";
public const string Null = "Non";
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public class MappingTableList : List<MappingTable>
{
public void Add(string entityName, string dbTableName)
{
this.RemoveAll(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
this.Add(new MappingTable() { EntityName = entityName, DbTableName = dbTableName });
}
public void Add(string entityName, string dbTableName, string dbTableShortName)
{
this.RemoveAll(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
this.Add(new MappingTable() { EntityName = entityName, DbTableName = dbTableName, DbShortTaleName = dbTableShortName });
}
public new void Clear()
{
this.RemoveAll(it=>true);
}
}
public class IgnoreColumnList : List<IgnoreColumn>
{
public void Add(string propertyName, string EntityName)
{
this.RemoveAll(it =>it.EntityName==EntityName&&it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
this.Add(new IgnoreColumn() { PropertyName = propertyName, EntityName = EntityName });
}
public new void Clear()
{
this.RemoveAll(it => true);
}
}
public class MappingColumnList : List<MappingColumn>
{
public void Add(string propertyName, string dbColumnName, string entityName)
{
this.RemoveAll(it =>it.EntityName==entityName &&it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
this.Add(new MappingColumn() { PropertyName = propertyName, DbColumnName = dbColumnName, EntityName = entityName });
}
public new void Clear()
{
this.RemoveAll(it => true);
}
}
}