控制器:
public ActionResult ABC()
{
var model = new Test.Models.Tables();
string ABC = "ABC";
model.TableA = db.TablesA.Where(d => d.ColumnA.Contains(ABC)).ToList();
model.TableB = (from d in db.TablesA.ToList()
join j in db.TablesB.ToList() on d.TableAID equals j.ID
select new TableB() { TableBDisplay = j.TableBDisplay });
List<Tables> allTables = new List<Tables>();
allTables.Add(model);
return View(allTables);
}
型号:
namespace Test.Models
{
public class Tables: DbContext
{
public IEnumerable<TableB> TableB { get; set; }
public List<TableA> TableA { get; set; }
public System.Data.Entity.DbSet<Test.TableA> TablesA { get; set; }
public System.Data.Entity.DbSet<Test.TableB> TablesB { get; set; }
}
}
查看:
我试过了:
@model IEnumerable <Test.Models.Tables>
@model List<Test.Models.Tables>
@model IEnumerable<Test.TableB>
和其他一些人。就显示多个表而言,这些都不起作用。我怎样才能使这个功能起作用?