Suppose I want to set FullName
property using string.Format
like this:
var userList = users.Select(user => new User()
{
Id = user.Id,
UserName = user.UserName,
FirstName = user.FirstName,
LastName = user.LastName
FullName = string.Format("{0} {1}", user.UserName, user.FirstName)
}).ToList();
This obviously doesn't work because LINQ doesn't know about string.Format
.
My question is what are the other options beside going over the list in memory and setting FullName
for each item?
userList.ForEach(u => u.FullName = string.Format("{0} {1}", user.UserName, user.FirstName))
UPDATE: to see what I need, please see my conversation with @octavioccl below