我有以下class
和linq
我用来填充的查询grid
!
返回的Title
每一行都是相同的。我想要做的是mString
用distinct
Title
查询填充,这样我就可以将它绑定到一个单独的文本块。
我可能不需要显示所有代码,但也许它会有所帮助。我怎样才能显示distinct Title
.
public class Items
{
public int Id { get; set; }
public string Details { get; set; }
public string Title { get; set; }
public int NewNumber { get; set; }
}
private ObservableCollection<Items> mItem = new ObservableCollection<Items>();
private string mString = string.Empty;
public string SpecTitle
{
get { return mString; }
}
public ObservableCollection<Items> GetItems
{
get { return mItem; }
}
这是 linq 查询
var results = (from z in mContext.View
orderby z.ItemNumber ascending
where z.ItemId == mId
select new Items()
{
Id = z.ItemId,
Details = z.Details,
Title = z.ItemTitle,
NewNumber = z.ItemNumber
});
List<Items> mNewItems = results.ToList();
mItem.Clear();
mNewItems.ForEach(y => mItem.Add(y));