不包含它的價值
一些假設你的意思是:
symbol
是一個字符串。
- 包含一個數字字符。
然後,如果這個正在客戶端上完成的)一個簡單的正則表達式將工作:
Dim results = (From t In ctx.events
Where t.date >= dStartDate.Date And t.date <= dEndDate.Date
Where Not Regex.IsMatch(t.symbol, "\d")
Order By t.time
Select New With {
t.symbol,
t.date, t.time,
t.description,
t.domestic_call_num,
t.web_url
}).ToList()
當然,這是不可能的(一個EF提供商可以實現正則表達式)工作的客戶端。接受一組特定的數字(例如,只是西方語言的阿拉伯數字)會使問題變得更加容易:請參閱其他answer。
服務器上更通用的解決方案很可能取決於您正在使用的提供程序的函數(或實體-SQL)的細節。除非這樣大量的行會被過濾掉,否則會產生差異(需要傳輸更多的數據),那麼混合解決方案是可能的。做盡可能多篩選的服務器上爲可以很容易地有工作要做,並在本地執行,其餘(如果我已經得到了VB語法右):
Dim results = (from s in (
From t In ctx.events
Where t.date >= dStartDate.Date And t.date <= dEndDate.Date
Order By t.time
Select New With {
t.symbol,
t.date, t.time,
t.description,
t.domestic_call_num,
t.web_url
}).ToEnumerable()
Where Not Regex.IsMatch(s.symbol, "\d")
Select s
).ToList()
正則表達式將與EF工作? –
@lazyberezovsky:糟糕:不,這將需要執行的東西客戶端。然而,我不確定 - 沒有提供者的知識 - 可以避免(不止需要SQL LIKE)。 – Richard
是的,正則表達式在查詢中不起作用。我使用mySQL作爲提供者 – dinotom