1
该查询实际工作但ClientName
集返回null
新的对象,其中名字或姓氏是null
(两个中的任何一个)。我该如何解决这个问题?我想在这些行中有一个空字符串,而不是null
。串联NULL和Linq中的字符串实体查询
var clients =
from client in _repository.GetAll()
where (client.Firstname.StartsWith(query) || client.Lastname.StartsWith(query))
select new
{
ClientName = (client.Firstname + " " + client.Lastname).Trim(),
client.Firstname,
client.Lastname,
client.Address1,
client.Address2,
client.client_id,
client.PrettyId,
client.PostCode.postalcode,
client.PostCode.postname
};
这就是为什么在设置字符串字段在数据库中为空的没有意义的原因。将FirstName和SecondName设置为NOT NULL,并忘记这些问题。 – LukLed 2011-02-16 04:24:55