动态 Linq Select 串联

发布于 2024-09-27 23:04:48 字数 415 浏览 2 评论 0原文

我有一个动态选择语句:

“new(PurchaseOrderID as ID_PK, PContractNo + GoodsSupplier.AssociatedTo.DisplayName as Search_Results)”

可以看出,我希望将 'PContractNo' 和 'GoodsSupplier.AssociatedTo.DisplayName' 字段连接到一个返回的字段中名为“Search_Results”的字段。将这两个领域结合起来非常重要。

然而,Linq 库抱怨“+”,表达式解析器将其作为“Concat(等...)”返回,这当然不能转换为存储表达式。

显然,因此我需要一些关于如何格式化选择字符串以便执行我想要的操作的帮助。我已经尝试了很多事情!

任何帮助将不胜感激!

谢谢你,伊恩·麦克

I have a dynamic select statement thus:

"new(PurchaseOrderID as ID_PK, PContractNo + GoodsSupplier.AssociatedTo.DisplayName as Search_Results)"

As can be seen I wish to concatenate the 'PContractNo' and 'GoodsSupplier.AssociatedTo.DisplayName' fields into one returned field named 'Search_Results'. It is important that these two fields are combined.

However the Linq library complains regarding the '+', which the expression parser brings back as a 'Concat(etc...), which of course cannot be translated into a store expression.

Obviously therefore I would like some help regarding just how i should format the select string in order to do what I want. I've tried many things!

Any help would be greatly appreciated!

Thank You, Ian Mac

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

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

发布评论

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

评论(1

是你 2024-10-04 23:04:48

创建一个类似的新类

public class A
{
    public String k;
    public String v;

}

并使用 linq 加入

res = from a in list
select new A
{
  k = a.Key,
  v = String.Concat(a.Key,a.Value)
};

Create a new Class like

public class A
{
    public String k;
    public String v;

}

and use linq to join

res = from a in list
select new A
{
  k = a.Key,
  v = String.Concat(a.Key,a.Value)
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文