Q:

Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Collections.Generic.List

i'm trying to return a list to show all of my content which is in a table which their id is equal to _id (in first If statement otherwise return all ) but i get this error 

Cannot implicitly convert type 'System.Collections.Generic.List (Project1.Models.EF_Model.Phone_book) to 'System.Collections.Generic.List(Project1.Models.EF_Model.Phone_BookEntities1)

and here's my code 
public List<Models.EF_Model.Phone_BookEntities1> Select(int? _id)
{
       var Ref_Phone = new Models.EF_Model.Phone_BookEntities1();
        if (_id.HasValue)
        {
            return Ref_Phone.Phone_book.Where(p => p.Id == _id); //here error shows up
        }
        else
        {
            Ref_Phone.Phone_book.ToList();
        }
} 

i tried to add this .ToList() it didn't work i don't know what to do

A:

You need to return a list of Phone_book instead of Models.EF_Model.Phone_BookEntities1 which is your context type:
public List<Models.EF_Model.Phone_book> Select(int? _id)
{
    var Ref_Phone = new Models.EF_Model.Phone_BookEntities1();
    return id.HasValue? Ref_Phone.Phone_book.Where(p => p.Id == _id).ToList():Ref_Phone.Phone_book.ToList();

} 

