简体   繁体   English

LINQ to Entities无法识别方法'System.String ToBase64String(Byte [])'方法,

[英]LINQ to Entities does not recognize the method 'System.String ToBase64String(Byte[])' method,

LINQ to Entities does not recognize the method 'System.String ToBase64String(Byte[])' method, and this method cannot be translated into a store expression. 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();

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: 更改您的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));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 意外错误:LINQ to Entities 无法识别方法“System.String DecryptValue(Byte[], System.String)”方法 - Unexpected Error : LINQ to Entities does not recognize the method 'System.String DecryptValue(Byte[], System.String)' method LINQ to Entities 无法识别“System.String Decrypt(System.String, System.String)”方法 - LINQ to Entities does not recognize the method 'System.String Decrypt(System.String, System.String)' method LINQ to Entities无法识别方法'System.String LetterType(Byte)',并且该方法无法转换为商店表达式 - LINQ to Entities does not recognize the method 'System.String LetterType(Byte)' method, and this method cannot be translated into a store expression LINQ to Entities无法识别方法'System.String ToString()'方法++++++ - LINQ to Entities does not recognize the method 'System.String ToString()' method ++++++ LINQ to Entities无法识别方法'System.String getFullname(System.String,System.String)' - LINQ to Entities does not recognize the method 'System.String getFullname(System.String, System.String)' LINQ to Entities无法识别方法'System.String [] ToArray [String] - LINQ to Entities does not recognize the method 'System.String[] ToArray[String] (MVC)LINQ to Entities无法识别方法'Boolean VerifyHashedPassword(Byte [],System.String)'方法 - (MVC) LINQ to Entities does not recognize the method 'Boolean VerifyHashedPassword(Byte[], System.String)' method LINQ to Entities无法识别方法'System.String - LINQ to Entities does not recognize the method 'System.String LINQ to Entities无法识别方法'System.String Format - LINQ to Entities does not recognize the method 'System.String Format LINQ to Entities无法识别方法'System.String IfNullOrWhiteSpace' - LINQ to Entities does not recognize the method 'System.String IfNullOrWhiteSpace'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM