C# 选择intellisense with Linq语句中缺少的方法
我可能真的忽略了一些东西,但是当使用Linq to Entities Linq语句创建类时,intellisense中缺少Select方法 我正在使用Visual Studio 2013和EntityFrameWork 6.0.2 我有以下代码片段,intellisense中下一个最接近的方法是RemoveRange和SingleAsync中间是我应该找到Select的位置 我想从Ratings类中获取属性的子集,而不是所有属性C# 选择intellisense with Linq语句中缺少的方法,c#,linq,entity-framework,C#,Linq,Entity Framework,我可能真的忽略了一些东西,但是当使用Linq to Entities Linq语句创建类时,intellisense中缺少Select方法 我正在使用Visual Studio 2013和EntityFrameWork 6.0.2 我有以下代码片段,intellisense中下一个最接近的方法是RemoveRange和SingleAsync中间是我应该找到Select的位置 我想从Ratings类中获取属性的子集,而不是所有属性 using System; using System.Collec
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Threading.Tasks;
using AjaxCallModel;
using AjaxCallModel.ViewModels;
namespace WcfServiceLibraryAjaxCall
{
public class AjaxCall : IAjaxCall
{
public async Task<List<Rating>> SelectRatingsAsync()
{
try
{
using (BillYeagerEntities DbContext = new BillYeagerEntities())
{
DbContext.Configuration.ProxyCreationEnabled = false;
DbContext.Database.Connection.Open();
var ratings = await DbContext.Ratings.ToListAsync();
return ratings;
}
}
catch (Exception ex)
{
throw;
}
}
使用系统;
使用System.Collections.Generic;
使用System.Data.Entity;
使用System.Threading.Tasks;
使用AjaxCallModel;
使用AjaxCallModel.ViewModels;
命名空间WcfServiceLibraryAjaxCall
{
公共类AjaxCall:IAjaxCall
{
公共异步任务选择SASync()
{
尝试
{
使用(BillYeageEntities DbContext=new BillYeageEntities())
{
DbContext.Configuration.ProxyCreationEnabled=false;
DbContext.Database.Connection.Open();
var ratings=await DbContext.ratings.ToListAsync();
回报率;
}
}
捕获(例外情况除外)
{
投掷;
}
}
如果我将它与我拥有的另一个项目进行比较,就没有问题(请参阅下面的代码)
有人知道我做错了什么或错过了什么吗?
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Transactions;
using YeagerTechModel;
using YeagerTechModel.DropDownLists;
using YeagerTechModel.ViewModels;
using System.Data.Entity;
using System.Threading.Tasks;
public async Task<List<ProjectName>> GetProjectNameDropDownListAsync()
{
try
{
using (YeagerTechEntities DbContext = new YeagerTechEntities())
{
DbContext.Configuration.ProxyCreationEnabled = false;
DbContext.Database.Connection.Open();
var project = await DbContext.Projects.Select(s =>
new ProjectName()
{
ProjectID = s.ProjectID,
Name = s.Name
}).ToListAsync();
return project;
}
}
catch (Exception)
{
throw;
}
}
使用系统;
使用System.Collections.Generic;
使用系统数据;
使用System.Linq;
使用系统事务;
使用YeagerTechModel;
使用YeagerTechModel.DropDownLists;
使用YeagerTechModel.ViewModels;
使用System.Data.Entity;
使用System.Threading.Tasks;
公共异步任务GetProjectNameDropDownListAsync()
{
尝试
{
使用(YeagerTechEntities DbContext=new YeagerTechEntities())
{
DbContext.Configuration.ProxyCreationEnabled=false;
DbContext.Database.Connection.Open();
var project=await DbContext.Projects.Select(s=>
新项目名称()
{
projectd=s.projectd,
Name=s.Name
}).ToListAsync();
返回项目;
}
}
捕获(例外)
{
投掷;
}
}
将名称空间System.Linq添加到您的cs文件中
使用System.Linq;
使用System.Linq
缺失。@DaveSwersky这是一个完全不同的问题,只是有相同的症状。不是重复的。@Servy看起来你是对的…很难相信这个问题以前没有人问过…@DaveSwersky我肯定有。我个人见过一些。Marcinhuraszek,你打对了吗我不明白我怎么会忽略这一点。非常感谢!这是因为,Select()
,Sum
,Where
等都是扩展方法,它们不在集合类中声明,而是在单独的命名空间System.Linq