Reputation: 4692
I might be really overlooking something, but when creating a class using the Linq to Entities linq statements, the Select method is missing from the intellisense!
I'm using Visual Studio 2013 with EntityFrameWork 6.0.2.
I have the following code snippet and the next closest methods in the intellisense is RemoveRange and SingleAsync. In between is where I should find the Select!
I'd like to get a subset of the properties from the Ratings class and not all of them.
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;
}
}
If I compare it to another project I have, there's not an issue (see the code below).
Does anybody know what I'm doing wrong or missing?
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;
}
}
Upvotes: 3
Views: 2648