asp.net-mvc - 具有 Entity Framework 的 MVC Controller 的 T4 模板 - 主机的成员属性 (MvcTextTemplateHost)?

标签 asp.net-mvc visual-studio asp.net-mvc-3 t4 scaffolding

是否有人完整引用了我可以在 MVC 3 附带的 T4 模板 ControllerWithContext.tt 中使用的 Host 对象的成员?

我已经尝试了所有我能想到的谷歌搜索,但唯一相关的结果是这个页面:
http://blogs.msdn.com/b/webdevtools/archive/2009/01/29/t4-templates-a-quick-start-guide-for-asp-net-mvc-developers.aspx

但它只显示 4 个属性(ItemName、NameSpace、ExtraActionMethods、ControllerRootName)而不是完整列表。在模板中有相关属性、实体集名称、模型类型和上下文类型。

我正在尝试查找属性、它们的类型和描述的完整列表。任何帮助将不胜感激。

最佳答案

我整理了一份ASP.NET MVC 3 properties available to T4 templates 的非官方列表。当您在 Visual Studio 2010 中使用“添加 View ”或“添加 Controller ”对话框时。它不包括在 NuGet 包管理器控制台中使用 MvcScaffolding 时可用的属性。属性信息是使用 T4 模板确定的,以反射(reflect) MvcTextTemplateHost 上的公共(public)属性。

添加 Controller :

+--------------------+---------------+----------------------------------------------------------------------------------------+
|   Property Name    |     Type      |                                      Description                                       |
+--------------------+---------------+----------------------------------------------------------------------------------------+
| AddActionMethods   | Boolean       | Adds action methods to the generated controller class.                                 |
| AreaName           | System.String | The name of the Area that the controller is created for.                               |
| ContextType        | System.Type   | The type of the data context.                                                          |
| ControllerName     | String        | The name of the controller class that will be generated.                               |
| ControllerRootName | String        | The name of the controller class excluding the Controller part at the end of the name. |
| EntitySetName      | String        | Name of the property on the data context class containing the set of entities.         |
| ModelType          | System.Type   | The type of the model class specified in the Add Controller dialog.                    |
| Namespace          | String        | Namespace that will be used for the generated controller class.                        |
| PrimaryKeys        | PrimaryKey[]  | Primary keys for the model. See table at end for PrimaryKey properties.                |
| RelatedProperties  | Dictionary    | Related properties on the model. See table at end for RelatedModel properties.         |
+--------------------+---------------+----------------------------------------------------------------------------------------+

添加查看 :

+-----------------------------+---------------+------------------------------------------------------------------------------------------+
|        Property Name        |     Type      |                                       Description                                        |
+-----------------------------+---------------+------------------------------------------------------------------------------------------+
| AreaName                    | System.String | The name of the Area that the view is being created for.                                 |
| ContentPlaceHolderIDs       | List<string>  | List of content place holder IDs in the master page.                                     |
| IsContentPage               | Boolean       | True if the generated view will be created with a master page or a Razor layout page.    |
| IsPartialView               | Boolean       | True if the generated view is a partial view (e.g. an ASP.NET user control).             |
| MasterPageFile              | String        | Master page file or Razor layout to be used with view (e.g. ~/Views/Shared/Site.Master). |
| Namespace                   | String        | Namespace that will be used for the generated view.                                      |
| PrimaryContentPlaceHolderID | String        | Primary content place holder ID to be used when creating a view using a master page.     |
| ReferenceScriptLibraries    | Boolean       | True if checked in the Add View dialog.                                                  |
| ViewDataType                | System.Type   | The view model's type.                                                                   |
| ViewDataTypeName            | String        | Fully qualified name for the view model's type.                                          |
| ViewName                    | String        | Name of the view.                                                                        |
+-----------------------------+---------------+------------------------------------------------------------------------------------------+

常见属性 :

+---------------------+-------------------------+-----------------------------------------------------------------------------------------------+
|    Property Name    |          Type           |                                          Description                                          |
+---------------------+-------------------------+-----------------------------------------------------------------------------------------------+
| AssemblyPath        | List<string>            | List of assemblies referenced by the project and the project's output assembly. Internal use. |
| Errors              | CompilerErrorCollection | Used to stored errors that occur whilst processing the T4 template. Internal use.             |
| FileEncoding        | System.Text.Encoding    | The encoding of the file that will be generated.                                              |
| FileExtension       | String                  | Not set.                                                                                      |
| FrameworkVersion    | System.Version          | The .NET framework version.                                                                   |
| OutputFileExtension | System.String           | The extension of the file that will be generated.                                             |
| TemplateFile        | System.String           | The full path to the T4 template file being used.                                             |
+---------------------+-------------------------+-----------------------------------------------------------------------------------------------+

关于asp.net-mvc - 具有 Entity Framework 的 MVC Controller 的 T4 模板 - 主机的成员属性 (MvcTextTemplateHost)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7583858/

相关文章:

javascript - JSON:.NET MVC3 中的 500(内部服务器服务器错误)

jquery - 如何修复 jQuery.fn.init.jQuery 中未定义的 jquery url.indexOf 函数?

javascript - 如何防止从项目外部提交表单

c++ - 当基类成员的析构函数具有非空 noexcept 说明符和主体时,析构函数上的 C2694

asp.net-mvc-3 - 通过一个 Action 对两个模型执行创建操作

c# - 使用 Fluent Security 捕获来自RequiredRole 和其他策略的异常以进行重定向

c# - EF5 中的 UOW 和存储库模式

c# - Request.Url.Scheme 在负载平衡站点上提供 http 而不是 https

c# - 转到定义并查找所有引用在 Visual Studio 中不起作用

javascript - 传递 JSON 对象时 View 中出现 Visual Studio "Conditiional compilation is turned off"错误