Since you are returning objects of an anonymous type, you cannot declare this in your return type for the method. Your attempt to use a common <T> will not work for this. There is no safe type method for declaring such a method. If you declare your return type as IList , then this should work, but you still will not have type safety.
You just have to declare a type.
Update:
Declaring a simple return type is not so bad. You can write a class like this:
public class MemberItem { public string IdMember { get; set; } public string UserName { get; set; } }
And then write your method as follows:
public static List<MemberItem> GetMembersItems(string ProjectGuid) { using (PMEntities context = new PMEntities("name=PMEntities")) { var items = context.Knowledge_Project_Members.Include("Knowledge_Project").Include("Profile_Information") .Where(p => p.Knowledge_Project.Guid == ProjectGuid) .Select(row => new MemberItem { IdMember = row.IdMember, UserName = row.Profile_Information.UserName }); return items.ToList(); } }
source share