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


C# this.AsEnumerable方法代码示例

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


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

示例1: Upload

        public static void Upload(this System.Data.DataTable dt, string tableName)
        {

            string query = "SELECT * from " + tableName;


            using (SqlConnection conn = new SqlConnection(SqlConnStr))
            {
                using (SqlDataAdapter oda = new SqlDataAdapter())
                {
                    using (SqlCommandBuilder bu = new SqlCommandBuilder())
                    {
                        using (SqlBulkCopy bulkcopy = new SqlBulkCopy(conn))
                        {
                            oda.SelectCommand = new SqlCommand(query, conn);
                            bulkcopy.DestinationTableName = "dbo." + tableName;
                            DataTable dtsql = new DataTable();
                            oda.Fill(dtsql);
                            List<DataRow> lst_temp = dt.AsEnumerable().ToList();
                            foreach (DataRow row in lst_temp)
                            {
                                dtsql.ImportRow(row);
                            }
                            conn.Open();

                            bulkcopy.WriteToServer(dtsql);
                            conn.Close();
                        }
                    }
                }
            }

        }
开发者ID:Sho20,项目名称:In2S3D_v4,代码行数:33,代码来源:DbConn.cs

示例2: CalculateSum

        public static DataTable CalculateSum(this DataTable source)
        {
            var query = source.AsEnumerable();

            var table = query.CopyToDataTable();

            var newRow = table.NewRow();

            //Summe Heizperiode

            newRow[0] = "Summe Heizperiode";

            int cellsCount = table.Columns.Count - 1;
            for (int i = 1; i <= cellsCount; i++)
            {
                newRow[i] = CalcColumnSumme(table, i, true);
            }

            //Summe Jahr
            var newRow2 = table.NewRow();
            newRow2[0] = "Summe Jahr";

            for (int i = 1; i <= cellsCount; i++)
            {
                newRow2[i] = CalcColumnSumme(table, i, false);
            }
            table = GetTableWithMonts(table);

            table.Rows.Add(newRow);
            table.Rows.Add(newRow2);

            return table;
        }
开发者ID:bpug,项目名称:MetronaWT,代码行数:33,代码来源:DataTableExtensions.cs

示例3: IsEqualTo

 public static bool IsEqualTo(this DataTable source, DataTable other)
 {
     if (other == null)
     {
         return false;
     }
     return source.AsEnumerable().SequenceEqual(other.AsEnumerable(), DataRowComparer.Default);
 }
开发者ID:Animattronic,项目名称:BrainSharper,代码行数:8,代码来源:DataTableExtensions.cs

示例4: GenerateItems

        public static IEnumerable<ListItem> GenerateItems(this DataTable Table, string ValueField, string TextField)
        {
            IEnumerable<ListItem> Result = new List<ListItem>();

            var datos = Table.AsEnumerable();
            Result = datos.Select(p => new ListItem { Value = p[ValueField].ToString(), Text = p[TextField].ToString() });

            return Result;
        }
开发者ID:FranciscoMontelongo,项目名称:Basica-Prom-Supervisores-Asigna15,代码行数:9,代码来源:ExtendControls.cs

示例5: AsSelectedList

 /// <summary>
 /// Get Authors as SelectedList (for Views)
 /// </summary>
 /// <param name="Authors">List of Athors</param>
 /// <param name="currAuthor">Current Author will be selected</param>
 /// <returns></returns>
 public static List<SelectListItem> AsSelectedList(this IQueryable<Author> Authors, int currAuthor = 0)
 {
     return (from author in Authors.AsEnumerable()
             select new SelectListItem
             {
                 Value = author.Id.ToString(),
                 Text = author.FirstName + " " + author.LastName,
                 Selected = author.Id == currAuthor
             }).ToList();
 }
开发者ID:RaiseRaise,项目名称:BookShop,代码行数:16,代码来源:ModelExtension.cs

示例6: ToAMSChannels

        public static AMSChannelCollection ToAMSChannels(this IEnumerable<IChannel> channels)
        {
            channels.NullCheck("channels");

            AMSChannelCollection result = new AMSChannelCollection();

            channels.AsEnumerable().ForEach(c => result.Add(c.ToAMSChannel()));

            return result;
        }
开发者ID:zhshen,项目名称:HuaweiAMS,代码行数:10,代码来源:Converters.cs

示例7: FieldsIn

		public static HashSet<Field> FieldsIn (this LispList<PathElement> path)
		{
			var result = new HashSet<Field> ();
			if (path != null) {
				foreach (PathElement element in path.AsEnumerable ()) {
					Field f;
					if (element.TryField (out f))
						result.Add (f);
				}
			}
			return result;
		}
开发者ID:carrie901,项目名称:mono,代码行数:12,代码来源:PathExtensions.cs

示例8: AsDynamic

 /// <summary>DataTableの各RowをExpandoObjectに変換します。</summary>
 public static IEnumerable<dynamic> AsDynamic(this DataTable table)
 {
     return table.AsEnumerable().Select(x =>
     {
         IDictionary<string, object> dict = new ExpandoObject();
         foreach (DataColumn column in x.Table.Columns)
         {
             var value = x[column];
             if (value is System.DBNull) value = null;
             dict.Add(column.ColumnName, value);
         }
         return (dynamic)dict;
     });
 }
开发者ID:masaru-b-cl,项目名称:EntityClassGeneratorForOracle,代码行数:15,代码来源:Program.cs

示例9: AsObservable

        public static IObservable<KeyValuePair<string, string>> AsObservable(this IConfiguration configuration) {
            return Observable.Create<KeyValuePair<string, string>>(observer => {
                var dictionary = configuration.AsEnumerable().ToDictionary(x => x.Key, x => x.Value, StringComparer.OrdinalIgnoreCase);

                var token = ChangeToken.OnChange(() => configuration.GetReloadToken(), () => {
                    var value = (string)null;
                    foreach(var kvp in configuration.AsEnumerable()) {
                        if(dictionary.TryGetValue(kvp.Key, out value) && value.Equals(kvp.Value, StringComparison.OrdinalIgnoreCase)) {
                            continue;
                        }
                        else {
                            dictionary[kvp.Key] = kvp.Value;
                            observer.OnNext(kvp);
                        }
                    }
                });

                return () => {
                    observer.OnCompleted();
                    token.Dispose();
                };
            });
        }
开发者ID:migrap,项目名称:Migrap.Extensions.Configuration,代码行数:23,代码来源:ReactiveConfigurationExtensions.cs

示例10: ToRouteValues

        public static IDictionary<string, object> ToRouteValues(
            this IDictionary<string, MethodArgumentTestContext> dictionary,
            Func<KeyValuePair<string, MethodArgumentTestContext>, bool> filter = null)
        {
            var result = dictionary.AsEnumerable();

            if (filter != null)
            {
                result = result.Where(filter);
            }

            return result.ToDictionary(
                a => a.Key,
                a => a.Value.Value);
        }
开发者ID:ivaylokenov,项目名称:MyTested.AspNetCore.Mvc,代码行数:15,代码来源:DictionaryExtensions.cs

示例11: ToJsonValidation

		public static SimpleModelState ToJsonValidation(this ModelStateDictionary modelState)
		{
			var v = from m in modelState.AsEnumerable()
					from e in m.Value.Errors
					select new SimpleError { Key = m.Key, ErrorMessage = e.ErrorMessage };
			v = v.ToList();

			var pe = v.Where(x => !string.IsNullOrEmpty(x.Key)).ToList();
			var me = v.Where(x => string.IsNullOrEmpty(x.Key)).ToList();

			return new SimpleModelState
			{
				IsValid = modelState.IsValid,
				PropertyErrors = pe,
				ModelErrors = me
			};
		}
开发者ID:csengineer13,项目名称:Simple.MVC,代码行数:17,代码来源:ModelStateHelper.cs

示例12: Sort

        public static IQueryable<Message> Sort(this IQueryable<Message> source, MessageSort sortedBy, bool des)
        {
            if (sortedBy == MessageSort.PublishTime)
            {
                source = source.OrderBy(m => m.CreateTime);
            }
            else if (sortedBy == MessageSort.ReadTime)
            {
                source = source.OrderBy(m => m.ReadTime);
            }

            if (des)
            {
                source = source.AsEnumerable().Reverse().AsQueryable();
            }
            return source;
        }
开发者ID:feilang864,项目名称:task.zyfei.net,代码行数:17,代码来源:MessageQuery.cs

示例13: AsDynamic

        /// <summary>
        /// DataTableの各RowをExpandoObjectに変換します。
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public static dynamic AsDynamic(this DataTable table)
        {
            // return table.AsEnumerable()
            var dynamic = table.AsEnumerable()
                .Select(row =>
                {
                    IDictionary<string, object> expando = new ExpandoObject();
                    foreach (DataColumn column in row.Table.Columns)
                    {
                        var value = row[column];

                        if (value is DBNull) { value = null; }
                        expando.Add(column.ColumnName, value);
                    }
                    return (dynamic) expando;
                });

            return dynamic;
        }
开发者ID:kkkkkkaaaaaa,项目名称:kkkkkkaaaaaa,代码行数:24,代码来源:KandaDataTableExtensions.2010.cs

示例14: GroupBy

 public static DataTable GroupBy(this DataTable inputDataTable, string[] columnNames)
 {
     var groupedDataTable = new DataTable();
     var distinctColumnNames = columnNames.Distinct().ToArray();
     foreach (var columnName in distinctColumnNames)
     {
         groupedDataTable.Columns.Add(columnName, inputDataTable.Columns[columnName].DataType);
     }
     foreach (
         var grouping in
             inputDataTable.AsEnumerable()
                 .GroupBy(r => new NTuple<object>(distinctColumnNames.Select(cn => r[cn]))))
     {
         var row = groupedDataTable.NewRow();
         for (int i = 0; i < distinctColumnNames.Length; i++)
         {
             row[i] = grouping.Key.Values[i];
         }
         groupedDataTable.Rows.Add(row);
     }
     return groupedDataTable;
 }
开发者ID:dresser,项目名称:SitecoreEzImporter,代码行数:22,代码来源:DataTableExtensions.cs

示例15: GetErrors

        public static string[] GetErrors(this ModelStateDictionary modelState, string prefix)
        {
            if (!modelState.IsValid)
            {
                List<string> errors = new List<string>();

                IEnumerable<KeyValuePair<string, ModelState>> states =
                    prefix.IsNullOrEmpty() ? modelState.AsEnumerable()
                    : modelState.Where(x => x.Key.StartsWith(prefix + "."));

                foreach (var modelStateKvp in states)
                {
                    foreach (var modelError in modelStateKvp.Value.Errors)
                    {
                        errors.Add(modelError.ErrorMessage);
                    }
                }

                return errors.ToArray();
            }

            return null;
        }
开发者ID:mbsky,项目名称:myextensions,代码行数:23,代码来源:ModelStateDictionaryExtensions.cs


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