0

I have the following entity code where i want to return a formatted string based on a custom a function that return a string:

var query =
               from a in db.Authors
               join b in db.Books
               on a.id equals b.atuhorId into ab
               from item in ab.DefaultIfEmpty()
               select new
               {
                   id =  a.id,
                   authorName= a.name,
                   bookName = b.name,
                   formatted_book = item.id != null ?  model.getFormatedBook(item.id) : "N/A",
                   },

               };

But i got an error like mentioned in my post title. Is there a cast that i can put inside my entity code for the getFormatedBook(item.id) ? I tried getFormatedBook(item.id).ToString() but with no success

Thanks

user708683
  • 500
  • 3
  • 9
  • 26

1 Answers1

0

LINQ to Entity is unable to call outside methods as a part of a query. Take a look at this answer: https://stackoverflow.com/a/12641286/1202275 for possible workarounds.

Community
  • 1
  • 1
Darth Veyda
  • 828
  • 2
  • 12
  • 23