升级到Entityframework 6. Load()方法不再可用

时间:2014-09-19 12:39:47

标签: asp.net entity-framework entity-framework-6

我正在将ASP.Net webapp升级到Entityframework6。

我在部分类上有一个属性,以前使用.load()方法来延迟加载相关实体。 EF6中不再提供加载方法,我更愿意保留相关实体在类中加载状态的事实,而不会让消费代码担心加载。

public partial class Member
{
    /// <summary>
    /// Has the member got a valid membership renewal
    /// </summary>
    [ReadOnly(true)]
    public bool CurrentMember
    {
        get
        {
            this.Renewals.Load();     // this is no longer available in EF6
            var query = from renewal in this.Renewals
                        where renewal.Expired == false
                        select renewal;
            return (query.Count() > 0);
        }
    }

如何保留现有功能?

0 个答案:

没有答案