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


C# DataColumnCollection.Cast方法代码示例

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


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

示例1: MapColumns

        public void MapColumns(DataColumnCollection columns)
        {

            QRColumnNames obj;

            foreach(var column in columns.Cast<DataColumn>()
                                           .Select((value, index) => new { index = index, value = value })
                                           .Where(x => QRColumnNames.TryParse(x.value.ColumnName, true, out obj))
                                           .Select(x => new {cnmae=x.value.ColumnName,idx=x.index}))
                template.Add(column.idx, CreateAct(column.cnmae));

        }
开发者ID:cutthenblood,项目名称:WCFcln,代码行数:12,代码来源:QueryResultConverter.cs

示例2: getColumnName

 /// <summary>
 /// Gets the Columne name from the Collections
 /// </summary>
 /// <param name="cols"></param>
 /// <param name="phrase"></param>
 /// <returns></returns>
 static string getColumnName(DataColumnCollection cols, string phrase)
 {
     var colName = from c in cols.Cast<DataColumn>()
                   where c.ColumnName.ToLower().Contains(phrase.ToLower())
                   select c.ColumnName.ToString();
     return colName.ToList()[0].ToString();
 }
开发者ID:shanghaiese,项目名称:argicast,代码行数:13,代码来源:SW_GroundSprayGeneric.cs

示例3: MapColumns

        /// <summary>
        /// Maps columns by name.  Required by SqlBulkCopy if schema changes or columns are out of order.
        /// </summary>
        private void MapColumns(SqlBulkCopyColumnMappingCollection columnMappings, IEnumerable<string> tableColumnNames,
            DataColumnCollection importFileColumns)
        {
            var importColumnNames = importFileColumns.Cast<DataColumn>().Select(c => c.ColumnName);
            var columnsInCommon = tableColumnNames.Intersect(importColumnNames);
            foreach (var column in columnsInCommon)
            {
                columnMappings.Add(column, column);
            }

        }
开发者ID:ninerats,项目名称:DataTools,代码行数:14,代码来源:DataTableSerializer.cs

示例4: WriteToDB

        private void WriteToDB(DataRow row, DataColumnCollection columns, bool isB2BData)
        {
            try
            {
                string tableName = isB2BData ? "B2BDatas" : "B2CDatas";
                //filter 需要确认,即需要确认那些字段可以确定唯一一条记录,逻辑意义上, 这些字段在上传的时候是比需要有的字段
                string filter = string.Format("数据编码=N'{0}'", Convert.ToString(row["数据编码"]).Replace("'", "''").Trim());
                string fieldValues = string.Empty;
                StringBuilder sql = new StringBuilder();
                sql.AppendLine(string.Format("if exists(select top 1 1 from dataCenter.dbo.{0} with(nolock) where {1})", tableName, filter));
                sql.AppendLine("begin");
                sql.AppendLine(string.Format("update dataCenter.dbo.{0}", tableName));
                sql.AppendLine("set ");
                for (int i = 0; i < columns.Count; i++)
                {
                    sql.AppendLine(string.Format("{0}=N'{1}'", columns[i].ColumnName, Convert.ToString(row[columns[i]]).Replace("'", "''").Trim()));
                    if (i != columns.Count - 1)
                        sql.Append(",");
                }
                sql.AppendLine(string.Format("where {0}", filter));
                sql.AppendLine("end");
                sql.AppendLine("else");
                sql.AppendLine("begin");
                sql.AppendLine(string.Format("insert into dataCenter.dbo.{0}", tableName));
                sql.AppendLine("(" + string.Join(",", columns.Cast<DataColumn>().Select(p => p.ColumnName)) + ")");
                sql.AppendLine("values(");
                for (int i = 0; i < columns.Count; i++)
                {
                    sql.AppendLine(string.Format("N'{0}'", Convert.ToString(row[columns[i]]).Replace("'", "''").Trim()));
                    if (i != columns.Count - 1)
                        sql.Append(",");
                }
                sql.Append(")");
                sql.AppendLine("end");

                string tempSql = sql.ToString();
                DBAccesser.GetData(DBAccesser.DefaultConnection, tempSql);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
开发者ID:jelaxwang,项目名称:sxrt_datafilter,代码行数:43,代码来源:ImportController.cs

示例5: InitializeColumns

		private void InitializeColumns(DataColumnCollection dataColumnCollection, IEnumerable<string> columns)
		{
			if (columns == null)
			{
				Columns.AddRange(
					dataColumnCollection.Cast<DataColumn>().Select(dc => new ColumnInfo(dc)));
			}
			else
			{
				Columns.AddRange(
					columns.Select(columnName => new ColumnInfo(dataColumnCollection[columnName])));
			}
		}
开发者ID:jamescurran,项目名称:Castle.MonoRail.ViewComponents,代码行数:13,代码来源:SmartGridComponent.cs


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