获得非重复列表后,在查询中使用结果

编程入门 行业动态 更新时间:2024-10-09 10:20:29
本文介绍了获得非重复列表后,在查询中使用结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

最初,我获得了帮助,从一个较大的列表(该列表包含多个节点)中获得了一个独特的列表.我认为那行得通.

I originally got help with getting a distinct list from a larger list with multiple nodes to group. I think that worked.

我现在需要有关如何使用该列表的帮助.

I now need help on how to use that list.

这是我的代码:

var LOE = results.Body .getEntitiesResponse .getEntities .listOfEntities .Select(x=>new string[]{x.entityIdentification.DUNS,x.entityIdentification.DUNSPlus4}) .Distinct(); foreach (var d in LOE) { using (OleDbConnection conn = new OleDbConnection(cm.ConnectionString)) { using (OleDbCommand cmd = new OleDbCommand()) { cmd.CommandText = "sam.DeleteRecordsToBeUpdated"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@a", d.DUNS); //This is my problem area cmd.Parameters.AddWithValue("@b", d.DUNSPlus4); //This is my problem area cmd.Connection = conn; conn.Open(); cmd.ExecuteNonQuery(); } } }

有人可以帮助我如何使用第一行中创建的新对象吗?

Can someone help me with how to use the new object created in the first line?

也许我没有正确设置第一行?我似乎无法像尝试那样使用该对象.

Maybe I am not setting the first line properly? I can't seem to use the object as I am trying to.

推荐答案

您的问题出在第一条语句上

Your problem is with the first statement

var LOE = results.Body.getEntitiesResponse.getEntities.listOfEntities .Select(x=>new string[]{x.entityIdentification.DUNS,x.entityIdentification.DUNSPlus4}) .Distinct();

您应该像下面这样

var LOE = results.Body.getEntitiesResponse.getEntities.listOfEntities .Select(x => new { x.entityIdentification.DUNS, x.entityIdentification.DUNSPlus4 }).Distinct();

在您的情况下,您正在选择一个数组,而不是一个匿名类

In your case, you are selecting an array, instead of an anonymous class

更多推荐

获得非重复列表后,在查询中使用结果

本文发布于:2023-10-31 06:49:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545338.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!