I created the below function to get FirstName and LastName and place them into a string FullName.
My linq statement looks a bit funny as I am doing 2 queries on the same row to get the information I need.
Is there a better way of coding this?
public static string getMemberFullNamebyID(int memID)
{
using (var ctx = new GPEntities())
{
string fname = string.Empty;
string lname = string.Empty;
fname = ctx.Members.Where(g => g.memID == memID).Select(g => g.memFirstName).FirstOrDefault();
lname = ctx.Members.Where(g => g.memID == memID).Select(g => g.memLastName).FirstOrDefault();
return (lname + ", " + lname).ToString();
}
}
How about: