获得非重复列表后,在查询中使用结果 [英] After getting distinct list, using the results in a query

查看:43
本文介绍了获得非重复列表后,在查询中使用结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这篇关于获得非重复列表后,在查询中使用结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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