5
我想使用拉吉斯拉夫Mrnka的建議here使用:拉吉斯拉夫Mrnka的使用建議包括
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Data.Entity;
namespace SimTask.Data.EF4
{
public static class Extensions
{
public static IQueryable<T> IncludeMultiple<T>(this IQueryable<T> query,
params Expression<Func<T, object>>[] includes)
where T : class
{
if (includes != null)
{
query = includes.Aggregate(query,
(current, include) => current.Include(include));
}
return query;
}
}
}
但我得到一個錯誤。編譯器無法識別current.Include
:
Error 7 'System.Linq.IQueryable<T>' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Linq.IQueryable<T>' could be found (are you missing a using directive or an assembly reference?) C:\MySolution\MyProj.Data.EF4\Extensions.cs 19 57 MyProj.Data.EF4
我從here安裝ADO.NET實體框架4.1。
它沒有幫助。我更新了我的問題。 – Naor 2011-04-23 16:30:26
@Naor:您是否將對EntityFramework的引用添加到您的項目中? – BrokenGlass 2011-04-23 16:33:03
我引用System.Data.Entity。它不代表實體框架嗎? – Naor 2011-04-23 16:33:59