Subsonic VB.NET problem

被刻印的时光 ゝ 提交于 2019-12-24 12:19:59

问题


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:


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?




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/985834/subsonic-vb-net-problem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!