我的目标是:
我连接到数据库文件管理器,它基于一个单一的视图,这就是为什么我必须打两次电话。
但是然后我想将这2个调用的结果放在同一个对象(oEventViewModel)中,以便将它们发送回我的视图。
您有解决办法吗?
控制器
[Authorize]
[HttpGet]
public async Task<ActionResult> Index()
{
ViewBag.sessionv = HttpContext.Session.GetInt32("idMember");
FileMakerRestClient client = new FileMakerRestClient(serverName, fileName, userName, password);
var toFind = new Models.EventsLines { Zkf_CTC = 1053 };
var results = await client.FindAsync(toFind);
Models.EventViewModel oEventViewModel = new Models.EventViewModel
{
_EventsLines = (from o in results select o).ToList()
};
var xtoFind = new Models.SubEventsLines { Zkf_CTC = 1053 };
var xresults = await client.FindAsync(xtoFind);
Models.EventViewModel oSubEventViewModel = new Models.EventViewModel
{
_SubEventsLines = (from x in xresults select x).ToList()
};
ViewBag.Zkf_CTC = 1053;
ViewBag.JsonList = oEventViewModel;
return View(oEventViewModel);
}
模型
public class EventViewModel
{
public List<EventsLines> _EventsLines { get; set; }
public List<SubEventsLines> _SubEventsLines { get; set; }
}