I have a LINQ statement where I'd like to merge in the First address with the Nickname of 'Me'.
using (var ctx = new DataEntities())
{
return from c in ctx.Customers.Include("Addresses")
let m = from a in c.Addresses where a.Nickname == "Me" select a
where m.Any()
select new
{
Id = c.CustomerId,
m.First().Name,
m.First().Address1,
m.First().Address2,
m.First().City,
m.First().State,
m.First().Zip,
m.First().Email,
m.First().PhoneNumber
};
}
I'm wondering:
- Is it going to hurt performance if I call First multiple times like this?
- Is there an better LINQ statement for this?
- Just also realized, Do I need to .Include("Addresses")?