我正在尝试执行以下操作:
from c in db.GetAllContactsQuery()
select new
{
ID= c.ID,
LastName = c.LastName,
FirstName = c.FirstName,
Email = c.Email,
City =c.City+" "+c.State
}
我遇到的问题是,如果 c.City 或 c.State 为 null,则 City 属性返回 null。如何在该City=
声明旁边放置一个函数?
我真的很想知道是否可以做这样的事情(这不起作用):
from c in db.GetAllContactsQuery()
select new
{
ID= c.ID,
LastName = c.LastName,
FirstName = c.FirstName,
Email = c.Email,
City ={ c=>
//completely sweet function in here
if(String.IsNullOrEmpty(c.City))
return "booyah";
}
}