开发者

Get Distinct Value from Observable Collection Class

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜