c # DataTable join two tables are connected

 

Turn: https: //www.cnblogs.com/xuxiaona/p/4000344.html

JlrInfodt and dtsource are two datatable, by associating [Name] and [LQRY]
               var query1 = from rJlrInfodt in JlrInfodt.AsEnumerable()
                                     from rdtsource in dtsource.AsEnumerable()
                                     where rJlrInfodt.Field<String>("姓名") == rdtsource.Field<String>("lqry")
                                     select new
                                     {
                                         Receive staff = rdtsource.Field <String> ( " LQRY " ),
                                         Submit total = rdtsource.Field <Int64> ( " Submit total " ),= rJlrInfodt.Field<Double>(""),
                                         Unit = rJlrInfodt.Field <String> ( " unit " ),
                                     };
                        DataTable DtAll = new DataTable();
                        DtAll.Columns.Add ( " receive personnel " , typeof (String));
                        DtAll.Columns.Add ( " submit total " , typeof (Int64));
                        DtAll.Columns.Add("", typeof(Double));
                        DtAll.Columns.Add("单位", typeof(String));
                        DataTable dtNew = DtAll.Copy();
                        foreach (var obj in query1)
                            dtNew.Rows.Add (. obj receiving personnel, obj submit the total, obj number, obj units...);

 

Guess you like

Origin www.cnblogs.com/SeNaiTes/p/11014410.html