ADO.NET实体框架 - pre-生成视图 - [英] ADO.NET Entity Framework - Pre-Generate Views -

查看:134
本文介绍了ADO.NET实体框架 - pre-生成视图 - 的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用ADO.NET实体为我们的ASP.NET应用程序。

We are using ADO.NET Entity for our ASP.NET application.

我已经阅读了pre-产生意见提高了性能。所提到的博客文章,

I have read that the pre-generated views improves the performance. Referred to the blog post,

<一个href="http://blogs.msdn.com/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx" rel="nofollow">http://blogs.msdn.com/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx,我产生了意见。命名空间和放大器;作为生成的类

http://blogs.msdn.com/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx, I generated the views. The namespace & classes generated as

namespace Edm_EntityMappingGeneratedViews
{


    /// <Summary>
    /// The type contains views for EntitySets and AssociationSets that were generated at design time.
    /// </Summary>
    public sealed class ViewsForBaseEntitySets4D4A6E0AA7AF6B2298FABB4F22235831 : System.Data.Mapping.EntityViewContainer
    {

        /// <Summary>
        /// The constructor stores the views for the extents and also the hash values generated based on the metadata and mapping closure and views
        /// </Summary>
        public ViewsForBaseEntitySets4D4A6E0AA7AF6B2298FABB4F22235831()
        {
            this.EdmEntityContainerName = "JSEntities";

我说这我的数据层和测试性能。看不到多大的改善。 CPU使用率总是转到20-30%的利用率(响应时间为好),减少到0%,在500毫秒 - 1秒。我认为,CPU使用率每次都去,因为视图生成高。

I added this to my data layer and test the performance. Couldn't see much improvement. CPU usage always goes to 20-30% utilization (response timing is good) and reduce back to 0% in 500ms - 1 sec. I think the CPU utilization goes high because of view generation every time.

我不明白为什么实体框架知道,这是我的pre生成视图类为我的模型eventhough的MyModel.edmx和放大器; MyModel.Views.cs与文件名匹配。

I couldn't understand how the entity framework knows that this is my pre-generated view class for my model eventhough the MyModel.edmx & MyModel.Views.cs matches with filename.

我应该有更新的Web.Config或app.config中映射视图类的地方模式?

Should I have to update Web.Config or App.Config to map the View class to model somewhere?

请澄清。

推荐答案

我一直在想同样的事情,在做一些挖掘。

I've been wondering the same thing and been doing some digging.

据我可以告诉生成的类文件中包含一个程序集级别的属性, EntityViewGenerationAttribute ,它定义包含pre-编译视图类的类型。 然后,在这里我只是做的猜测,在编译时的类必须通过反射,并以某种方式绑定到视图定义的查询被加载。可能在ESQL缓存,这将makea一定量感

As far as I can tell the generated class file contains an assembly level attribute, EntityViewGenerationAttribute, which defines the class type that contains the pre-compiled view. Then, and here im only making educated guesses, at compile time the class must be loaded via reflection and in some way bound to the queries the view defines. Possibly in the ESQL cache, which would makea certain amount of sense.

尽管视图的ARE pre-编译自己只生产一些ESQL,没有这将是运行的实际TSQL。然而pre-编译意见并允许查询的执行跳过验证和ESQL生成步骤应该提供一个轻微的性能提升,特别是对于大型compilcated查询。

Even though the view's are pre-compiled they only produce ESQL, not the actual TSQL which will be ran. However pre-compiling views does allow the execution of a query to skip the validation and ESQL generation step which should offer a slight performance gain, especially for large compilcated queries.

这篇关于ADO.NET实体框架 - pre-生成视图 - 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆