LINQ to Entities不能识别'System方法.字符串ToBase64String (Byte []
本文关键字:ToBase64String 字符串 方法 Byte System Entities to 不能 识别 LINQ | 更新日期: 2023-09-27 18:03:48
LINQ to Entities不识别'System '方法。String ToBase64String(Byte[])'方法,该方法不能转换为存储表达式。
var activityList = (from item in committeeMemberList
let committee = db.Committee.FirstOrDefault(x => x.Committee_Id == item.Committee_Id)
let contact = db.Contacts.FirstOrDefault(x => x.Contact_Id == item.Contact_Id)
select new Activity
{
Id = Convert.ToBase64String(item.Committee_Member_SPE_Id),
Name = committee.Committee_Name,
...
...
}).ToList();
更改LINQ,使原始语句返回一个匿名对象列表,然后在该列表中选择并使用ToBase64String函数:
var activityList =
(from item in
(from member in committeeMemberList
let committee = db.Committee.FirstOrDefault(x => x.Committee_Id == item.Committee_Id)
let contact = db.Contacts.FirstOrDefault(x => x.Contact_Id == item.Contact_Id)
select new
{
Id = member.Committee_Member_SPE_Id,
Name = committee.Committee_Name,
...
...
}).ToList())
select new Activity
{
Id = Convert.ToBase64String(item.Id),
Name = committee.Committee_Name,
...
...
}).ToList();
var activityList =
(from item in
(from member in committeeMemberList
let committee = db.Committee.FirstOrDefault(x => x.Committee_Id == item.Committee_Id)
let contact = db.Contacts.FirstOrDefault(x => x.Contact_Id == item.Contact_Id)
select new
{
Id = member.Committee_Member_SPE_Id,
Name = committee.Committee_Name,
...
...
}).ToList());
//After Collecting information just update current value to base4string using following Syntax
activityList.ForEach(s=>s.id=(s.id==null?"noimage":Convert.ToBase4String(s.id));