动态代理和延迟加载之间是否存在任何关系

时间:2015-03-20 16:25:15

标签: asp.net-mvc entity-framework asp.net-mvc-5 entity-framework-5

我很担心动态代理在EF中意味着什么?并且动态代理与懒惰或急切加载之间是否存在关系。

例如,我有以下视图模型: -

public class ServerJoin
{
        public Server Server { get; set; }
        public Resource Resource { get; set; }
        public Technology Technology { get; set; }
        //public ComponentDefinition ComponentDefinition { get; set; }
        //public SystemInfo SystemInfo { get; set; }
        public SDOrganization Site { get; set; }
        public SDOrganization Customer { get; set; }
        public NetworkInfo NetworkInfo { get; set; }
        public ICollection<NetworkInfo> NetworkInfo2 { get; set; }
       [Display(Name="MAC Unique")]
        public bool IsMACUnique { get; set; }
        [Display(Name = "IP Unique")]
        public bool IsIPUnique { get; set; }
        public Nullable<double> SPEED { get; set; }
        public Nullable<Int64> PROCESSORCOUNT { get; set; }
        //public ResourceState AssetState { get; set; }
        public TechnologyIP TechnologyIP2 { get; set; }// this is use for inserting the Network info for the VM.
        [Display(Name = "IP Unique")]
        public bool IsTMSIPUnique { get; set; }
        [Display(Name = "MAC Unique")]
        public bool IsTMSMACUnique { get; set; }
}

目前在Visual Studio中,我在创建视图模型的新实例时发现了以下内容:其中一些值的类型为“count = 12,而其他值的类型为”动态代理“等等:

enter image description here

那么什么是动态代理,以及为什么某些值将其类型作为动态代理?

1 个答案:

答案 0 :(得分:0)

是的,实体框架在能够创建动态代理时(通常是虚拟属性)。这些代理包装了类的实际实现,并允许延迟加载。

不同的IoC容器也使用相同的技术来提供拦截器等AOP风格。

相关问题