我有一个已定义的枚举
using System.ComponentModel.DataAnnotations;
namespace Clinton.Core.Domain.Enums
{
public enum ReceiptType
{
[Display(Name = "Cash")]
Cash = 0,
[Display(Name = "Debit Order")]
DebitOrder = 1,
[Display(Name = "Credit Card")]
Cheque = 2,
}
}
然后在班级中使用哪个
using Clinton.Core.ReportHelperInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Clinton.Core.Domain.Enums;
namespace Clinton.Persistance.ReportHelper
{
public class ReturnReceiptType : IReturnReceiptType
{
public string GetReceiptType(ReceiptType receiptType)
{
return Enum.GetName(typeof(ReceiptType), receiptType);
}
}
}
这很好用,但是要根据分配的数字值对其进行排序,而我需要按名称的字母顺序对其进行排序。我不能只是手动修改数字,因为这是很多旧信息和报告,它们已经利用了存储的枚举。有没有办法设置
@Html.EditorFor(model => model.ReceiptType)
订购说明?
谢谢