Check This Code Sniplet out.
using (AttendanceDataContext db = new AttendanceDataContext())
{
var attendance = db.attendpunches.Select(at => new RawEmployeeCheckInOutInfo
{
CheckTime = at.punchtime.Value,
Direction = ((AttendanceDirection)at.direction.Value).ToString()
});
…
AttendanceDirection is enum Which is…
public enum AttendanceDirection : int
{
CheckIn = 1,
CheckOut = 2
}
The Problem is The Direction = ((AttendanceDirection)at.direction.Value).ToString() is always returning the byte value.
I suspect the problem is that the
ToStringis being effectively performed at the database side, which doesn’t know the enum names. Try this: