When using EF (at least until version 6.1.3), if you have a class like this:
class Customer { public string FirstName { get; set; } public string LastName { get; set; } }
if you get a FullName field which is a concatenation of both ( FirstName and LastName ) as a field as a result of the query, you will need to do something like this:
db.Customers.Select(c => new { FullName = c.FirstName + " " + c.LastName })
now that there is String Interpolation in C #, you could do something like this instead
db.Customers.Select(c => new { FullName = $"{c.FirstName} {c.LastName}" })
this may seem like a trivial example (as it is), but the question remains.
Can I use this out of the box, do I need to do some tricks to make it work, or is it sure it wonβt work?
c # linq entity-framework
Luiso
source share