我有一個用戶列表,每個用戶都有問題列表。在我的模型列表中,問題應通過逗號串入。我嘗試:LINQ,無法加入字符串
public List<ITW2012Mobile.ViewModels.AdminSurveyReportModel> SurveyReportList()
{
var q = from i in _dbContext.Users
where i.UserId != null
select new ITW2012Mobile.ViewModels.AdminSurveyReportModel()
{
FirstName = i.FirstName,
LastName = i.LastName,
Question4 = String.Join(", " , (from a in _dbContext.MultipleQuestions where a.MultipleQuestionType.KEY == MultipleQuestionKeys.BENEFITS select a.Question).ToArray())
};
return q.ToList();
}
public class AdminSurveyReportModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Question4 { get; set; }
}
當然
,我得到錯誤:
LINQ to Entities does not recognize the method 'System.String Join(System.String, System.String[])' method, and this method cannot be translated into a store expression.
如何正確地得到它?
而不是'linq',剛剛返回集合並做檢索 – 2012-03-10 14:07:08