While using EF (up to version 6.1.3 at least) assuming you have a class like this:
class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
if you to get a field FullName
that is the concatenation of both (FirstName
and LastName
) as a field in query result you would have to do something like this:
db.Customers.Select(c => new { FullName = c.FirstName + " " + c.LastName })
now that there is String Interpolation in C# could you do something like this instead
db.Customers.Select(c => new { FullName = $"{c.FirstName} {c.LastName}" })
this might seem like a trivial example (which it is) but the question remains.
Can I use this out of the box, do I need to make some tricks to get it working or is it sure it won't work?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…