Extracting items from 02 SelectListItem to show only unique Items in two selectlist

44 Views Asked by At

I have prepared two selectlistitems from the entity framework structure.

List<SelectListItem> out_file = _dbcontext.file_out
  .Where(x => x.section == _section && x.active == true)
  .Select(x => new SelectListItem { Text = x.file_id, Value = x.file_name })
  .OrderBy(x => x.Value)
  .ToList();

List<SelectListItem> fileid_list = _dbcontext.Master_table
  .Where(x => x.section == _section)
  .Select(x => new SelectListItem { Text = x.File_id, Value = x.File_name })
  .OrderBy(x => x.Value)
  .ToList();

Now I want to trim the fileid_list by removal of all the values which are already present in out_file list and display the same on the view page.

Please suggest me either the list preparation from scratch with using two tables in the entity framework environment or trimming of fileid_list from the another list.

List<SelectListItem> out_file = _dbcontext.file_out
  .Where(x => x.section == _section && x.active == true)
  .Select(x => new SelectListItem { Text = x.file_id, Value = x.file_name })
  .OrderBy(x => x.Value)
  .ToList();

List<SelectListItem> fileid_list = _dbcontext.Master_table
  .Where(x => x.section == _section)
  .Select(x => new SelectListItem { Text = x.File_id, Value = x.File_name })
  .OrderBy(x => x.Value)
  .ToList();
0

There are 0 best solutions below