How i can return list with anonymous type, because with this code i get
"The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)"
i need only return IdMember and UserName, thanks
public static List<T> 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 { IdMember = row.IdMember, UserName = row.Profile_Information.UserName });
return items.ToList();
}
}
The class Tuple<> is made for situations like this. Creating a custom class as already suggested is clearer, but Tupple gets the job done too.
e.g.
.Select(row => new Tuple<int,string>(row.IdMember,row.Profile_Information.UserName))
to access the member properties at the other side of the wire, you'll need to use:
var id=t.Item1
var name=t.Item2