Search code examples
c#castle-activerecordcastle

How to get reference to SqlConnection (or Connection string) in Castle ActiveRecord?


how can I get reference to current SqlConnection or Sqlconnection in config?

I found http://svn.castleproject.org:8080/svn/castle/trunk/ActiveRecord/Castle.ActiveRecord.Tests/DifferentDatabaseScopeTestCase.cs

and code

 private string GetSqlConnection()
        {
            IConfigurationSource config = GetConfigSource();

            IConfiguration db2 = config.GetConfiguration(typeof(ActiveRecordBase));

            string conn = string.Empty;

            foreach (IConfiguration child in db2.Children)
            {
                if (child.Name == "connection.connection_string")
                {
                    conn = child.Value;
                }
            }

            return conn;
        }

But I cant understand where I can find "GetConfigSource" implementation? Is this standart Castle helper function or not?

I use these namespaces

using Castle.ActiveRecord;
using NHibernate.Criterion;
using NHibernate;
using Castle.Core.Configuration;
using Castle.ActiveRecord.Framework;

Solution

  • I had to doanload AR sources from svn to solve it.

    It means

    System.Configuration.ConfigurationManager.GetSection("activerecord") as IConfigurationSource;