2017-08-24 15:18:53 +08:00
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 {
2023-03-21 15:58:43 +08:00
public SugarTable ( ) { }
2017-08-24 15:18:53 +08:00
public string TableName { get ; set ; }
2018-11-11 21:08:35 +08:00
public string TableDescription { get ; set ; }
2021-03-06 20:27:43 +08:00
public bool IsDisabledDelete { get ; set ; }
public bool IsDisabledUpdateAll { get ; set ; }
2022-07-14 09:13:02 +08:00
public bool IsCreateTableFiledSort { get ; set ; }
2017-08-24 15:18:53 +08:00
public SugarTable ( string tableName ) {
this . TableName = tableName ;
}
2018-11-11 21:08:35 +08:00
public SugarTable ( string tableName , string tableDescription )
{
this . TableName = tableName ;
this . TableDescription = tableDescription ;
}
2021-03-06 20:27:43 +08:00
public SugarTable ( string tableName , string tableDescription , bool isDisabledDelete )
{
this . TableName = tableName ;
this . TableDescription = tableDescription ;
this . IsDisabledDelete = isDisabledDelete ;
}
2022-07-14 09:13:02 +08:00
public SugarTable ( string tableName , string tableDescription , bool isDisabledDelete , bool isCreateTableFieldSort )
{
this . TableName = tableName ;
this . TableDescription = tableDescription ;
this . IsDisabledDelete = isDisabledDelete ;
this . IsCreateTableFiledSort = isCreateTableFieldSort ;
}
2017-08-24 15:18:53 +08:00
}
[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 ; }
}
2017-08-28 02:31:02 +08:00
private int _DecimalDigits ;
public int DecimalDigits {
get { return _DecimalDigits ; }
set { _DecimalDigits = value ; }
}
2017-10-23 15:26:24 +08:00
private string _OracleSequenceName ;
public string OracleSequenceName {
get { return _OracleSequenceName ; }
set { _OracleSequenceName = value ; }
}
2017-12-07 18:05:06 +08:00
private bool _IsOnlyIgnoreInsert ;
public bool IsOnlyIgnoreInsert
{
get { return _IsOnlyIgnoreInsert ; }
set { _IsOnlyIgnoreInsert = value ; }
}
2018-10-14 16:21:29 +08:00
2019-06-01 16:30:38 +08:00
private bool _IsOnlyIgnoreUpdate ;
public bool IsOnlyIgnoreUpdate
{
get { return _IsOnlyIgnoreUpdate ; }
set { _IsOnlyIgnoreUpdate = value ; }
}
2018-10-14 16:21:29 +08:00
private bool _IsEnableUpdateVersionValidation ;
public bool IsEnableUpdateVersionValidation {
get { return _IsEnableUpdateVersionValidation ; }
set { _IsEnableUpdateVersionValidation = value ; }
}
2019-04-10 08:25:16 +08:00
private bool _IsTranscoding ;
public bool IsTranscoding
{
get { return _IsTranscoding ; }
set { _IsTranscoding = value ; }
}
2019-04-28 16:08:45 +08:00
private bool _NoSerialize ;
public bool NoSerialize
{
get { return _NoSerialize ; }
set { _NoSerialize = value ; }
}
private string _SerializeDateTimeFormat ;
public string SerializeDateTimeFormat
{
get { return _SerializeDateTimeFormat ; }
set { _SerializeDateTimeFormat = value ; }
}
2019-05-17 22:26:30 +08:00
private bool _IsJson ;
public bool IsJson
{
get { return _IsJson ; }
set { _IsJson = value ; }
}
2019-05-28 21:41:06 +08:00
private string _DefaultValue ;
public string DefaultValue
{
get { return _DefaultValue ; }
set { _DefaultValue = value ; }
}
private string [ ] _IndexGroupNameList ;
public string [ ] IndexGroupNameList
{
get { return _IndexGroupNameList ; }
set { _IndexGroupNameList = value ; }
}
2020-12-05 17:28:33 +08:00
public string [ ] UniqueGroupNameList { get ; set ; }
2020-11-02 15:43:24 +08:00
2020-10-14 15:09:54 +08:00
private bool _IsArray ;
public bool IsArray
{
get { return _IsArray ; }
set { _IsArray = value ; }
}
2022-05-11 18:15:15 +08:00
private bool _IsTreeKey ;
public bool IsTreeKey
{
get { return _IsTreeKey ; }
set { _IsTreeKey = value ; }
}
2022-05-27 11:01:09 +08:00
public object SqlParameterDbType { get ; set ; }
2022-08-19 20:52:41 +08:00
public object SqlParameterSize { get ; set ; }
2022-07-14 09:13:02 +08:00
public int CreateTableFieldSort { get ; set ; }
2022-12-17 13:21:51 +08:00
public bool InsertServerTime { get ; set ; }
public string InsertSql { get ; set ; }
2022-12-20 17:12:30 +08:00
public bool UpdateServerTime { get ; set ; }
public string UpdateSql { get ; set ; }
2017-08-24 15:18:53 +08:00
}
2021-04-25 17:31:49 +08:00
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public class TenantAttribute : Attribute
{
public object configId { get ; set ; }
public TenantAttribute ( object configId )
{
this . configId = configId ;
}
}
2022-04-12 08:28:20 +08:00
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
2022-04-14 13:47:12 +08:00
public class Navigate : Attribute
2022-04-12 08:28:20 +08:00
{
public string Name { get ; set ; }
2022-06-27 22:18:07 +08:00
public string Name2 { get ; set ; }
2022-04-12 08:28:20 +08:00
public Type MappingType { get ; set ; }
public string MappingAId { get ; set ; }
public string MappingBId { get ; set ; }
2022-04-14 13:47:12 +08:00
public NavigateType NavigatType { get ; set ; }
2022-08-06 00:08:26 +08:00
public string WhereSql { get ; set ; }
2022-04-14 13:47:12 +08:00
public Navigate ( NavigateType navigatType , string name )
2022-04-12 08:28:20 +08:00
{
this . Name = name ;
this . NavigatType = navigatType ;
}
2022-06-27 22:18:07 +08:00
public Navigate ( NavigateType navigatType , string firstName , string lastName )
{
this . Name = firstName ;
this . Name2 = lastName ;
this . NavigatType = navigatType ;
}
2022-08-06 00:08:26 +08:00
public Navigate ( NavigateType navigatType , string firstName , string lastName , string whereSql )
{
this . Name = firstName ;
this . Name2 = lastName ;
this . NavigatType = navigatType ;
this . WhereSql = whereSql ;
Check . ExceptionEasy ( navigatType ! = NavigateType . OneToOne , "Currently, only one-to-one navigation configuration Sql conditions are supported" , "目前导航配置Sql条件只支持一对一" ) ;
}
2022-04-14 13:47:12 +08:00
public Navigate ( Type MappingTableType , string typeAiD , string typeBId )
2022-04-12 08:28:20 +08:00
{
this . MappingType = MappingTableType ;
this . MappingAId = typeAiD ;
this . MappingBId = typeBId ;
2022-04-14 13:47:12 +08:00
this . NavigatType = NavigateType . ManyToMany ;
2022-04-12 08:28:20 +08:00
}
}
2022-05-04 11:43:30 +08:00
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public class SugarIndexAttribute : Attribute
{
public string IndexName { get ; set ; }
public Dictionary < string , OrderByType > IndexFields { get ; set ; }
public bool IsUnique { get ; set ; }
public SugarIndexAttribute ( string indexName , string fieldName , OrderByType sortType , bool isUnique = false )
{
this . IndexName = indexName ;
IndexFields = new Dictionary < string , OrderByType > ( ) ;
IndexFields . Add ( fieldName , sortType ) ;
this . IsUnique = isUnique ;
}
public SugarIndexAttribute ( string indexName , string fieldName1 , OrderByType sortType1 , string fieldName2 , OrderByType sortType2 , bool isUnique = false )
{
this . IndexName = indexName ;
IndexFields = new Dictionary < string , OrderByType > ( ) ;
IndexFields . Add ( fieldName1 , sortType1 ) ;
IndexFields . Add ( fieldName2 , sortType2 ) ;
this . IsUnique = isUnique ;
}
public SugarIndexAttribute ( string indexName , string fieldName1 , OrderByType sortType1 , string fieldName2 , OrderByType sortType2 , string fieldName3 , OrderByType sortType3 , bool isUnique = false )
{
this . IndexName = indexName ;
IndexFields = new Dictionary < string , OrderByType > ( ) ;
IndexFields . Add ( fieldName1 , sortType1 ) ;
IndexFields . Add ( fieldName2 , sortType2 ) ;
IndexFields . Add ( fieldName3 , sortType3 ) ;
this . IsUnique = isUnique ;
}
public SugarIndexAttribute ( string indexName , string fieldName1 , OrderByType sortType1 , string fieldName2 , OrderByType sortType2 , string fieldName3 , OrderByType sortType3 , string fieldName4 , OrderByType sortType4 , bool isUnique = false )
{
this . IndexName = indexName ;
IndexFields = new Dictionary < string , OrderByType > ( ) ;
IndexFields . Add ( fieldName1 , sortType1 ) ;
IndexFields . Add ( fieldName2 , sortType2 ) ;
IndexFields . Add ( fieldName3 , sortType3 ) ;
IndexFields . Add ( fieldName4 , sortType4 ) ;
this . IsUnique = isUnique ;
}
public SugarIndexAttribute ( string indexName , string fieldName1 , OrderByType sortType1 , string fieldName2 , OrderByType sortType2 , string fieldName3 , OrderByType sortType3 , string fieldName4 , OrderByType sortType4 , string fieldName5 , OrderByType sortType5 , bool isUnique = false )
{
this . IndexName = indexName ;
IndexFields = new Dictionary < string , OrderByType > ( ) ;
IndexFields . Add ( fieldName1 , sortType1 ) ;
IndexFields . Add ( fieldName2 , sortType2 ) ;
IndexFields . Add ( fieldName3 , sortType3 ) ;
IndexFields . Add ( fieldName4 , sortType4 ) ;
IndexFields . Add ( fieldName5 , sortType5 ) ;
this . IsUnique = isUnique ;
}
public SugarIndexAttribute ( string indexName , string fieldName1 , OrderByType sortType1 , string fieldName2 , OrderByType sortType2 , string fieldName3 , OrderByType sortType3 , string fieldName4 , OrderByType sortType4 , string fieldName5 , OrderByType sortType5 , string fieldName6 , OrderByType sortType6 , bool isUnique = false )
{
this . IndexName = indexName ;
IndexFields = new Dictionary < string , OrderByType > ( ) ;
IndexFields . Add ( fieldName1 , sortType1 ) ;
IndexFields . Add ( fieldName2 , sortType2 ) ;
IndexFields . Add ( fieldName3 , sortType3 ) ;
IndexFields . Add ( fieldName4 , sortType4 ) ;
IndexFields . Add ( fieldName5 , sortType5 ) ;
IndexFields . Add ( fieldName6 , sortType6 ) ;
this . IsUnique = isUnique ;
}
public SugarIndexAttribute ( string indexName , string fieldName1 , OrderByType sortType1 , string fieldName2 , OrderByType sortType2 , string fieldName3 , OrderByType sortType3 , string fieldName4 , OrderByType sortType4 , string fieldName5 , OrderByType sortType5 , string fieldName6 , OrderByType sortType6 , string fieldName7 , OrderByType sortType7 , bool isUnique = false )
{
this . IndexName = indexName ;
IndexFields = new Dictionary < string , OrderByType > ( ) ;
IndexFields . Add ( fieldName1 , sortType1 ) ;
IndexFields . Add ( fieldName2 , sortType2 ) ;
IndexFields . Add ( fieldName3 , sortType3 ) ;
IndexFields . Add ( fieldName4 , sortType4 ) ;
IndexFields . Add ( fieldName5 , sortType5 ) ;
IndexFields . Add ( fieldName6 , sortType6 ) ;
IndexFields . Add ( fieldName7 , sortType7 ) ;
this . IsUnique = isUnique ;
}
}
2017-08-24 15:18:53 +08:00
}