开发者

SubSonic and not default connection string problem

开发者 https://www.devze.com 2022-12-11 19:00 出处:网络
I encountered bug in my programm because of SubSonic3 returns records with default connection string in

I encountered bug in my programm because of SubSonic3 returns records with default connection string in

SingleOrDefault(ByVal expression As System.Linq.Expressions.Expression(Of System.Func(Of Company.filter, Boolean)), ByVal connectionString As String, ByVal providerName As String)

In Subsonic sources, Database.cs line 323:

instance = Activator.CreateInstance<T>();

I think that was the cause of problem in my case. It creates instance with default constructor and then returns it as a result, that's where we loose custom connection string.

Personally I fixed it with adding 2 lines to ActiveRecord.tt template, in SingleOrDefault function, which has connectionString argument:

            single._db=new <#=Namespace#>.<#=Da开发者_如何学运维tabaseName#>DB(connectionString, providerName);
            single._repo = new SubSonicRepository<<#=tbl.ClassName#>>(single._db); 

But I think you should examine this problem deeper, Rob :)


I don't follow. You specify the name of the ConnectionString is Settings.tt - that's the one we use.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号