我已經使用Linq-to-SQL創建了一個Area類。嘗試創建部分類時出錯
現在我想創建一個同名的部分類,以便我可以實現驗證。任何幫助?
錯誤1無法隱式轉換類型 '
System.Data.Linq.Table<SeguimientoDocente.Area>
' 到 'System.Linq.IQueryable<SeguimientoDocente.Models.Area>
' C:\用戶\塞爾吉奧\文檔\ Visual 工作室 2010 \項目\ SeguimientoDocente \ SeguimientoDocente \型號\ AreaRepository.cs 14 20 SeguimientoDocente
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SeguimientoDocente.Models
{
public class AreaRepository
{
private SeguimientoDataContext db = new SeguimientoDataContext();
public IQueryable<Area> FindAllAreas()
{
return db.Areas;
}
public Area GetArea(int id)
{
return db.Areas.SingleOrDefault(a => a.ID == id);
}
public void Add(Area area)
{
db.Areas.InsertOnSubmit(area);
}
public void Delete(Area area)
{
db.Areas.DeleteOnSubmit(area);
}
public void Save()
{
db.SubmitChanges();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SeguimientoDocente.Models
{
public partial class Area
{
}
}
下面是截圖。
我正在學習本教程。有什麼建議麼? – 2010-07-28 01:26:57
請注意,只有在添加部分Area類時纔會出現此錯誤。當沒有區域部分時,代碼編譯和單詞正確。 – 2010-07-28 01:32:18
其實OP的問題沒有正確標記。通常表確實實現IQueryable的但在這種情況下,他無意中定義具有相同的簡單名稱爲T1 A T2。 –
Josh
2010-07-28 02:33:17