LINQ to Entities无法识别方法'System.String ToBase64String(Byte [])'方法, [英] LINQ to Entities does not recognize the method 'System.String ToBase64String(Byte[])' method,
本文介绍了LINQ to Entities无法识别方法'System.String ToBase64String(Byte [])'方法,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
LINQ to Entities无法识别方法'System.String ToBase64String(Byte [])'方法,并且该方法无法转换为商店表达式.
LINQ to Entities does not recognize the method 'System.String ToBase64String(Byte[])' method, and this method cannot be translated into a store expression.
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函数:
Change your LINQ so that your original statement returns a list of anonymous objects, and then select on THAT list and use the ToBase64String function:
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();
这篇关于LINQ to Entities无法识别方法'System.String ToBase64String(Byte [])'方法,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文