2009-12-13 79 views
1

我創建了一個名爲Repository的類庫,其中包含存儲SQL Server數據庫的ORM的LINQ To SQL文件,除此之外,我還創建了另一個類庫具有Repository類庫引用的服務,我想使用位於服務中的Repository中的LINQ to SQL文件,但是我看不到擴展方法,但我可以在Services中創建LinqToSQL實例。我看不到LINQ to SQL在類庫中的擴展方法

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 
     } 

    } 
} 
+0

我應該補充System.Data.Linq命名空間先走:) – Tarik 2009-12-13 00:26:34

回答

2

您是否添加了對System.Core的引用? linq的擴展方法居住在那裏。

+0

我已經找到了解決辦法,我應該提到'System.Data.Linq' – Tarik 2009-12-13 00:31:10

+1

好吧,引用是那麼討厭啊;-) – 2009-12-13 00:59:17

+0

Yeap :)我認爲Visual Studio應該有時更聰明。 – Tarik 2010-03-05 05:26:17

0

你能像普通的靜態方法那樣調用擴展方法嗎?看看你是否可以撥打:

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

可能會給你什麼是怎麼了一些信息...

而且,你可能要檢查你有一個使用子句的確切的命名空間類型聲明的擴展方法,我有過去類似的問題...