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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

江戶川亂折騰 2019-10-21 10:39:10
MVC3 Web應用程序內(nèi)部出現(xiàn)錯誤。 LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.當我嘗試使用EF從查詢中獲取值時: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 回答

?
繁星點點滴滴

TA貢獻1803條經(jīng)驗 獲得超3個贊

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


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


var pricingSecurityID = (from m in dbContext.Reporting_DailyNAV_Pricing

                                     select m.PricingSecurityID).AsEnumerable()

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


查看完整回答
反對 回復 2019-10-21
?
楊__羊羊

TA貢獻1943條經(jīng)驗 獲得超7個贊

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


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


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

比較數(shù)字時,請執(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

工夫。


查看完整回答
反對 回復 2019-10-21
  • 3 回答
  • 0 關注
  • 1772 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號