2013-02-07 23 views
-1

其中表達:如何將int轉換爲字符串列?

filtrationResult = filtrationResult.Where(string.Format("Convert.ToString({0}).Contains(@0)", filter.Field), filter.Value); 

filter.Field的名稱列(Int32)已

我得到錯誤:

LINQ to Entities does not recognize the method 'System.String ToString(Int32)' method, and this method cannot be translated into a store expression. 

轉換如何正確?

+0

像一個數字的部分搜索? –

+0

RaphaëlAlthaus,是 – Mediator

回答

0

我會爲filter.Field創建一個包含所有可能值的switch語句,然後使用EF生成的屬性。

+0

如果您使用的是EF,那麼我會使用'SqlFunctions.StringConvert' –

+0

類型'CompanyListItem'中不存在屬性或字段'SqlFunctions' – Mediator

+0

'SqlFunctions'是一個'static'類。 –