-1

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();
4

2 回答 2

3

更改您的 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();
于 2013-03-13T17:39:21.410 回答
0
    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));
于 2017-04-10T12:54:07.943 回答