c# - How to convert LINQ Query Generic List of Anonymous objects to IEnumerable<object> -


i have following repository method , trying convert linq query tolist result return type no avail. advice appreciated.

public class projectrepository : iprojectrepository {     idbentities dbcontext;     public projectrepository(idbentities db)     {         dbcontext = db;     }     public ienumerable<project> selectall(bool? is_debug_mode, int? performed_by_id)     {         var projects = (from p in dbcontext.projects                         join o in dbcontext.organizations on p.organization_id equals o.organization_id                         join m in dbcontext.members on o.organization_id equals m.organization_id                         m.member_id == performed_by_id                         select new                         {                             p                         }).tolist();         return (ienumerable<project>)projects;     } } 

the error receive is:

unable cast object of type 'system.collections.generic.list1[<>f__anonymoustype21[namespace.data.project]]' type 'system.collections.generic.ienumerable`1[namespace.data.project]'.

assuming p in linq query of type project

var projects = (from p in dbcontext.projects                 join o in dbcontext.organizations on p.organization_id equals o.organization_id                 join m in dbcontext.members on o.organization_id equals m.organization_id                 m.member_id == performed_by_id                 select p).tolist(); return projects; 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -