score:0

public string EnumDisplayValue { get { return GetMyEnumDisplayName(MyEnumValue); } } 

score:0

public static string Describe(this Enum enumVal)
{
    var type = enumVal.GetType();
    var memInfo = type.GetMember(enumVal.ToString());
    var attributes = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
    return (attributes.Length > 0) ? ((DescriptionAttribute)(attributes[0])).Description : enumVal.ToString();
}

score:0

public enum IntervalUse
    {
        Hourly,
        Daily,
        Weekly
    }

    public static class EnumExt
    {
        public static string GetDescription(this IntervalUse item)
        {
            switch (item)
            {
                case IntervalUse.Hourly:
                    return "Hour by hour";
                case IntervalUse.Daily:
                    return "Day by day";
                case IntervalUse.Weekly:
                    return "Each week ...";
                default:
                    throw new ArgumentOutOfRangeException(nameof(item), item, null);
            }
        }
    }

score:1

var query = dbo.Records.Include(x => x.Prescriptions).OrderByDescending(x => x.Id).AsEnumerable()
            .Select(x => new
            {
                Id = x.Id,
                Care = new
                {
                    x.StartDate,
                    x.ForwardedBy,
                },
                Prescriptions = x.Prescriptions.Select(p => new
                {
                    p.Medicament,
                    p.IntervalUse.GetDisplayName()
                }),
            });

Related Query

More Query from same tag