0
我有兩種不同的型號。一個是視圖模型,另一個是標準模型。我試圖將一個模型的結果合併到第二個視圖模型中。我被困在循環部分。將一個列表從一個模型合併到另一個模型中?
var model = new SurveyPageViewModel()
{
SurveyId = surveyData.Id,
Title = surveyData.Title,
Id = surveyData.Pages[0].Id,
Questions = new List<QuestionViewModel>()
{
new QuestionViewModel()
{
// I want to use the data I pulled in my surveyData here.
}
}
};
型號:
public class SurveyPageViewModel
{
public int? SurveyId { get; set; }
public string Title { get; set; }
public int? Id { get; set; }
public List<QuestionViewModel> Questions { get; set; }
}
public class QuestionViewModel
{
public int? Id { get; set; }
public string QuestionType { get; set; }
public string SubType { get; set; }
public string Text { get; set; }
public string Value { get; set; }
public int SortOrder { get; set; }
public bool IsHidden { get; set; }
public List<QuestionOptionViewModel> Options { get; set; }
}
我的其他型號:
public class SurveyPageViewModel
{
public int? Id { get; set; }
public List<QuestionViewModel> Questions { get; set; }
}
public class Question
{
public int? Id { get; set; }
public string QuestionType { get; set; }
public string SubType { get; set; }
public string Text { get; set; }
public int SortOrder { get; set; }
public bool IsHidden { get; set; }
public List<QuestionOptionViewModel> Options { get; set; }
}
什麼問題? –