Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Records retrieved via ExecuteSingle have isNew = true #10

Open
BatteryMan opened this Issue Feb 10, 2010 · 0 comments

Comments

Projects
None yet
1 participant

When I pull a record from the database via ExecuteSingle, it is incorrectly marked as IsNew = true. when I pull records from the database via ExecuteAsCollection, they are correctly marked is IsNew = false. Here's some sample code that reproduces the problem:

    Dim query As SubSonic.SqlQuery = _
        New SubSonic.Select().From(User.Schema)
    Dim userCol As UserCollection = query.ExecuteAsCollection(Of UserCollection)()
    Dim u1 As User = userCol(0)
    Dim u2 As User = query.ExecuteSingle(Of User)()
    Debug.Print("u1.isNew = " & u1.IsNew)
    Debug.Print("u2.isNew = " & u2.IsNew)

Here's the output from the Debug.Print:

u1.isNew = False
u2.isNew = True

I'm using VB.NET, VS2008, and SQL Server 2005.

Some others noticed something similar on Stack Overflow: http://stackoverflow.com/questions/985834/subsonic-vb-net-problem

Here's some forensics someone did on the issue:

I checked the source code of SubSonic.. and I found that the VB class generator doesn't implements the IActiveRecord. I think most likely is because VB.Net doesn't seem to support 're-implementation' of inheritance or whatever you call that...

So when I debug, I found that Utility.IsSubSonicType returns false (because the ActiveRecord class returns as IReadOnlyRecord, but IsSubSonicType checks for IActiveRecord and IRecordBase) and thus doesn't call the SetLoadState and MarkClean.

So I'm not sure if this is a bug or it is intentional. Any way to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment