everyone。 我知道,這個話題已經被討論過了。但不幸的是,我沒有發現在現有的answers.So任何解決方案,我有下面的代碼:LINQ To SQL異常:本地序列無法用於LINQ to SQL實現
public List<List<string>> DataTableParser(IQueryable<T> queriable)
{
//I missed the unnecessary code
return queriable.Select(SelectProperties).ToList();
//I missed the unnecessary code
}
private Expression<Func<T, List<string>>> SelectProperties
{
get
{
var properties = typeof(T).GetProperties();
//
return value => properties.Select
(
// empty string is the default property value
prop => (prop.GetValue(value, null) ?? string.Empty).ToString()
)
.ToList();
}
}
所以,在方法DataTableParser我有下一個消息的異常:
「本地序列除了Contains()運算符「之外,不能用於查詢運算符的LINQ to SQL實現。 我不在我的查詢「where」部分中使用。所以我無法想象如何使用「包含」運算符。我無法理解這個例外的原因。 有沒有人有任何想法?我會感謝任何幫助。謝謝。
什麼是「屬性」變量? – 2010-10-21 08:42:41
對不起,喬恩,我忘了它。我將它添加到代碼中。 var properties = typeof(T).GetProperties(); – Deniplane 2010-10-21 10:05:41