gpt4 book ai didi

c# - 使用 Linq 加载数据表 - 将 C# 转换为 VB.Net

转载 作者:太空宇宙 更新时间:2023-11-03 20:46:17 25 4
gpt4 key购买 nike

我在 http://www.erictobia.com/2009/02/21/LoadADataTableWithLINQ.aspx 上找到了以下示例不幸的是,我在 VB 中需要它,它使用了一些我和自动代码转换器都无法识别的结构。那里的任何人都知道这应该如何用 VB.Net 编写? (问题点是“select new {...”)

PeopleDataSet ds = new PeopleDataSet();
using (PeopleDataContext context = new PeopleDataContext())
{
(from p in context.Persons
select new
{
Row = ds.Person.AddPersonRow(p.Id, p.FirstName, p.LastName)
}).ToList();

}

最佳答案

在我看来是为了使用 LINQ 而使用 LINQ。

只针对每个上下文。Persons

For Each p As Person In context.Persons
ds.Person.AddPersonRow(p.Id, p.FirstName, p.LastName)
Next

关于c# - 使用 Linq 加载数据表 - 将 C# 转换为 VB.Net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/756050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com