1

I have a query and i want to convert a decimal field to string but the query return the above error

LINQ to Entities does not recognize the method 'System.String ToString () "and it can not be translated into term store.

My query :

    var t = (from f in db.teacher_fee
             where f.fee_status == 1
             select new
             {
                 f.fee_date,
                 f.teacher_fee_id,
                 debit = "",
                 credit = f.total_amount.ToString()
             }); 

can someone help me thanks

El Hamza
  • 37
  • 2
  • 8

1 Answers1

0

You cannot apply methods like (System.ToString() in your example) on something that is not on the memory.

So basically, the query was never executed. If you look at it, this is still a IQueryable.

You need to bring it with AsEnumerable() or ToList(), before applying the methods into your fields.

Anderson Oki
  • 637
  • 1
  • 6
  • 18