看板 C_Sharp 關於我們 聯絡資訊
請教一下,如何在Linq query中使用特殊字元? 舉例: var q = (from p in dataServiceManager.getDataService().XXXX where p.field1 == "TEST.TEST" select p).First(); 上面這個例子在執行時會出現DataServiceRequestException. 原因應該是出在"TEST.TEST"中有(.)出現(我猜想的) 如果我的資料有這類的特殊字元存在,我要怎麼修改where條件才能query得到? 補上error message HTTP 404. 您要尋找的資源 (或其相依性的其中之一) 可能已經移除、名稱已經變更或是暫時無法使用。 請檢閱下列 URL,並且確定它的拼寫無誤 要求的 URL: /EntityDataService.svc/XXXX('TEST.TEST') 版本資訊: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.272 [HttpException]: 檔案不存在。 於System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) 於 System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath) 於 System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) 於 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 於 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.222.153.62
bbcust:我覺得問題應該不是出在那 不然你把where拿掉試試 05/25 12:30
tong1219:where拿掉是ok的 05/25 13:12
ssccg:跟 . 沒關係,那在字串中是很正常的字元 05/25 13:42
tong1219:可以如果沒有.的話,where條件式可以運作的,多了.就掛了 05/25 13:43
tong1219:這跟field1是primary key有沒有關係? 05/25 13:46
glennchen:p.field1 == "TEST.TEST" ??? 05/25 13:47
已修正 ※ 編輯: tong1219 來自: 61.222.153.62 (05/25 13:54)
bbcust:== 05/25 13:54
bbcust:p.field1是object ? .是很一般字元 不是特殊字元 05/25 13:55
bbcust:exception message呢? 05/25 13:56
tong1219:原因可能是我設field1為primary key的關係 05/25 13:56
tong1219:如果TEST.TEST是用在其他非PK欄位是可以正常使用 05/25 13:57
bbcust:field1在DB中的type是什麼? 05/25 13:58
tong1219:varchar2 05/25 14:04
※ 編輯: tong1219 來自: 61.222.153.62 (05/25 14:08)
ashram:你的linq是直接寫在程式碼? 05/26 12:52
ashram:看message 那段where一起被當做web service url一部分了 05/26 12:53
ashram:所以才會404 如果是抓回來比對出錯就不是404 05/26 12:53