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

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

在EF 4.0中將字符串轉(zhuǎn)換為Int

在EF 4.0中將字符串轉(zhuǎn)換為Int

郎朗坤 2019-11-04 09:51:58
有沒(méi)有辦法做到這一點(diǎn)?我在數(shù)據(jù)庫(kù)中有一個(gè)字符串字段,我想將其解析為我的LINQ查詢(xún)中的int屬性(是的,它必須處于IQueryable級(jí)別,而不是位于內(nèi)存中)。我知道2年前EF 1.0不能做到這一點(diǎn)(即使LINQ to SQL開(kāi)箱即用也支持此基本功能)...但是我只是想知道現(xiàn)在是否有人想出辦法?自定義功能映射?特殊語(yǔ)法?什么都沒(méi)有...更新:我嘗試了模型定義的函數(shù),如下所示:    <Function Name="ConvertToInt32" ReturnType="Edm.Int32">      <Parameter Name="v" Type="Edm.String" />      <DefiningExpression>        CAST(v AS INT)      </DefiningExpression>    </Function>    [EdmFunction("Model.Repository", "ConvertToInt32")]    public static int ConvertToInt32(string value)    {        throw new InvalidOperationException("Only valid when used as part of a LINQ query.");    }但它似乎不起作用。我得到運(yùn)行時(shí)異常: ErrorDescription=Type 'INT' could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly.        StackTrace:             at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertTypeName(Node typeName, SemanticResolver sr)             at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertTypeExprArgs(BuiltInExpr astBuiltInExpr, SemanticResolver sr)             at System.Data.Common.EntitySql.SemanticAnalyzer.<CreateBuiltInExprConverter>b__73(BuiltInExpr bltInExpr, SemanticResolver sr)             at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertBuiltIn(Node astExpr, SemanticResolver sr)             at System.Data.Common.EntitySql.SemanticAnalyzer.Convert(Node astExpr, SemanticResolver sr)             at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertValueExpression(Node astExpr, SemanticResolver sr)             at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertQueryStatementToDbExpression(Statement astStatement, SemanticResolver sr)             at System.Data.Common.EntitySql.SemanticAnalyzer.AnalyzeQueryCommand(Node astExpr)
查看完整描述

2 回答

?
MMMHUHU

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

關(guān)于在運(yùn)行時(shí)將其添加到元數(shù)據(jù)工作空間的問(wèn)題非常好,但是我不知道答案。無(wú)論如何,您將無(wú)法將其映射到,Convert.ToInt32因?yàn)槟鸁o(wú)法EdmFunction向該方法添加屬性。

查看完整回答
反對(duì) 回復(fù) 2019-11-04
  • 2 回答
  • 0 關(guān)注
  • 669 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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