简体   繁体   English

Linq 数据表不包含 AsParallel C# 的定义?

[英]Linq datatable does not contain the definition of AsParallel C#?

i am getting error "datatable does not contain the definition of AsParallel in my Linq Query. pls tell me how to fix this what i am doing wrong.我收到错误“数据表在我的 Linq 查询中不包含 AsParallel 的定义。请告诉我如何解决这个问题,我做错了什么。

var results = from myRow in dtTaskandBugs.AsParallel()
                          select myRow;
            results.ForAll(async r =>
            {
                Task<int> storyProcessing = GetStoryid(r["Id"]);
                Task<int> fidProcessing = Fidname(r["Storyid"]);
                Task<string> featureProcessing = r["FeatureID"].ToString() == "0" ? Task.FromResult("Anonymous") : fname(r["FeatureID"]);
                r["Storyid"] = await storyProcessing;
                r["FeatureID"] = await fidProcessing;
                r["FeatureName"] = await featureProcessing;
            });

From what I can see here it appears AsParallel isn't an extension on the DataTable class.从我在这里看到的看来AsParallel不是DataTable类的扩展。 You may want to go through the AsEnumerable method and then parallelize as you need.您可能希望通过AsEnumerable方法,然后根据需要进行并行化。

var results = from myRow in dt.TaskandBugs.AsEnumerable().AsParallel() select myRow;
results.ForAll(async r => ...

See if that doesn't solve your problem.看看这是否不能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM