c# - Enums to predicates of lambda expression -
i've been searching how convert enums predicate in lambda expression/linq query ef. example, have below enums:
public enum myenum { [display(displayname="firstdesc") first = 0, [display(displayname="seconddesc")] sec = 1, [display(displayname="thirddesc")] 3rd = 2 }
and linq query is
var query = (from in context.users select new { desc = case when status==(int)myenum.first ? "firstdesc" : case when status==(int)myenum.second ? "seconddesc": case when status==(int)myenum.third ? "thirddesc" : "unknown" });
i want accomplish 1 time add together new item enum, linq query automatically adjust status items in enum.
any help appreciated.
c# linq entity-framework enums
No comments:
Post a Comment