任何人都可以帮助在ASP.NET核心中找到.asenumerable()的替代选项 [英] Can any one help here to find alternative option for .asenumerable() in ASP.NET core

查看:403
本文介绍了任何人都可以帮助在ASP.NET核心中找到.asenumerable()的替代选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助在asp.net核心找到.AsEnumerable()的替代选项



我尝试了什么:



< pre> var StockList =(来自dr在ds.Tables [0] .AsEnumerable()
选择新
{
BrandID = dr.Field< int>(BrandID),
BrandName = dr.Field< string>(BrandName)
}
).ToList();

解决方案

< blockquote>一个简单的替代方案是for循环。例如,考虑以下

 System.Collections.Generic.List< object> StockList =  new  System.Collections.Generic.List< object>(); 
for int counter = 0 ; counter < ds.Tables [ 0 ]。Rows.Count; counter ++){
StockList.Add( new {
BrandID = ds.Tables [ 0 ]。行[counter] [ BrandID],
BrandName = ds.Tables [ 0 ]。行[counter] [ BrandName ]
});
}


Can any one help here to find alternative option for .AsEnumerable() in asp.net core

What I have tried:

<pre> var StockList = (from dr in ds.Tables[0].AsEnumerable()
                                 select new
                                 {
                                     BrandID = dr.Field<int>("BrandID"),
                                     BrandName = dr.Field<string>("BrandName")
                                 }
                                 ).ToList();

解决方案

A simple alternative would be a for loop. For example consider the following

System.Collections.Generic.List<object> StockList = new System.Collections.Generic.List<object>();
for (int counter = 0; counter < ds.Tables[0].Rows.Count; counter++) {
   StockList.Add(new {
      BrandID = ds.Tables[0].Rows[counter]["BrandID"],
      BrandName = ds.Tables[0].Rows[counter]["BrandName"]
   });
}


这篇关于任何人都可以帮助在ASP.NET核心中找到.asenumerable()的替代选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆