Как запретить добавление повторяющихся записей в DataGrid WPF C#
При самом первом добавлении я Написал ПФМК, второе добавление - Позис, третье - опять ПФМК, а мне надо чтобы при добавлении повторяющиеся поля Организация не повторялись на форме с датагридом
public AcceptancePage()
{
InitializeComponent();
var storages = StorageAppEntities.GetContext().Storages.OrderBy(prop => prop.Storage_name).ToList();
storages.Insert(0, new Storage
{
Storage_name = "Все типы"
}
);
CBoxStorage.ItemsSource = storages;
CBoxStorage.SelectedIndex = 0;
CBoxSort.Items.Insert(0, "Без сортировки");
CBoxSort.SelectedIndex = 0;
UpdateCount();
}
private void UpdateData()
{
var currentGoods = StorageAppEntities.GetContext().Goods.OrderBy(p => p.Good_name).ToList();
if (CBoxStorage.SelectedIndex > 0)
currentGoods = currentGoods.Where(p => p.Storage_ID == (CBoxStorage.SelectedItem as Storage).Storage_ID).ToList();
currentGoods = currentGoods.Where(p => p.Good_name.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();
if (CBoxSort.SelectedIndex > 0)
{
if (CBoxSort.SelectedIndex == 1)
currentGoods = currentGoods.OrderBy(p => p.Quantity).ToList();
if (CBoxSort.SelectedIndex == 2)
currentGoods = currentGoods.OrderByDescending(p => p.Quantity).ToList();
}
DataGridAcceptance.ItemsSource = currentGoods;
TextBlockCount.Text = $"Результат запроса: {currentGoods.Count} записей из {_itemcount}";
}

