Issue show data from userprofile data

Topics: Writing modules
May 5, 2013 at 4:08 PM
Hi, i trying show some data from a userprofile query but i get this error:

Image

Query is this:
var miembrosEquipo = _contentManager.Query<UserPart, UserPartRecord>()
                .List()
                .Select(user => ((dynamic) user).ProfilePart)
                .Select(user => new {
                    user.Nombre,
                    user.Apellidos,
                    ...
            });
miembroEquipo is Model.Miembros in view.

How Do i can show properties?

thanks in advance.
Coordinator
May 6, 2013 at 6:00 AM
Knowing nothing about that ProfilePart, it's hard to tell.
May 6, 2013 at 8:09 AM
Edited May 6, 2013 at 8:11 AM
Sorry for few information, I'll try to explain a little more. I am using Contrib.Profile module for ProfilePart, i have added in Profile Part (from dashboard) some fields (name, surname, facebook profile url, etc), all fields are input, media or link fields. I can use "miembrosEquipo" var in a foreach to get each value without issues in a action code, but when I use "miembrosEquipo" var as view Model I get a error getting these values in a foreach (no definition for object issue). I try create a ViewModel and set miembrosEquipo in a IEnumerable<dynamic> var without results.

I think create a new model from code and add all profile data to avoid these errors, but I want ask before continue.

Sorry for my bad English.
Coordinator
May 6, 2013 at 7:24 PM
The double select is bizarre. You should be able to replace that with a single select looking like:
.Select(user => {
    dynamic item = user.ContentItem;
    var profile = item.ProfilePart;
    return new {
        Nombre = profile.Nombre,
        //...
    };
})