0

Error:

Cannot convert method group 'ToList' to non-delegate type 'System.Collections.Generic.List'. Did you intend to invoke the method? D:\PROJECTS\CECB2013-03-26\CECB\cecb.Functions\ActivationCodeEmail.cs 102 20 cecb.Functions*

My code is

 List<Members> teamMembers = new List<Members>();

 var query = from c in cecbContext.Projects
             join b in cecbContext.TeamMembers on c.proj_team equals b.team_reference
             join d in cecbContext.Members on b.mem_reference equals d.mem_reference
             select new
                    {
                        d.mem_reference
                    };

    return query.ToList<Members>;
}
4

1 回答 1

1

You've forgotten the brackets after ToList - it's an ( extension ) method:

return query.ToList<Members>();

You have another problem, though - you trying to turn an IQueryable<AnonymousType> into a List<Members>.

If you create instances of Members in your Select clause, it will work and you will be able to omit the generic type parameter on ToList()

select new Members
{
  ...
};

return query.ToList(); // this will create a List<Members>
于 2013-03-30T16:35:41.707 回答