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();

  • 相关阅读:
    java编码过滤器
    DAO设计模式
    常用的SQL语句
    IO流总结
    IO流的登录与注册
    设计模式之模板方法模式(Template Method)详解及代码示例
    设计模式之享元模式(Flyweight)详解及代码示例
    设计模式之桥接模式(Bridge)详解及代码示例
    设计模式之组合模式(Composite)详解及代码示例
    设计模式之外观模式(Facade)详解及代码示例
  • 原文地址:https://www.cnblogs.com/mol1995/p/5964950.html
Copyright © 2011-2022 走看看