当前位置: 首页>>代码示例>>C#>>正文


C# DataColumn.Select方法代码示例

本文整理汇总了C#中System.Data.DataColumn.Select方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.Select方法的具体用法?C# DataColumn.Select怎么用?C# DataColumn.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataColumn的用法示例。


在下文中一共展示了DataColumn.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveDuplicates

        public static DataTable RemoveDuplicates(DataTable dt, DataColumn[] keyColumns, string SavePath, string currentMapping)
        {
            int rowNdx = 0;
            var res = new List<DataTable>();
            DataTable duplicatesTable = dt.Clone();

            var qFields = string.Join(", ", keyColumns.Select(x => "it[\"" + x.ColumnName + "\"] as " + x.ColumnName.Replace(" ","") + ""));

            var q = dt.AsEnumerable()
                                .AsQueryable()
                                .GroupBy("new(" + qFields + ")", "it")
                                .Select("new (it as Data)");

            var dtemp = dt.Clone();

            foreach (dynamic d in q)
            {
               // dtemp.Rows.Add(d.Data.First().ItemArray());
                rowNdx = 0;
                foreach (var row in d.Data)
                {
                    if (rowNdx == 0)
                    {
                        dtemp.Rows.Add(row.ItemArray);
                    }
                    else
                    {
                        duplicatesTable.Rows.Add(row.ItemArray);
                    }
                    rowNdx++;
                }
            }

            string newFileName = string.Format("{0}{1}", "test", rowNdx);
            FileSaveHelper.ExportDataTable(duplicatesTable, string.Format("{0}\\{1}", SavePath, currentMapping + "_Duplicates.xlsx"));
            return dtemp;
            //while (rowNdx < tbl.Rows.Count - 1)
            //{
            //    DataRow[] dups = FindDups(tbl, rowNdx, keyColumns);

            //    if (dups.Length > 0)
            //    {
            //        foreach (DataRow dup in dups)
            //        {
            //            duplicatesTable.ImportRow(dup);
            //            tbl.Rows.Remove(dup);
            //        }
            //        tbl.Rows.Add(dups.FirstOrDefault());
            //    }
            //    else
            //    {
            //        rowNdx++;
            //    }
            //}
               // return duplicatesTable;
        }
开发者ID:kavamara,项目名称:CAMS_ETL,代码行数:56,代码来源:DataSetHelper.cs

示例2: UpdateFeaturesAction

        private DataTable UpdateFeaturesAction(DataColumn[] updateColumns, 
            object[] updateValues, DataTable historyTable)
        {
            if (!TableExists(_selName))
                throw new Exception("Error selecting update features from MapInfo layer.");

            //---------------------------------------------------------------------
            // QUERY: KI106 (Shape area and length values)
            // Should this include updates for the geom1 and geom2 columns automatically?
            //---------------------------------------------------------------------

            // update selection
            _mapInfoApp.Do(String.Format("Update {0} Set {1}", _selName,
                String.Join(",", updateColumns.Select((c, index) => String.Format("{0} = {1}",
                   GetFieldName(_hluLayerStructure.Columns[c.ColumnName].Ordinal),
                   QuoteValue(updateValues[index]))).ToArray())));

            if (!CommitChanges())
                return null;
            else
                return historyTable;
        }
开发者ID:HabitatFramework,项目名称:HLUTool,代码行数:22,代码来源:MapInfoApp.cs

示例3: UpdateFeaturesAction

        private DataTable UpdateFeaturesAction(DataColumn[] updateColumns, 
            object[] updateValues, DataTable historyTable)
        {
            if (String.IsNullOrEmpty(_selName) || !TableExists(_selName))
                throw new Exception("Error selecting update features from MapInfo layer.");

            if (String.IsNullOrEmpty(_selName)) return null;

            // update selection
            _mapInfoApp.Do(String.Format("Update {0} Set {1}", _selName,
                String.Join(",", updateColumns.Select((c, index) => String.Format("{0} = {1}",
                   GetFieldName(_hluLayerStructure.Columns[c.ColumnName].Ordinal),
                   QuoteValue(updateValues[index]))).ToArray())));

            if (!CommitChanges())
                return null;
            else
                return historyTable;
        }
开发者ID:Wolfgang-HBIC,项目名称:HLUTool,代码行数:19,代码来源:MapInfoApp.cs

示例4: FromList

        public string FromList(bool includeFrom, DataColumn[] targetColumns, 
            bool quoteIdentifiers, ref List<SqlFilterCondition> whereClause, out bool additionalTables)
        {
            DataTable[] colTables = targetColumns.Select(c => c.Table).Distinct().ToArray();
            var whereTables = whereClause.Select(con => con.Table).Distinct().Where(t => !colTables.Contains(t));

            int numTables = colTables.Length;
            colTables = colTables.Concat(whereTables).ToArray();
            additionalTables = colTables.Length > numTables;

            whereClause = JoinClause(colTables).Concat(whereClause).ToList();

            return FromList(includeFrom, quoteIdentifiers, colTables.Select(t => t.TableName).ToArray());
        }
开发者ID:Wolfgang-HBIC,项目名称:HLUTool,代码行数:14,代码来源:SqlBuilder.cs


注:本文中的System.Data.DataColumn.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。