【发布时间】:2015-09-04 16:10:37
【问题描述】:
我正在开发一个 asp.net mvc4 web 应用程序 + 实体框架 5。我试图引用 ToListAsync() 如下:-
var tservers = await t.TServers.Include(a => a.Technology.TechnologyIPs).Include(a => a.TVirtualMachines.Select(a2 => a2.Technology))
.Where(
a2 => (!singlescan && String.IsNullOrEmpty(FQDN) && a2.TechnologyRole.Name.ToLower() == "hypervisor")
||
(singlescan && !String.IsNullOrEmpty(FQDN) && a2.Technology.IT360ID == it360id)
).ToListAsync();
但我不断收到以下错误:-
Error 10 'System.Linq.IQueryable<**.Models.**>' does not contain a definition for 'ToListAsync' and no extension method 'ToListAsync' accepting a first argument of type 'System.Linq.IQueryable<**.Models.***>' could be found (are you missing a using directive or an assembly reference?) C****\Repository.cs 181 22 Scanning
我将这些参考资料包含在我的班级中:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Data;
using System.Data.Objects.SqlClient;
using System.Data.Entity.Infrastructure;
using T.ViewModels;
using System.DirectoryServices.AccountManagement;
using System.Security.Principal;
using System.DirectoryServices;
using System.Linq.Expressions;
using System.Data.Objects;
using System.Linq.Dynamic;
using System.Configuration;
using System.Threading.Tasks;
究竟是什么问题? ToListAsync() 在 EF 5 中可用吗?
【问题讨论】:
标签: asp.net-mvc entity-framework asp.net-mvc-4 entity-framework-5