Tôi có một danh sách người dùng, mỗi người dùng có danh sách các câu hỏi. Trong danh sách các câu hỏi mô hình của tôi nên có chuỗi thông qua dấu phẩy. Tôi cố gắng:LINQ, không thể tham gia vào chuỗi
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; }
}
tất nhiên, tôi nhận được lỗi:
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.
Làm thế nào để có được nó một cách chính xác?
thay vì tham gia trong 'linq', chỉ cần trả lại bộ sưu tập và làm việc gia nhập sau khi hồi –