當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。