Reputation: 3153
need help
I have this enum which sets the PayClassNo to Direct and Indirect. I want to use this enum in my LinQ query.
Here's my scratch LinQ query:
var jDef = from jd in context.GetTable<RJVDefinition>()
select new PayrollJVDefinition
{
JVdefNo = jd.JVDefNo,
AccntCode = jd.AccntCode,
AccntDesc = jd.AccntDesc,
PayClass = enum.GetValue(jd.PayClassNo),
IsFixed = jd.IsFixed,
IsEmployee = jd.IsFixed,
IsAR = jd.IsAR,
CreatedByNo = jd.CreatedByNo,
CreatedDate = jd.CreatedDate,
ModifiedByNo = jd.ModifiedByNo,
ModifiedDate = jd.ModifiedDate
};
Need help because I'm not sure if this will work.
Upvotes: 0
Views: 550
Reputation: 124790
You could certainly do the translation in code, similar to your example (using Enum.Parse
), but you don't need to. You can use the designer to set the object property type to an enumerated value. See this article for details.
Upvotes: 1
Reputation: 15242
You just need to parse the Enum
just use something like
Enum.Parse(jb.PayClassNo, YourEnumType)
Upvotes: 0