我有下面的代码片段,它在“i.tPersons.Any”处生成错误:
“WhatWorks.Models.tPerson”不包含“Any”的定义,并且找不到接受“WhatWorks.Models.tPerson”类型的第一个参数的扩展方法“Any”(您是否缺少 using 指令或程序集引用?)
'Any' 是 System.Data.Entity 的一种方法,所以我希望它会被采纳。我错过了什么?
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WhatWorks.Models;
namespace WhatWorks.Controllers
{
public class InterventionController : Controller
{
private WhatWorksEntities db = new WhatWorksEntities();
//
// GET: /Intervention/
// where parameter list only includes id
public ActionResult Index(int id)
{
var model =
(
from i in db.tInterventions
where (i.householdID == id && !(i.tPersons.Any(t => i.householdID == id)))
select i
);