如何在投影中連接兩個字符串?投影中的Concat字符串(Linq)
這是我到目前爲止有:
IEnumerable<NameIdentity> data = null;
JsonResult res;
using (DBContext _db = new DBContext())
{
data = MyEntity.GetEntities(_db).OrderBy(a=> a.name)
.Select(b=> new NameIdentity
{
ID = b.entityID,
Name = String.Join(" - ", new String[]{ b.year, b.name })
});
res = Json(data.ToList(), JsonRequestBehavior.AllowGet);
}
我需要在我的投影的名稱歡迎使用屬性來串聯年和name屬性。
給我的錯誤是一個「NotSupportedException」,它表示LINQ to Entities不能識別de Join()
方法,並且它不能轉換爲存儲表達式。
更多詳情請參閱? –
@ It'sNotALie。對不起,我更新了我的答案與真正的錯誤。 – amp