MVC是否将不同的关键字“virtual”用于C#webForm应用程序? [英] Does MVC utilise the keyword 'virtual' differently to a C# webForm application?

查看:93
本文介绍了MVC是否将不同的关键字“virtual”用于C#webForm应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说过很多关于MVC中的延迟加载(我对MVC btw来说是全新的),并且很多人说你在实体框架中懒得加载的属性上使用了virutal关键字。



任何人都可以解释这是否意味着虚拟关键字在MVC中具有与标准应用程序中不同的含义,其中虚拟均值='属性/方法可以被派生类覆盖',或者是允许两者?



这是一种很好的做事方式,并且在WebForm使用c#代码和MVC之间是否存在任何其他关键字差异。



抱歉,我只是MVC和EF的新手,想要清除它。

解决方案

1.Lazy loading related与EF并不依赖于MVC。您可以在下一个链接中找到有关它的详细信息: http:// msdn.microsoft.com/en-us/library/vstudio/dd456846(v=vs.100).aspx [ ^ ]

或者如果你想要关于延迟加载的信息这里有一篇很好的文章:你能解释一下Lazy Loading吗? [ ^ ]



2.虚拟是C#语言的一部分,不依赖于使用的UI技术:MVC,Web窗体,Windows窗体或WPF。


< blockquote>通过使属性 virtual ,实体框架可以为您的对象创建动态代理,并通过重写属性支持延迟loadi ng。



虚拟关键字没有不同的含义,只是允许框架操纵你的对象以某种方式允许其他功能(如延迟加载)工作。



希望这会有所帮助,

Fredrik


I've heard a lot about lazy loading in MVC (i'm completely new to MVC btw), and alot say you utilise the virutal keyword on properties you wish to lazy load from Entity Framework.

can anyone explain does that mean the virtual keyword has a different meaning in MVC than in standard application where virtual means = 'the property / method can be overriden by the derived class', or does it allow both ?

is this a good way of doing things, and is there any other keyword differences between WebForm usage of c# code and MVC.

sorry i'm just new to MVC and EF, and wanted to clear this up.

解决方案

1.Lazy loading related with EF does not depends on MVC. You could find details about it in the next link: http://msdn.microsoft.com/en-us/library/vstudio/dd456846(v=vs.100).aspx[^]
Or if you want info about "Lazy Loading" in general here is a good article: Can you explain Lazy Loading?[^]

2."virtual" is part of C# language and does not depend on the used UI technology: MVC, Web Forms, Windows Forms or WPF.


By making the properties virtual, entity framework can conjure up dynamic proxies for your objects, and through the overridden properties support lazy loading.

The virtual keyword does not have a different meaning, it just allows the framework to manipulate your object in a way that allows additional functionality (like lazy loading) to work.

Hope this helps,
Fredrik


这篇关于MVC是否将不同的关键字“virtual”用于C#webForm应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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