【发布时间】:2014-03-29 22:37:27
【问题描述】:
我在尝试正确获取模型时遇到了困难,无论如何我可以在 IEnumerable 中安装 2 个模型吗?这就是我所拥有的..
public class threadreplying
{
public IEnumerable<profile,Threadpost> IEThreadpost { get; set; }
public taker orginalthread { get; set; }
}
IEnumerable 只需要 1 个参数我怎样才能使 IEthreadpost 工作?我这样做是因为我在我的 sql 中实现了一个 Join 并需要来自存储在数据库中的两个模型的信息。我也试过这样做
public class ModelMix
{
public profile profiles { get; set; }
public Threadpost threadposts { get; set; }
}
public class threadreplying
{
public IEnumerable<ModelMix> IEThreadpost { get; set; }
public taker orginalthread { get; set; }
}
这可行,但它在视图中不起作用,即使我正在检查它也会给我一个空错误
@if (Model.IEThreadpost != null)
{
foreach (var item in Model.IEThreadpost)
{
@item.threadposts.post
}
}
【问题讨论】:
-
您收到错误是因为 threadposts 属性为空。