zoukankan      html  css  js  c++  java
  • C#中Linq查询List与DataTable和Dictionary be

    查询DataTable返回List

     List<string> listNation = dtNation.AsEnumerable().Select(d => d.Field<string>("MZMC").Trim()).Distinct().ToList();

    查询DataTable返回string

     string strB = (from DataRow r in dtA.Rows
                                  where r.Field<string>("A") == "1034"
                                  select r.Field<string>("B")).FirstOrDefault();

    查询DataTable返回DataTable

    DataTable dtB= (from r in dtA.AsEnumerable()
                           where r.Field<string>("XY").Trim().Equals("A")
                           select r).CopyToDataTable<DataRow>();

    查询List返回Dictionary

    Dictionary<string, string> DictionaryB = ListA.FeeSubject.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => new { Key = x.FeeCode, Value = x.Code }).Distinct().ToDictionary(c => c.Key, c => c.Value);

    List集合取差集

     List<string > C = A.Except(B).ToList();

     移除

    ComboBoxPar.VmCommun.RemoveAll(x => x.CommunityName.Equals("全部")) ;
  • 相关阅读:
    001 Python网络爬虫与信息提取 课程前序
    004 JQuery (010
    Vuex的元素对象
    003 JQuery (009
    002 JQuery (004
    001 JQuery (001
    Vuex简介
    axios实例与模块封装
    axios拦截器
    015 Javascript(152
  • 原文地址:https://www.cnblogs.com/CityOfThousandFires/p/13267937.html
Copyright © 2011-2022 走看看