Tengo una lista de usuarios, cada usuario tiene una lista de preguntas. En mi modelo, la lista de preguntas debe estar en cadena a través de una coma. Trato:LINQ, no se puede unir a la cadena
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; }
}
por supuesto, me sale error:
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.
Como llegar correctamente?
en lugar de unirse en 'linq', simplemente devolver la colección y hacer la unión después de la recuperación –