简体   繁体   English

如何从字典中排除字符串值列表

[英]How to Exclude list of string values from a dictionary

 Dictionary<string, int?> tVers = null;

Below my list of string fetches data from one table entity 在我的字符串列表下面,从一个表实体中获取数据

List<string> category = context.Cat
  .Where(c.Description != "abc")
  .Select(a => a.Name)
  .ToList(); 

Here i need to exclude the list of string values fetched in above list in my Tvers dictionary which fetches data from some other table entity,iethe TName of dictionary must exclude values from cat and return the dictiionary 在这里,我需要排除在我的Tvers字典中从上面的列表中获取的字符串值的列表,该字符串从其他表实体中获取数据,即字典的TName必须从cat中排除值并返回字典

tVers = context.MCurrentVer
  .Where(x => x.MKey == 1000)
  .ToDictionary(k => k.TName, 
                v => v.CVer);

Please help 请帮忙

Use !category.Contains(x.TName) to filter out x.TName that are in the catrgory list. 使用!category.Contains(x.TName)过滤掉x.TName是在catrgory列表。

tVers = context.MCurrentVer
   .Where(x => x.MKey == 1000 && !category.Contains(x.TName))
   .ToDictionary(k => k.TName, v => v.CVer);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM