C#Concat DataTable列DataTable作为枚举
我要做的是阐述两个字符串列,并将其用作一个。我已经看到了很多问题和答案,但并没有真正解决我的问题。
我有一个类似于下面的数据表,其中有200列以上的行和许多列。我要做的是拥有“ BVM2022000000810”
BILL_ID | 序列 | 号 |
---|---|---|
1 | BVM | 20220000810 |
2 | BVH | 2022000000845 |
这是我的代码结构,而我
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_ID | Serial | Number |
---|---|---|
1 | BVM | 2022000000810 |
2 | BVH | 2022000000845 |
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试以下代码:
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.