1

我正在使用VS2010。.NET 4.0 与实体框架。我最近使用旧版 EF 从 VS2008 和 .NET 3.5 升级了这段代码。此代码适用于旧代码库。

我有一个存储过程,它返回一组有效位置,并与我的商家数据绑定,然后获取该结果集并将其作为列表发送回。当我到达那里时,我收到以下错误:

此方法支持 LINQ to Entities 基础结构,并且不打算直接从您的代码中使用。

每当我在 Watch 中引用结果变量时,我都会收到此错误。

有任何想法吗?

这是一些代码。

    public List<Merchant> GetNearest(float miles, float latitude, float longitude)
    {
        var locations = getNearestLocations(miles, latitude, longitude);
        var result = (from ai in locations
                      join b in _entities.Merchant on
                        ai.Merchant.MerchantId equals b.MerchantId
                      select b);

        return result.ToList();
    }

    private IQueryable<Location> getNearestLocations(float miles, float latitude, float longitude)
    {
        var result = (from ai in _entities.AddressInfoWithinRange(miles, latitude, longitude) // this is the call to the Stored Proc
                      join a in _entities.Location on
                        ai.LocationId equals a.LocationId
                      select a).AsQueryable();

        return (IQueryable<Location>)result;
    }
4

0 回答 0