SubSonic3 VB.Net 添加、更新、FirstOrDefault 问题
我已经使用 subsonic3 Vb.net 模板构建了 sctive record dal。我正在处理亚音速 dll 中的很多错误。
1)在Add()函数中:(我已经修复) 当 indx 在数据库中有计数器时,返回的新键类型是十进制,活动记录有异常“公共成员‘更改类型为’n 类型‘十进制’未找到”。 我设法修复了这个错误。我在 activeRecord 模板中更改了
子
Public Sub SetKeyValue(value As Object) Implements IActiveRecord.SetKeyValue
If value IsNot Nothing AndAlso value IsNot DBNull.Value Then
Dim settable = value.ChangeTypeTo(Of <#=tbl.PK.SysType#>)()
Me.GetType.GetProperty(Me.KeyName()).SetValue(Me, settable, Nothing)
End If
End Sub
旧新
Public Sub SetKeyValue(value As Object) Implements IActiveRecord.SetKeyValue
If value IsNot Nothing AndAlso value IsNot DBNull.Value Then
Dim settable = CType( value, <#=tbl.PK.SysType#>)
Me.GetType.GetProperty(Me.KeyName()).SetValue(Me, settable, Nothing)
End If
End Sub
更新功能()功能中的 2):(我已修复) 更新永远不会起作用。调试后发现更新的 sql 语句永远不会有查询的“SET”部分,它总是像: 更新 [表名] WHERE ... Subsonic.Repository dll 似乎有问题 --> IRepository 的 脏列未在新对象中更新,例如:
- Dim Cat as db.Category
- Cat.Indx=1
- Cat.SetIsNew(False)
- Cat.Name= 'Motors'
- Cat.Update
为什么更新时没有 DirtyColumns 我如何将列设置为肮脏的?
--更新问题已解决,这不是错误。-- 通过在第 3 行后添加 CAT.SetIsLoaded(True) 来解决。 因此,当属性 IsLoaded 设置为 tru 时,任何更新的列都将添加到 DirtyColums 中,并且这些列将更新到 DB
3) FirstOrDefault 函数:(无法修复) 总是我meaaaaaaaaan总是抛出exsiption =“第1行:‘(’附近的语法不正确。” 来自 SubSonic.Linq dll
Pleeeeeeeeeeeease 帮助
提前致谢, 教父
I hade build sctive record dal with subsonic3 Vb.net templates. and i am dealing with alot of bugs in the sub sonic dlls.
1)in Add() function: (i have fix)
when indx has counter in the db the returnd new key type is decimal the active record fil have an exception "Public member 'Change Type To' n type 'Decimal' not found".
i managed to fix this bug. i changed in the activeRecord template the sub
OlD
Public Sub SetKeyValue(value As Object) Implements IActiveRecord.SetKeyValue
If value IsNot Nothing AndAlso value IsNot DBNull.Value Then
Dim settable = value.ChangeTypeTo(Of <#=tbl.PK.SysType#>)()
Me.GetType.GetProperty(Me.KeyName()).SetValue(Me, settable, Nothing)
End If
End Sub
NEW
Public Sub SetKeyValue(value As Object) Implements IActiveRecord.SetKeyValue
If value IsNot Nothing AndAlso value IsNot DBNull.Value Then
Dim settable = CType( value, <#=tbl.PK.SysType#>)
Me.GetType.GetProperty(Me.KeyName()).SetValue(Me, settable, Nothing)
End If
End Sub
2)in Update function() function:(I Have Fixed)
the update never do the work . after debuging it apeard that the sql statment of the update never have the "SET" dection of the query its always Like:
UPDATE [tableName] WHERE ...
It seems there is a problem in the Subsonic.Repository dll -- > IRepository The
Dirty Colums not apdated in new object for example :
- Dim Cat as db.Category
- Cat.Indx=1
- Cat.SetIsNew(False)
- Cat.Name= 'Motors'
- Cat.Update
Why when update there is no DirtyColumns How can i set Column as Dirty?
--Update problem resolved its not a bug.--
Resolved by adding after line 3 : CAT.SetIsLoaded(True) .
So when the propety IsLoaded is set to tru any column updated will be added to DirtyColums and thes will be Updated To DB
3) the FirstOrDefault Function : (Couldn't fix)
always i meaaaaaaaaan always throw exsiption = "Line 1: Incorrect syntax near '('."
from the SubSonic.Linq dll
Pleeeeeeeeeeeease help
Thanks In advance,
TheGodfather
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您使用的是哪个版本的 SubSonic3?
1)不确定你想在这里做什么。
2) 这不是更新记录的方式,试试这个...
3) Subsonic 使用
SingleOrDefault()
如上面的示例所示。Firtly, which version of SubSonic3 are you using?
1) Not sure what you are trying to do here.
2) That is not how you update a record, try this...
3) Subsonic uses
SingleOrDefault()
as example above demonstrates.