【发布时间】:2013-10-03 23:05:32
【问题描述】:
我将 DataTables 与 jquery AJAX 和 Entity Framework 一起使用。我从将其序列化为 json 的网络方法返回 EntityFramework 对象。我有很多表需要生成 CRUD 页面,因此在后端页面中会有 CRUD webmethods。我以前是用动态数据做的。有没有办法使用 T4 模板生成这些页面?我目前没有确切的代码,但最终结果会是这样的
http://editor.datatables.net/release/DataTables/extras/Editor/examples/envelope_inline.html
这是 .aspx.cs 中的一些示例代码,它返回 json
[WebMethod]
public string GetCustomers(int page)
{
return db.Customers.Skip(page*100).Take(100);
}
[WebMethod]
public string DeleteCustomer(int id)
{
// ...
}
在 .aspx 页面上
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "scripts/server_processing.aspx"
}
} );
} );
【问题讨论】:
-
当然有,示例代码会更容易演示。你想做剃须刀还是普通的aspx? mvc 还是 web 表单?
-
在 MVC 中,内置了基于实体框架生成 CRUD 的模板。到目前为止,您正在使用什么以及您尝试过什么?
-
@Maslow 我包含了代码。
标签: c# .net code-generation t4