LINQ to Entities无法识别方法'System.String Concat(System.Object)'方法,

时间:2013-05-16 21:32:48

标签: c# vb.net linq

当我尝试在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.错误?怎么解决这个?

     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()

2 个答案:

答案 0 :(得分:1)

你可以做到

SqlFunctions.StringConvert((double)factInitiative.Location_Idx) + ";" + factInitiative.Dim_Location.Location_Name

答案 1 :(得分:0)

我认为你可以用+连接字符串。如果您使用Concat进行隐式字符串转换,请考虑使用SqlFunction.StringConvert