Add: SugarIndexAttribute(string indexName, string[] fieldNames, OrderByType[] sortTypes, bool isUnique = false)

This commit is contained in:
sunkaixuan 2023-12-15 14:49:20 +08:00
parent b780552cdb
commit 6ba3832943

View File

@ -429,6 +429,21 @@ namespace SqlSugar
IndexFields.Add(fieldName10, sortType10);
this.IsUnique = isUnique;
}
public SugarIndexAttribute(string indexName, string[] fieldNames, OrderByType[] sortTypes, bool isUnique = false)
{
if (fieldNames.Length != sortTypes.Length)
{
Check.ExceptionEasy($"SugarIndexAttribute {indexName} fieldNames.Length!=sortTypes.Length 检查索引特性", $"SugarIndexAttribute {indexName} fieldNames.Length!=sortTypes.Length");
}
this.IndexName = indexName;
IndexFields = new Dictionary<string, OrderByType>();
for (int i = 0; i < fieldNames.Length; i++)
{
IndexFields.Add(fieldNames[i], sortTypes[i]);
}
this.IsUnique = isUnique;
}
}
}