第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

為什么LINQ to Entities無(wú)法識(shí)別方法'System.String ToString()

為什么LINQ to Entities無(wú)法識(shí)別方法'System.String ToString()

江戶川亂折騰 2019-10-21 10:39:10
MVC3 Web應(yīng)用程序內(nèi)部出現(xiàn)錯(cuò)誤。 LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.當(dāng)我嘗試使用EF從查詢中獲取值時(shí):public class DataRepository    {        public mydataEntities1 dbContext = new mydataEntities1();        public List<SelectListItem> GetPricingSecurityID()        {        var pricingSecurityID = (from m in dbContext.Reporting_DailyNAV_Pricing                                     select new SelectListItem                                         {                                                Text = m.PricingSecurityID.ToString(),                                                Value = m.PricingSecurityID.ToString()                                         });        return pricingSecurityID.ToList();        }    }
查看完整描述

3 回答

?
繁星點(diǎn)點(diǎn)滴滴

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊

那不能轉(zhuǎn)換成SQL。我猜,從理論上講,它可以,但是沒有實(shí)現(xiàn)。


得到結(jié)果后,只需執(zhí)行投影即可:


var pricingSecurityID = (from m in dbContext.Reporting_DailyNAV_Pricing

                                     select m.PricingSecurityID).AsEnumerable()

    .Select(x => new SelectListItem{ Text = x.ToString(), Value = x.ToString() });


查看完整回答
反對(duì) 回復(fù) 2019-10-21
?
楊__羊羊

TA貢獻(xiàn)1943條經(jīng)驗(yàn) 獲得超7個(gè)贊

這個(gè)怎么樣。在此示例中,db中的VDN字段和Skill字段都是整數(shù)。我正在尋找來(lái)自兩個(gè)領(lǐng)域的比賽,所以我有2個(gè)比較。


包括以下內(nèi)容:


using System.Data.Objects.SqlClient; // needed to convert numbers to strings for linq

比較數(shù)字時(shí),請(qǐng)執(zhí)行以下操作:


        // Search Code

            if (!String.IsNullOrEmpty(searchString))

            {

                depts = depts.Where(d => SqlFunctions.StringConvert((double)d.VDN).Contains(searchString.ToUpper())

                || SqlFunctions.StringConvert((double)d.Skill).Contains(searchString.ToUpper()));

            }

        // End Search Code

工夫。


查看完整回答
反對(duì) 回復(fù) 2019-10-21
  • 3 回答
  • 0 關(guān)注
  • 1760 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)