zoukankan      html  css  js  c++  java
  • 2016.1.22 利用LINQ实现DataSet内多张DataTable关联查询操作(目前未发现太大价值)

    DataSet ds = new DataSet();

                DataTable t1 = DBFactorySingleton.GetInstance().Factory.GetDataTable(sql_ndp).Copy();

                t1.TableName = "t1";

                DataTable t2 = DBFactorySingleton.GetInstance().Factory.GetDataTable(sql_naip).Copy();

                t2.TableName = "t2";

                ds.Tables.Add(t1);

                ds.Tables.Add(t2);

     

                var restable =

                    from f1 in ds.Tables[0].AsEnumerable()

                    from f2 in ds.Tables[1].AsEnumerable()

                    where f1.Field<string>("类型") + f1.Field<string>("名称") + f1.Field<string>("识别") == f2.Field<string>("类型") + f2.Field<string>("名称") + f2.Field<string>("识别")

                    //where f1.Field<string>("类型") + f1.Field<string>("名称")=="VOR_DME英德"

                    select new

                    {

                        c1 = f1.Field<string>("源"),

                        c2 = f1.Field<string>("类型"),

                        c3 = f1.Field<string>("名称"),

                        c4 = f1.Field<string>("识别"),

                        c5 = f1.Field<string>("磁差"),

                        c6 = f1.Field<string>("坐标"),

                        c7 = f1.Field<string>("频率"),

                        c8 = f1.Field<string>("波道"),

                        c9 = f1.Field<string>("天线高"),

                        c10 = f1.Field<string>("强制报告")

                    };

                gdc_pmatch.DataSource = restable.ToArray();

  • 相关阅读:
    C语言中for循环的使用
    详解C语言的main函数
    计算机语言的发展(the history of computer's language)
    hdu 1001
    hoj 1002
    hdu 1000
    POJ 1000(水题)
    hoj 1001
    code hunt题解(1)
    《C和指针》学习笔记(3)
  • 原文地址:https://www.cnblogs.com/mol1995/p/5964950.html
Copyright © 2011-2022 走看看