我有一個(gè)這樣的表達(dá)式:var values = Enumerable.Range(1,2);return message => message.Properties.Any( p => p.Key == name && int.Parse(p.Value) >= values[0] && int.Parse(p.Value) <= values[1]);這樣編譯可以,但是當(dāng)它命中數(shù)據(jù)庫(kù)時(shí)會(huì)拋出異常 'LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression '如果我不進(jìn)行分析并且將值設(shè)置為a string[],則不能在字符串上使用>=and <=運(yùn)算符。p.Value 是一個(gè)包含各種值的字符串,但是在這種情況下,它是 int有沒(méi)有一種方法可以查詢數(shù)據(jù)庫(kù)以執(zhí)行這種之間的語(yǔ)句?
實(shí)體框架/ Linq EXpression從字符串轉(zhuǎn)換為int
喵喵時(shí)光機(jī)
2019-12-05 16:04:28