我有这个代码从一个Alleged Perpetrator表中返回一个caseID。该表还有一列“LastName”。我想搜索caseID并返回LastName,但我不知道如何对其进行编码。我一直在微软网站上寻找LINQ to SQL的例子,但仍然无法弄清楚。任何帮助将不胜感激!Linq查询问题
肯
public static class AllegedPerpetratorRepository
{
public static IQueryable<AllegedPerpetrator> GetByCaseID(
this IQueryable<AllegedPerpetrator> source,
int caseID)
{
return (from s in source where s.CaseID.Equals(caseID) select s);
}
}
另外,该方法的返回类型的记录将改为'LastName'的类型,大概是'string' – 2009-12-30 17:06:43
函数类型不应该是字符串。它可以是IEnumerable,也可以应用.First()返回。 –
2009-12-30 18:39:57