C#Concat DataTable列DataTable作为枚举

发布于 2025-01-24 15:11:46 字数 1059 浏览 1 评论 0原文

我要做的是阐述两个字符串列,并将其用作一个。我已经看到了很多问题和答案,但并没有真正解决我的问题。

我有一个类似于下面的数据表,其中有200列以上的行和许多列。我要做的是拥有“ BVM2022000000810”

BILL_ID序列
1BVM20220000810
2BVH2022000000845

这是我的代码结构,而我

                    var Table_bill= Table.AsEnumerable()
                    .Where(r => r["Bill_ID  "] != DBNull.Value && r["Bill_ID  "] != null)
                    .GroupBy(r => new { Bill_id= r["Bill_ID  "] })
                    .Select(r => new
                    {
                        Bill_id= r.Key.Bill_id.ToString(),
                        Count = r.Count(),
                        Bill_No= r.Select(x => x["Serial"]).Concat(r.Select(x => x["Number"])),
                        //Bill_No= string.Format("{0}{1}",r.Select(x =>x["Serial"].ToString()),r.Select(x=>x["Number"]).ToString()),
 });

现在尝试的是感谢!

What I am trying to do is concate two string columns and use them as one. I have seen many questions and answers on that but didn't really fix my problem.

I have a data table like the below which has 200 + rows and lots of columns. What I aim to do is to have "BVM2022000000810"

Bill_IDSerialNumber
1BVM2022000000810
2BVH2022000000845

Here is my code structure and what I tried

                    var Table_bill= Table.AsEnumerable()
                    .Where(r => r["Bill_ID  "] != DBNull.Value && r["Bill_ID  "] != null)
                    .GroupBy(r => new { Bill_id= r["Bill_ID  "] })
                    .Select(r => new
                    {
                        Bill_id= r.Key.Bill_id.ToString(),
                        Count = r.Count(),
                        Bill_No= r.Select(x => x["Serial"]).Concat(r.Select(x => x["Number"])),
                        //Bill_No= string.Format("{0}{1}",r.Select(x =>x["Serial"].ToString()),r.Select(x=>x["Number"]).ToString()),
 });

Thanks by now!

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

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

发布评论

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

评论(1

思慕 2025-01-31 15:11:46

您可以尝试以下代码:

bill_no = string.join(“”,r.Select(x => x [“ serial']))) + string.join(“”,r.Select(x => x [“”编号“]))

或以下:

bill_no = string.join(“”,r.Select(x => x.serial)) + string.join(“”,r.Select(x => x.number) )

尚未检查一下,但似乎应该起作用。

can you try this code:

Bill_No= string.Join("",r.Select(x => x["Serial"])) + string.Join("", r.Select(x => x["Number"]))

or this:

Bill_No= string.Join("",r.Select(x => x.Serial)) + string.Join("", r.Select(x => x.Number))

Haven't checked this but seems like it should work.

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