在完成 ASP MVC 3 音乐商店教程时,我正在尝试将 C# 页面翻译成 VB。http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-4
该页面是一堆将被拉入数据库的示例数据。
我要翻译的 C# 如下所示:
new List<Album>
{
new Album { Title = "A Copland Celebration, Vol. I", Genre = genres.Single(g => g.Name == "Classical"), Price = 8.99M, Artist = artists.Single(a => a.Name == "Aaron Copland & London Symphony Orchestra"), AlbumArtUrl = "/Content/Images/placeholder.gif" },
//lots of albums here... just like examples above and below
new Album { Title = "Ao Vivo [IMPORT]", Genre = genres.Single(g => g.Name == "Latin"), Price = 8.99M, Artist = artists.Single(a => a.Name == "Zeca Pagodinho"), AlbumArtUrl = "/Content/Images/placeholder.gif" },
}.ForEach(a => context.Albums.Add(a));
我转换后的 VB 代码看起来像这样,但编译器说第一行有语法错误...
New List(Of Album)() With { _ //Compiler says there is a syntax error here
New Album() With { _
.Title = "A Copland Celebration, Vol. I", _
.Genre = genres.[Single](Function(g) g.Name = "Classical"), _
.Price = 8.99D, _
.Artist = artists.[Single](Function(a) a.Name = "Aaron Copland & London Symphony Orchestra"), _
.AlbumArtUrl = "/Content/Images/placeholder.gif" _
}, _
//lots of albums here
New Album() With { _
.Title = "Ao Vivo [IMPORT]", _
.Genre = genres.[Single](Function(g) g.Name = "Latin"), _
.Price = 8.99D, _
.Artist = artists.[Single](Function(a) a.Name = "Zeca Pagodinho"), _
.AlbumArtUrl = "/Content/Images/placeholder.gif" _
} _
}.ForEach(Function(a) context.Albums.Add(a))
如何修复语法错误?