SubSonic3 VB.Net添加,更新,FirstOrDefault问题 [英] SubSonic3 VB.Net Add,Update, FirstOrDefault Problems
问题描述
我哈德建立sctive记录DAL与subsonic3 Vb.net模板。而我用了很多的bug买卖本次音速的DLL。
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)Add()函数:(我有固定) 当INDX有计数器DB中的returnd新的密钥类型是十进制的活动记录FIL有一个例外,公共成员的变更类型为N型十进制未找到。 我设法解决这个问题。我在ActiveRecord的改变模板子
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
旧
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)的更新功能()函数:(我有固定的) 更新永远不会做的工作。 debuging后apeard的更新的SQL说明书永远不会有SET查询它总是像乳鼠: UPDATE [tableName值]其中... 它似乎有一个在Subsonic.Repository DLL中的一个问题 - > IRepository的 脏Colums不apdated在新的对象,例如:
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 :
- 在昏暗的猫为db.Category
- Cat.Indx = 1
- Cat.SetIsNew(假)
- 在Cat.Name ='汽车'
- Cat.Update
为什么当更新没有DirtyColumns我如何设置栏脏?
Why when update there is no DirtyColumns How can i set Column as Dirty?
- 更新问题解决它不是一个错误。 - CAT.SetIsLoaded(真):由3号线之后加入解决。 因此,当欢迎使用属性IsLoaded设置为TRU更新将被添加到DirtyColums和THES将更新到数据库的任何列
--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)FirstOrDefault功能:(无法修复) 我总是meaaaaaaaaan总是抛出exsiption =行1:附近有语法错误('。 从SubSonic.Linq DLL
3) the FirstOrDefault Function : (Couldn't fix) always i meaaaaaaaaan always throw exsiption = "Line 1: Incorrect syntax near '('." from the SubSonic.Linq dll
Pleeeeeeeeeeeease帮助
Pleeeeeeeeeeeease help
在此先感谢, TheGodfather
Thanks In advance, TheGodfather
推荐答案
Firtly,其中SubSonic3的版本是您使用?
Firtly, which version of SubSonic3 are you using?
1)不知道你想在这里做什么。
1) Not sure what you are trying to do here.
2)这不是你如何更新记录,试试这个......
2) That is not how you update a record, try this...
Dim cat = Category.SingleOrDefault(Function(item) item.CategoryID = 1)
cat.CategoryName = "MOTORS"
cat.Update()
3)亚音速使用的SingleOrDefault()
如上面例子说明。
这篇关于SubSonic3 VB.Net添加,更新,FirstOrDefault问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!