在 vb.net 中使用亚音速
我对 VB 非常熟悉,并且我需要做一个非常大的项目。我遇到过 SubSonic,它看起来棒极了。
我不清楚是否可以在VB中使用它。我看过一些帖子表明他们这样做了,但在网站上它专门显示了 C#。
我可以将 SubSonic 与 VB.NET 一起使用吗?
I'm quite comfortable with VB and have a very large project i need to do. I've come across SubSonic and it looks awesome.
I am not clear if i can use it in VB. I've seen a a couple of posts that suggest they did but on the site it specifically shows C#.
Can I use SubSonic with VB.NET?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SubSonic 本身完全是用 C# 编写的,但表和视图的代码生成也可用于 vb.net。
对于 SubSonic3,您需要将 VB 模板添加到您的项目
http://github.com/subsonic/SubSonic-3.0-Templates/tree/master//SubSonic.TemplatesVB/
对于 SubSonic2,您必须向 subcommander 添加
/lang vb
参数(声波.exe)不过,我个人会坚持使用 C# 代码生成,因为我想,由于用户群更大,它经过了更多的测试。
您可以将另一个 C# 类库项目添加到您的解决方案中(无论如何,您应该为您的 DAL 创建一个单独的项目)并将其链接到您的 vb.net 网站项目中。我也运行这种设置。
这种情况有 3 个缺点:
1) 您无法使用 Visual Studio Express 版本创建混合编程语言项目的解决方案。
2)如果您不想扩展生成的类(使用部分类,而不是继承),则必须在 C# 中执行此操作,因为部分类必须位于同一项目中。
3) 如果您对 c# 项目进行了某些更改,则设计时错误仅在下次编译后才会显示(例如,如果您更改了 vb 项目中使用的列名称并重新生成 DAL,则错误窗口仅在编译时显示此错误您的解决方案/c# 项目一次。
最终,我鼓励您坚持使用 c#,因为使用 subsonic(linq、lamdas,...)进行编码会更有趣。 ,你应该可以使用 VB 来实现
一些例子,这些例子在 C# 中更容易实现。
SubSonic itself is entirely written in C#, but the code generation for your tables and views is also available for vb.net.
For SubSonic3 you will need to add the VB-Templates to your project
http://github.com/subsonic/SubSonic-3.0-Templates/tree/master//SubSonic.TemplatesVB/
For SubSonic2 you have to add a
/lang vb
parameter to subcommander (sonic.exe)However, I would personally stick with the C# code generation, since it is more tested because of the bigger user base, I suppose.
You can add another c# class library project to your solution (you should create a seperate project for your DAL anyways) and link that in you vb.net website project. I run this kind of setup, too.
There are 3 drawbacks in this scenario:
1) You can't create solutions with mixed programming language projects with the visual studio express editions.
2) if you wan't to extend the generated classes (with partial classes, not inheritance) you have to do that in c# since partial classes have to be in the same project.
3) If you change something to your c# project the design time errors are only shown after the next compile (e.g. if you change a column name that is used in your vb project and regenerate your DAL the error window only shows this error if you compile your solution/the c# project once.
At the end of the day I would encourage you to stick with c# since it is way more fun to code with subsonic (linq, lamdas, ...). But if you don't want to, you should be fine with vb.
Some examples, that are simplier to achive in c#