You are using anonymous types and there are limits as to what you can do with them, so the solution is to not use them.
Create a concrete class with the appropriate ID and Name properties
class MyData
{
public int ID { get; set; }
public string Name { get; set; }
}
update your query to use it
var query= (from p in tableA join b in tableB on p.ID equals b.ID select new MyData { ID=p.ID,Name=p.Name}).ToList();