2
在我的DataContext有鑑於此:沒有支持轉換爲SQL
public class EventsForUserID
{
public string eventName { get; set; }
public int eventID { get; set; }
public string eventIdentifier { get; set; }
public DateTime eventOpenDate { get; set; }
public DateTime eventCloseDate { get; set; }
public bool eventDisabled { get; set; }
public EventsForUserID() {}
public EventsForUserID(string pEventName, int pEventID, string pEventIdentifier, DateTime pEventOpenDate, DateTime pEventCloseDate, bool pEventDisabled)
{
this.eventName = pEventName;
this.eventID = pEventID;
this.eventIdentifier = pEventIdentifier;
this.eventOpenDate = pEventOpenDate;
this.eventCloseDate = pEventCloseDate;
this.eventDisabled = pEventDisabled;
}
}
public List<EventsForUserID> GetEventsForUserID(string userID, bool excludeDisabled)
{
var e =
from ex in this.Exhibitors
join ev in this.Events on ex.EventID equals ev.EventID
where ex.UserID.ToString() == userID
select new EventsForUserID (
ev.EventName,
ev.EventID,
ev.EventID + "[::]" + ex.ExhibitorID + "[::]" + ex.AccountDisabled + "[::]" + ev.EventDisabled,
ev.OpenDate.Value,
ev.CloseDate.Value,
ev.EventDisabled
);
if (excludeDisabled) {
e = from ev in e
where ev.eventDisabled != true
select ev;
}
return e.ToList();
}
我得到的錯誤: 成員 'LeadsDataContext + EventsForUserID.eventDisabled' 沒有支持轉換爲SQL。
上的return.ToList()行。
我已經試過各種.... AsQueryable已()等
我想,這是因爲EventsForUserID是不是真正的SQL表,可是轉念一想LINQ是爲在許多類型的對象進行查詢。
我是否缺少某種表演。
非常感謝,N
謝謝你的指針。這已經解決了它:如果(excludeDisabled){e.ToList())中的ev從var ev_ventDisabled!= true select ev; e = etemp.AsQueryable(); } – ninety 2011-06-14 15:33:49