From 051575717649e8c786b0140e414de66d8e9e07c3 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 4 May 2022 10:15:14 +0800 Subject: [PATCH] Add SugarIndexAttribute.cs --- .../Entities/Mapping/SugarMappingAttribute.cs | 75 ++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs b/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs index 6b4c71023..1ecd16dc2 100644 --- a/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs +++ b/Src/Asp.Net/SqlSugar/Entities/Mapping/SugarMappingAttribute.cs @@ -224,5 +224,78 @@ namespace SqlSugar this.NavigatType = NavigateType.ManyToMany; } } - + + + + [AttributeUsage(AttributeTargets.Class, Inherited = true)] + public class SugarIndexAttribute : Attribute + { + public string IndexName { get; set; } + public Dictionary IndexFields { get; set; } + public SugarIndexAttribute(string indexName,string fieldName,OrderByType type) + { + this.IndexName = indexName; + IndexFields = new Dictionary(); + IndexFields.Add(fieldName,type); + + } + public SugarIndexAttribute(string indexName, string fieldName1, OrderByType type1, string fieldName2, OrderByType type2) + { + this.IndexName = indexName; + IndexFields = new Dictionary(); + IndexFields.Add(fieldName1, type1); + IndexFields.Add(fieldName2, type2); + } + public SugarIndexAttribute(string indexName, string fieldName1, OrderByType type1, string fieldName2, OrderByType type2, string fieldName3, OrderByType type3) + { + this.IndexName = indexName; + IndexFields = new Dictionary(); + IndexFields.Add(fieldName1, type1); + IndexFields.Add(fieldName2, type2); + IndexFields.Add(fieldName3, type3); + } + public SugarIndexAttribute(string indexName, string fieldName1, OrderByType type1, string fieldName2, OrderByType type2, string fieldName3, OrderByType type3, string fieldName4, OrderByType type4) + { + this.IndexName = indexName; + IndexFields = new Dictionary(); + IndexFields.Add(fieldName1, type1); + IndexFields.Add(fieldName2, type2); + IndexFields.Add(fieldName3, type3); + IndexFields.Add(fieldName4, type4); + } + public SugarIndexAttribute(string indexName, string fieldName1, OrderByType type1, string fieldName2, OrderByType type2, string fieldName3, OrderByType type3, string fieldName4, OrderByType type4,string fieldName5, OrderByType type5) + { + this.IndexName = indexName; + IndexFields = new Dictionary(); + IndexFields.Add(fieldName1, type1); + IndexFields.Add(fieldName2, type2); + IndexFields.Add(fieldName3, type3); + IndexFields.Add(fieldName4, type4); + IndexFields.Add(fieldName5, type5); + } + public SugarIndexAttribute(string indexName, string fieldName1, OrderByType type1, string fieldName2, OrderByType type2, string fieldName3, OrderByType type3, string fieldName4, OrderByType type4, string fieldName5, OrderByType type5, string fieldName6, OrderByType type6) + { + this.IndexName = indexName; + IndexFields = new Dictionary(); + IndexFields.Add(fieldName1, type1); + IndexFields.Add(fieldName2, type2); + IndexFields.Add(fieldName3, type3); + IndexFields.Add(fieldName4, type4); + IndexFields.Add(fieldName5, type5); + IndexFields.Add(fieldName6, type6); + } + public SugarIndexAttribute(string indexName, string fieldName1, OrderByType type1, string fieldName2, OrderByType type2, string fieldName3, OrderByType type3, string fieldName4, OrderByType type4, string fieldName5, OrderByType type5, string fieldName6, OrderByType type6, string fieldName7, OrderByType type7) + { + this.IndexName = indexName; + IndexFields = new Dictionary(); + IndexFields.Add(fieldName1, type1); + IndexFields.Add(fieldName2, type2); + IndexFields.Add(fieldName3, type3); + IndexFields.Add(fieldName4, type4); + IndexFields.Add(fieldName5, type5); + IndexFields.Add(fieldName6, type6); + IndexFields.Add(fieldName7, type7); + } + } + }