I am using Linq-To-SQL.
I have made one class by inheriting ObservableCollection
This class has one constructor with Datacontext as parameter.
I have calling this construtor from my program and assigning it to the control's ItemSource property.
But I can't get distinct value in it..
public class BindBookIssueDetails : ObservableCollection { public BindBookIssueDetails(DataClasses1DataContext dataDC) { foreach (Resource_Allocation_View res in dataDC.开发者_如何学GoResource_Allocation_Views) { this.Add(res); } } }
private BindBookIssueDetails bResource; bResource = new BindBookIssueDetails(db); _cmbResource.ItemSource=bResource;
So what's the solution?
Plz Help...
I would first suggest taking your query logic out of the constructor of the collection. That's a very unusual place for something like that.
But otherwise, the LINQ function you're looking for is called Distinct.
精彩评论