我嘗試了幾乎所有的解決方案,但沒用。我無法獲得獨特的列表的特定列Priority.Any幫助非常感謝。與回報lstAlertNames發生不能隱式轉換類型'system.collections.generic.list <string>'到'system.collections.generic.list <entities.tablename>
public List<AlertType> GetAllAlertNames()
{
var lstAlertNames = _zyenaDbContext.AlertTypes.Select(x => x.Priority).Distinct().ToList();
return lstAlertNames;
}
以下錯誤:
cannot implicitly convert type 'system.collections.generic.list string '
to 'system.collections.generic.list zyenaEntities.AlertType
在型號的AlertType
public string Priority { get; set; }
是的,就在這裏找到:http://stackoverflow.com/questions/4607485/linq-distinct-use-delegate-for-equality-comparer – firda 2014-08-30 09:09:29
是@stepehen Muecke優先回報字符串。 DistinctBy在我的應用程序的實體框架中不受Intellisense支持。 – 2014-08-30 09:20:11
但是如果我沒有錯的話,morelinq不會在實體上工作。它致力於LINQ到對象... – 2014-08-30 09:20:31