public class Person
{
public string FirstName { get; set; } = string.Empty
public string LastName { get; set; } = string.Empty
public string FullName { get; set; } = string.Empty
}
How can I update FullName
as
FullName = $"{FirstName} {LastName}"
Placing the above line in the constructor doesn't seem to cut it as values of FirstName
& LastName
seems to be default and Entity Framework persists as an empty string too.
How can I make this work with EF without explicitly calling a method or assigning directly to the field FullName
from other classes?
Package: EF Core Cosmos 3.1
If you don't need to persist the FullName property, you can go with:
[NotMapped]
public string FullName => $"{FirstName} {LastName}";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.