首页 新闻 会员 周边

EF进行json序列化为什么会触发延迟加载

0
悬赏园豆:40 [已解决问题] 解决于 2014-03-20 16:29

EF获取的实体通过JavaScriptSerializer进行json序列化时,为什么会触发延迟加载,具体的实体如下:

public class RoleInfos
    {
        public int ID { getset; }
        [Required]
        public string RoleName { getset; }
        [Required]
        public string RoleCode { getset; }
        public bool Status { getset; }
        [StringLength(100)]
        public string CompanyCode { getset; }
        public bool IsBuiltIn { getset; }
        [NotMapped]
        public string TempActions { getset; }
 
        [NotMapped]
        public string TempCodes { getset; }
 
        [ScriptIgnore]
        public virtual IList<ActionInfos> ActionInfos { getset; }
        [ScriptIgnore]
        public virtual IList<UserInfos> UserInfos { getset; }
        [ScriptIgnore]
        public virtual IList<Right> Rights { getset; }
 
        [NotMapped]
        public string TempRights { getset; }
    }

求高手赐教!!!
忆起的主页 忆起 | 初学一级 | 园豆:171
提问于:2013-10-14 15:59
< >
分享
最佳答案
0

从orm思想来考虑,一个对象由非持久化转为持久化状态,数据库会select一个语句,虽然没有用过ef,我想ef框架也是这样做的。

收获园豆:10
李永京 | 老鸟四级 |园豆:3114 | 2013-10-14 16:13

如何不让标记[virtual]的属性被序列化呢,谢谢。

忆起 | 园豆:171 (初学一级) | 2013-10-14 17:15
其他回答(1)
0

[ScriptIgnore]换成 [JsonIgnore]

收获园豆:10
米笑仙 | 园豆:76 (初学一级) | 2013-11-10 15:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册