我的 MVC asp.net 动态数据 Web 应用程序中的脚手架问题

发布于 2024-09-30 06:30:06 字数 1258 浏览 2 评论 0原文

我正在开发一个 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,但我还是得到了默认值中所有表的列表.aspx 页面。

我有大约 50 个表,但我只需要 3 或 4 个表的动态数据。如果我注释代码片段 4,问题就会解决,但我不能这样做。有解决方法吗?

我还尝试注释代码片段 2 并为我想要列出的所有表添加代码片段 3。它仍然显示所有 50 张桌子。

问候,

哈里

I am working on an asp.net MVC application. I have the following code in my global.asax file for dynamic data implementation

Code snippet 1:

model.RegisterContext(typeof(MyCustomEntities), new ContextConfiguration() { ScaffoldAllTables = false });

Code snippet 2:

routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
{
    Constraints = new RouteValueDictionary(
     new { action = "List|Details|Edit|Insert" }),
    Model = model
});

Code snippet 3:

//routes.Add("MyTable1", new DynamicDataRoute("MyTable1/{action}.aspx")
//{
//    Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
//    Model = model,
//    Table = "MyTable1"
//});

Code snippet 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
);

Problem is despite of having scaffoldingAlltables = false, I get the listing of all tables in my Default.aspx page.

I have aroung 50 tables but i want dynamic data for only 3 or 4 tables. The problem gets solved if I comment code snippet 4, but I cannot do that. Is there a workaround for this?

I also tried commenting code snippet 2 and adding code snippet 3 for all the tables I want to list. Still it shows all the 50 tables.

Regards,

HARI

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文