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()
}),
});
Source: stackoverflow.com
Related Query
- Get Display Enum in LINQ
- Linq get rows by enum values
- LINQ get list from list by comparing enum
- Get data from database using linq query and display it in dynamically generated labels in repeater
- How do I get SOAP xml file data using LINQ and display it in a form's text box? C#
- Use LINQ to get items in one List<>, that are not in another List<>
- Using Linq to get the last N elements of a collection?
- How can I get LINQ to return the object which has the max value for a given property?
- How to get first record in each group using Linq
- How do I get the MAX row with a GROUP BY in LINQ query?
- How do I get the max ID with Linq to Entity?
- Get sum of two columns in one LINQ query
- How to get first object out from List<Object> using Linq
- Get List<> element position in c# using LINQ
- Optimal LINQ query to get a random sub collection - Shuffle
- LINQ to SQL: GroupBy() and Max() to get the object with latest date
- Get Average Using LINQ
- Get index of object in a list using Linq
- LINQ to Get Closest Value?
- Get previous and next item in a IEnumerable using LINQ
- How to get a Random Object using Linq
- Get indexes of all matching values from list using Linq
- Get the difference between two lists using LINQ
- How to get distinct instance from a list by Lambda or LINQ
- Using LINQ to find item in a List but get "Value cannot be null. Parameter name: source"
- Get top N records using LINQ to Entities
- Building a LINQ expression tree: how to get variable in scope
- Linq way to get piecewise difference between element and next element in list
- How do I get LINQ to order according to culture?
- LINQ way to get items between two indexes in a List
More Query from same tag
- How would you write this C# code (that uses the yield keyword) succinctly in Ruby?
- Building up linq querys as functions
- How to sum Timespan of subtraction between two datetimes in Linq when using group by?
- How to remove all value where the combination of two attributes equals a string?
- EF6, Windows Service & Database polling
- How do I compose Linq Expressions? ie Func<Exp<Func<X, Y>>, Exp<Func<Y, Z>>, Exp<Func<X, Z>>>
- Using FluentValidation's WithMessage method with a list of named parameters
- How to filter list in asp.net/vb.net using linq
- How to retrieve the specific indexes from array?
- C# Linq Syntax Join
- How to group dates by week and weekday with linq?
- data model problem
- Caching when using Query Expressions?
- How to query grand children from a list of persons?
- Compare two datasets from different databases using VB.NET
- How to I access the first LINQ element?
- Invoking a method of the key object of a dictionary using lambda expressions
- LINQ Enumerable in Enumerable - Why?
- Sorted dynamic list is read only?
- Linq Query to sum only values above specific threshold
- How to select non-distinct elements along with their indexes
- .net linq with regex ismatch in where
- Changing XML with Linq
- How to provide entity type/dbset type in Generic Repository
- Linq to SQL: Partial matching strings using contains on an array of strings
- How do I insert place holders in LINQ so that my group has exactly 24 points
- asp.net mvc 3 EF HTML MultiSelect - How to retrieve multiple values using LINQ
- c# Different Result between Linq and SQL
- Group , Sort List of Tuple with Linq
- query to Combine all childlist of all parent objects in one collection