1

我创建了一个名为 Repository 的类库,其中包括存储 SQL Server 数据库 ORM 的 LINQ To SQL 文件,此外,我还创建了另一个名为 Services 的类库,它具有 Repository 类库的引用,我想使用 LINQ SQL 文件位于服务的存储库中,但我看不到扩展方法,但我可以在服务中创建 LinqToSQL 的实例。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Repository; // This is the referred class library



namespace Core {
    class BugListService {

        BBDatabaseDataContext dbContext = new BBDatabaseDataContext();

        public int CreateBug(BugList bug) {

            dbContext.BugLists. // <= The extension methods don't appear in intellisense
        }

    }
}
4

2 回答 2

2

您是否添加了对 System.Core 的引用?linq 的扩展方法就在那里。

于 2009-12-13T00:29:37.827 回答
0

你能像普通静态方法一样调用扩展方法吗?看看能不能打电话:

<Declaring Type for the Extension Method>.<Extension Method Name>(bug, <other params>)

可能会给你一些关于出了什么问题的更多信息......

此外,您可能想检查您是否有声明扩展方法的类型的确切名称空间的 Using 子句,我过去遇到过类似的问题......

于 2009-12-13T00:27:57.857 回答