我正在开发一个 asp.net MVC 应用程序。我的 global.asax 文件中有以下代码用于动态数据实现
代码片段1:
model.RegisterContext(typeof(MyCustomEntities), new ContextConfiguration() { ScaffoldAllTables = false });
代码片段2:
routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
{
Constraints = new RouteValueDictionary(
new { action = "List|Details|Edit|Insert" }),
Model = model
});
代码片段3:
//routes.Add("MyTable1", new DynamicDataRoute("MyTable1/{action}.aspx")
//{
// Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
// Model = model,
// Table = "MyTable1"
//});
代码片段4:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.MapRoute(
"Default",
// Route name
"{controller}/{action}/{id}",
// URL with parameters
new { controller = "Home", action = "Index", id = "" }
// Parameter defaults
);
问题是尽管有scaffoldingAlltables = false,但我在我的Default.aspx 页面中获得了所有表的列表。
我有大约 50 个表,但我只想要 3 或 4 个表的动态数据。如果我评论代码片段 4,问题就会得到解决,但我不能这样做。有解决方法吗?
我还尝试评论代码片段 2 并为我要列出的所有表添加代码片段 3。它仍然显示所有 50 个表。
问候,
哈里