Alex Rivera | Logout

LINQ lambda - convert int to string

Asked 2011-11-30T12:06:50.690
8

i'm trying to compare a int with a string in the join method of linq lambda, like this:

database.booking.Join(database.address,
                      book => book.bookno,
                      afh => afh.addressid.ToString(),
                       (book, afh) => new { booking = book, add = afh })
                .Where(book => book.address.name == "test");

but i'm getting an error on the ToString():

System.NotSupportedException: LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression.

How do i solve this?

Edit
Report

1 Answer

2

Try this:

var bookinger = database.booking.Join(database.address,
                         book => book.bookno,
                         afh => afh.addressid,
                         (book, afh) =>
                         new { booking = book, add = afh })
                     .Where(book => book.address.name == "test")
                     .Select(new { booking, add = add.ToString() });
answered 2011-11-30T12:17:41.100

Your Answer