Trying to Project a EF linq result into IEnumerable of interfaces, something simialr to below but can’t get it working, any hints is apreciated:
IEnumerable<IBook> books = (from b in context.Library
(select new (Book() as IBook)
{
Id = b.Id,
Title = b.Title
}).AsEnumerable<IBook>;
Error : Cannot convert Lambda expression to type string because it is not delegate type.
PS : It is explicit interface implementation so I can’t just use the following that works with implicit interface implementation:
IEnumerable<IBooks> books = (from b in context.Library
select new Book()
{
Id = b.Id,
Title = b.Title
}).AsEnumerable<IBook>();
Try this:
Or you can do this:
Third option (for your explicit interface):