Link to home
Start Free TrialLog in
Avatar of bemara57
bemara57

asked on

Possible to convert this anonymous delegate to lambda expression?

I've been checking into C# 3.0's lambda expressions and people seem to really like it. I can see how it kinda works but not how it can in this scenario. Can someone pls help convert this to a lambda expression since it would help me see the difference:

        public virtual MembershipUserCollection GetUsers(ListDictionary queryValues)
        {
            return this.SelectQuery<MembershipUserCollection>(queryValues,
                delegate(IDataReader results)
                {
                    MembershipUserCollection users = new MembershipUserCollection();

                    while (results.Read())
                    {
                        users.Add(new MembershipUser("SiteMembership",
                                                      results["UserId"].ToString(),
                                                      results["UserId"].ToString(),
                                                      results["Email"].ToString(),
                                                      results["PasswordQuestion"].ToString(),
                                                      results["PasswordAnswer"].ToString(),
                                                      Convert.ToBoolean(results["IsApproved"]),
                                                      false,
                                                      DateTime.Now,
                                                      DateTime.Now,
                                                      DateTime.Now,
                                                      DateTime.Now,
                                                      DateTime.MinValue));
                    }

                    results.Close();

                    return users;
                });
        }
ASKER CERTIFIED SOLUTION
Avatar of ZachSmith
ZachSmith
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bemara57
bemara57

ASKER

I guess lambda isn't that much better in this case. Thanks!
That is correct. There are certain instances where the lambda expressions really shine, but this just isn't one of them
That is correct. There are certain instances where the lambda expressions really shine, but this just isn't one of them