Categories: java, c#, asp.net, asp.net-mvc, list

Problem with return type in asp MVC Repository

1 answer

I use list .Tolist() but it shows an error when return.I am use this method in asp.net MVC getaway/repository. I am also trying to find out this problem but don't find out the problem

public List<Floor> GetBuildingInfoByBuildId(int floor_Id)         {             var result = (from floor in db.Floors                           join c in db.Campuses on floor.CampusID equals c.ID                           join build in db.Buildings on floor.BuildingID equals build.ID                           where (floor.ID == floor_Id)                           select new                           {                               floor.ID,                               floor.Floor_Name,                               c.Campus_Name,                               build.Building_Name                           }).Tolist();             return result;                      } 
Received answer to this question:
The best answer according to the author of the question:

You need to specify the class object in the select statement.

public List<Floor> GetBuildingInfoByBuildId(int floor_Id)     {         return (from floor in db.Floors                       join c in db.Campuses on floor.CampusID equals c.ID                       join build in db.Buildings on floor.BuildingID equals build.ID                       where (floor.ID == floor_Id)                       select new Floor                       {                           floor.ID,                           floor.Floor_Name,                           c.Campus_Name,                           build.Building_Name                       }).Tolist();      } 

I hope it helps.