我在嘗試在LINQ中連接數字和字符串時出現LINQ to Entities does not recognize the method 'System.String Concat(System.Object)' method, and this method cannot be translated into a store expression.
錯誤?如何解決這個問題?LINQ to Entities無法識別方法'System.String Concat(System.Object)'方法,
Dim initiativeDataList As IEnumerable(Of InitiativeData) =
SGAEntities.Fact_Initiative.Where(Function(factInitiative) factInitiative.Client_Idx = client_Idx).[Select](
Function(factInitiative) New InitiativeData() With { _
.ClientIdx = factInitiative.Client_Idx,
.HierarchyIdx = factInitiative.Hierarchy_Idx,
.CostCenterIdx = factInitiative.Cost_Center_Idx,
.LocationIdx = factInitiative.Location_Idx,
.InitiativeIdx = factInitiative.Initiative_Id,
....
....
.Location = String.Concat(factInitiative.Location_Idx) + ";" + factInitiative.Dim_Location.Location_Name,
}).ToList()
我不認爲你想只包括*一件事*中的毗連,反正。但也許這個相關的問題可以幫助你在你的查詢中獲得你的數字作爲一個字符串。 http://stackoverflow.com/questions/4502842/int-to-string-in-entity-framework –
使用SqlFunctions.StringConvert將int轉換爲字符串 – maxlego