```
public ActionResult DownloadMembers()
{
    MembershipUserCollection users = Membership.GetAllUsers();
    var grid = new WebControls.GridView();
    grid.DataSource = from members in users  // the users gives error
                      select new
                      {
                          Name = members.FirstName, // This doesn't works
                          Email = members.Email     //  This doesn't works
                      };
    grid.DataBind();
    Response.ClearContent();
    Response.AddHeader("content-disposition", "attachment; filename=" + "Members" + ".xls");
    Response.ContentType = "application/excel";
    StringWriter sw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    grid.RenderControl(htw);
    Response.Write(sw.ToString());
    Response.End();
    return RedirectToAction("Index");
}

```

Hi The above query downloads all the details from the membership table into CSV format for ms excel, it gives an error on users which is:

> 
> Could not find an implementation of the query pattern for source type 'System.Web.Security.MembershipUserCollection'. 'Select' not found. Consider explicitly specifying the type of the range variable 'members'. 
> 
> 
> 

Can any one guide me on how to get just the user email address and his/her name on the csv instead of getting all the details.

Edited: This works :)

```
grid.DataSource = from MembershipUser u in Membership.GetAllUsers()
                  select new
                  {
                      Firstname = u.UserName,
                      Email = u.Email                                   
                  };

```