在亚音速3铸造问题 [英] Casting problem in SubSonic 3
问题描述
在保存行具有integere主键下面的异常被抛出在VB版本: 公共成员'ChangeTypeTo上键入小数没有找到。
When saving a row that has a integere primary key following exception is thrown in the VB version: 'Public member 'ChangeTypeTo' on type 'Decimal' not found.'
这发生在ActiveRecord.VB文件中的行3406:
This happens in ActiveRecord.VB file line 3406:
Public Sub SetKeyValue(value As Object) Implements IActiveRecord.SetKeyValue
If value IsNot Nothing AndAlso value IsNot DBNull.Value Then
Dim settable = value.ChangeTypeTo(Of Integer)()
我可以改变的最后一行:
I can change the last line to:
Dim settable = CInt(value) 'value.ChangeTypeTo(Of Integer)()
这将解决这个问题,直到我重新编译.TT文件。
This will fix the problem until I recompile the .tt files.
我的问题是,我该怎么改变这个在ActiveRecord.tt文件? 在code在TT文件看起来是这样的:
My question is, how can I change this in the ActiveRecord.tt file? The code in the tt file looks like this:
Dim settable = value.ChangeTypeTo(Of <#=tbl.PK.SysType#>)()
任何帮助是AP preciated。
Any help is appreciated.
感谢
推荐答案
我也有与VB模板的各种问题。这似乎的亚音速发展的重点是在C#。最后,我选择使用C#的模板在另一个项目,并从我的VB应用程序主引用它。与您正在试图做的改变的问题是,你想更换一个通用的方法,具体的,这并不是越大越好。 &LT;#= tbl.PK.SysType#&GT;
提到了主键的类型。如果你只有整数主键,您可以编辑该模板的暗淡可设置= CINT(值)
。否则,你需要的GetType的知道值
的类型,然后一个选择的情况下
每种类型的apropiate转换的到达的方法。
I also had have various issues with the VB templates. That seems the focus of the Subsonic developers is in C#. Finally I choose to use the C# templates in another project, and reference it from my VB main application. The problem with the change that you're trying to do is that you're trying to replace a generic method for a concrete one, this isn't the better. <#=tbl.PK.SysType#>
makes reference to the type of the primary key. If you only have integer primary keys, you can edit the template as Dim settable = CInt(value)
. Otherwise you need GetType for know the type of value
, and then a select case
with the apropiate conversion for each type that arrives to the method.
这篇关于在亚音速3铸造问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!