通过 Azure 服务总线发送对象列表

发布于 2024-12-13 23:10:49 字数 599 浏览 4 评论 0原文

我正在尝试通过 Azure 服务总线发送对象列表,并想检查这是否是正确的方法。最初我尝试发送:

IEnumerable<Product>

侦听器端点在集合中有产品对象,但是当它到达调用端点时,计数为 0。列表也是如此(我期望的),

我已经通过使用

        List<BrokeredMessage> messages = new List<BrokeredMessage>();

        foreach (BcsProduct product in products)
        {
            BcsProduct p = new BcsProduct { ProductId = product.ProductId, Name = product.Name };
            messages.Add(new BrokeredMessage(p));
        }

我想要的 BrokeredMessage 列表使其工作检查这是正确的方法,或者 IEnumerable 是否应该工作

谢谢尼克

......

I'm trying to send a list of objects over the Azure service bus, and want to check this is the correct way to do it. Intially I tried sending:

IEnumerable<Product>

The Listener endpoint had product objects in the collection, but when it got to the calling endpoint the count was 0. Same for List (which I expected)

I've got it working by using List of BrokeredMessage

        List<BrokeredMessage> messages = new List<BrokeredMessage>();

        foreach (BcsProduct product in products)
        {
            BcsProduct p = new BcsProduct { ProductId = product.ProductId, Name = product.Name };
            messages.Add(new BrokeredMessage(p));
        }

I wanted to check this was the correct approach, or if IEnumerable should work...

Thanks

Nick

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

因为看清所以看轻 2024-12-20 23:10:49

看到你已经找到答案了,但你可以简化你的代码:

    List<BrokeredMessage> messages = new List<BrokeredMessage>();

    foreach (BcsProduct product in products)
    {
        messages.Add(new BrokeredMessage(product));
    }

See you have already found the answer, but you could simplifly your code:

    List<BrokeredMessage> messages = new List<BrokeredMessage>();

    foreach (BcsProduct product in products)
    {
        messages.Add(new BrokeredMessage(product));
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文