views:

364

answers:

1

Hi, 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 :

  1. Dim Cat as db.Category
  2. Cat.Indx=1
  3. Cat.SetIsNew(False)
  4. Cat.Name= 'Motors'
  5. 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

A: 

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...

Dim cat = Category.SingleOrDefault(Function(item) item.CategoryID = 1)
cat.CategoryName = "MOTORS"
cat.Update()

3) Subsonic uses SingleOrDefault() as example above demonstrates.

BlackMael
MAIN PROBLEM :I am using SubSonic 3 With sqlServer 2000. the FirstOrDefault Function : always i meaaaaaaaaan always throw exsiption = "Line 1: Incorrect syntax near '('." from the SubSonic.Linq dll
TheGodfather
Okay. But as I said, maybe you should be using SingleOrDefault()? My example above (2) works for me, I am not sure why it wouldn't for you.
BlackMael
Or perhaps the following works... cat = Category.Find(Function(item) item.CategoryID = 1).FirstOrDefault()
BlackMael
Thanks for your time .did you try it with sql server 2000.i think that this is the problem somthing with hidden query sentax .in each select query subsonic3 add "TOP (n)" after the "SELECT",and this sentax is worng in sqlserver 2000 its should be " TOP n".so Know I am 99.999% sure that this a bug.
TheGodfather