1
我想從結果中刪除重複的記錄,但不同的不要這樣做對我來說!爲什麼???如何從結果linq刪除重複記錄到sql
var results = (from words in _Xplorium.Words
join wordFiles in _Xplorium.WordFiles on words.WordId equals wordFiles.WordId
join files in _Xplorium.Files on wordFiles.FileId equals files.FileId
join urls in _Xplorium.Urls on files.UrlId equals urls.UrlId
where files.Title.Contains(query) || files.Description.Contains(query)
orderby wordFiles.Count descending
select new SearchResultItem()
{
Title = files.Title,
Url = urls.Address,
Count = wordFiles.Count,
CrawledOn = files.CrawledOn,
Description = files.Description,
Lenght = files.Lenght,
UniqueKey = words.WordId + "-" + files.FileId + "-" + urls.UrlId
}).Distinct();
第一種選擇更好,更簡單!謝謝 – Sadegh 2010-05-25 20:32:52
如果這將是唯一的比較,或者比較與平常不同,是的。如果真的有東西讓對象每次「平等」,並且這種比較反覆發生,那麼第二個就很棒了。 – 2010-05-25 23:48:03