views:

290

answers:

3

When I'm using VB.NET to use subsonic, It seems to have problem marking records as Old and Clean. Whenever I query using ExecuteSingle or ExecuteTypedList, i need to manually MarkClean and MarkOld, else whenever I save it will save as a new record.

Am I the only one facing this problem ? I'm using SubSonic 2.2 btw.

+1  A: 

When you use ExecuteSingle or ExecuteTypedList, you could be doing with a class that didnt have those properties, I think the intention is that you are populating a POCO and not (necessarily) an Entity or other ORM object.

ExecuteAsCollection and all of the .Load methods behave as you expect because they call SetLoadState() and/or MarkClean().

Personally, I dont face this problem because I use Subsonic purely as a (smart) DAL (CRUD Only) and my own entity layer takes care of things like dirty/new.

Zapatta
+1  A: 

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?

Kelvin
A: 

Yes, I had the same problem. MarkClean and MarkOld before setting properties and saving fixed the issue. see this

Rick Ratayczak