c# - 预编译 View 不影响性能

标签 c# asp.net entity-framework c#-4.0 entity-framework-4

编辑:

这个问题不是关于编译查询,而是关于在编译时生成 EF 数据库 View 。

来自 ADO.NET 团队博客:Exploring the Performance of the ADO.NET Entity Framework - Part 1 :

View Generation 56%– A big part of creating an abstracted view of the database is providing the actual view for queries and updates in the store’s native language. During this step, the store views are created. The good news is there is a way of making view generation part of the build process so that this step can be avoided at run time.


我的 Web 应用程序中的第一个数据库调用大约需要 2.5 秒,而不是后续相同调用的大约 30 毫秒。

我使用 ADO.NET team blog 中的 T4 模板生成了一个预编译 View 源文件, 但它没有产生明显的差异。

T4 模板需要大约 2.5 秒的时间来运行并编译生成的代码。

我错过了什么?

最佳答案

已修复!

从 EntityViewContainer 派生的生成 View 必须位于包含 STO self 跟踪对象的程序集中,而不是包含 edmx 模型的程序集中。

关于c# - 预编译 View 不影响性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8272461/

相关文章:

c# - 将 List<IInfrastructureEntity> 转换为 List<TEntity>,其中泛型类型 TEntity 必须实现该接口(interface)

jquery - @html.BeginForm 使用 jquery Ajax 不能完全工作

c# - Entity Framework - 如何避免查询重新编译?

c# - 批量更新数据库的最快方法?

c# - 对 IComparable 对象进行排序,其中一些为 null

c# - JSON 响应被相当小的数组截断

c# - 在 c# asp.net 中复制到剪贴板

c# - 无法将 LINQ 查询结果转换为 ToList

c# - 从 Windows 服务打印 pcl 文件的 LPR 命令不起作用(现在是托盘应用程序)

c# - 修剪音频文件(.wav、.mp3)