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)
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?
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:
Here's the output from the Debug.Print:
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?