/// <summary>
/// Retrieves all of the items that a member currently has out on loan.
/// </summary>
/// <param name="memberId">The ID of the member for whose loans we are looking</param>
/// <returns>A List containing all Items the Member has on loan.</returns>
public List<Item> GetItems(short memberId)
{
List<Item> list = null;
Require.IsGreaterThan<int>(memberId, 0, "memberId");
try
{
using ( LibraryDataContext dataContext = new LibraryDataContext() )
{
list = from ql in dataContext.loans
let copy = ql.copy
let item = ql.copy.item
let title = ql.title
where ql.member_no == memberId
select new
{
ql.isbn,
ql.copy_no,
ql.member_no,
ql.out_date,
ql.due_date,
ql.copy.on_loan,
ql.copy.item.translation,
ql.copy.item.cover,
ql.copy.item.loanable,
ql.title.title1,
ql.title.author,
ql.title.synopsis,
};
if ( list == null )
{
throw new LibraryException(ErrorCode.ItemNotFound);
}
List<Item> result = (List<Item>)list.ToList<Item>();
return result;
}
}
catch (System.Exception ex)
{
throw new LibraryException(ErrorCode.GenericException);
}
}
This the error i keep when I compile this code what am I doing wrong
Error 1 Cannot implicitly convert type 'System.Linq.IQueryable<AnonymousType#1>' to 'System.Collections.Generic.List<DataTransferObjects.Item>'. An explicit conversion exists (are you missing a cast?)