var ps = dbContext.SplLedgers.Select(p => new SplLedgerModel
{
Name = p.Name,
VoucherType = Convert.ToString(((JIMS.VoucherTypes)p.VoucherType))
});
I am getting the following exception, whats wrong with the code.
JIMS.VoucherType is an enum
+ $exception {"LINQ to Entities does not recognize the method 'System.String ToString(System.Object)' method, and this method cannot be translated into a store expression."} System.Exception {System.NotSupportedException}
Your code is basically trying to find the Convert.ToString() method in the DB and understandably failing.
You can get around it, for example by making sure the query executes before the select, e.g.