Q:

Get Linq Subquery into a User Defined Type

I have a linq query, which is further having a subquery, I want to store the result of that query into a user defined type, my query is
var val = (from emp in Employees
                   join dept in Departments
                   on emp.EmployeeID equals dept.EmployeeID
                   select new Hello
                   {

                       EmployeeID = emp.EmployeeID
                       Spaces = (from order in Orders
                               join space in SpaceTypes
                               on order.OrderSpaceTypeID equals space.OrderSpaceTypeID
                               where order.EmployeeID == emp.EmployeeID                                   group new { order, space } by new { order.OrderSpaceTypeID, space.SpaceTypeCode } into g
                               select new
                               {
                                   ID = g.Key.SpaceTypeID,
                                   Code = g.Key.SpaceTypeCode,
                                   Count = g.Count()
                               })
                   }).ToList();

Definition for my Hello class is 
public class Hello
{      
    public IEnumerable<World> Spaces { get; set; }
    public int PassengerTripID { get; set; }      
}

Definition for my World class is 
 public class World
{
    public int ID { get; set; }
    public string Code { get; set; }
    public int Count { get; set; }
}

A:

You are creating anonymous object but you need to specify type name World
 select new World
          {
           ID = g.Key.SpaceTypeID,
           Code = g.Key.SpaceTypeCode,
          Count = g.Count()
           })

