This project is read-only.

Fixed GetConnectionString() bug

Jun 3, 2012 at 12:29 PM

Been able to select, and update, but I wasn't able to delete.  So I tracked down the issue to the following nHydrate generated code method: GetConnectionString().

This is my web.config connection string entry which works for everything else, but DbContext.DeleteItem(IBusinesObject):

<add name="TurbineEntities" connectionString="Data Source=fk-s02;Initial Catalog=alpha_Turbine;Persist Security Info=True;User ID=sa;Password=f#nK3y135;MultipleActiveResultSets=True" />

And this was the code generated method before I modified it, which would return string.Empty, as the RegEx match failed.:

internal static string GetConnectionString()
{
	string s = System.Configuration.ConfigurationManager.ConnectionStrings["TurbineEntities"].ConnectionString;
	System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex("provider connection string\\s*=\\s*\"([^\"]*)");
	System.Text.RegularExpressions.Match m = regEx.Match(s);
	string connString = string.Empty;
	if (m != null && m.Groups.Count > 1)
	{
		connString = m.Groups[1].Value;
	}
	return connString;
}

And this is the method after I modified it by changing the default connString from string.Empty to s.:

internal static string GetConnectionString()
{
	string s = System.Configuration.ConfigurationManager.ConnectionStrings["TurbineEntities"].ConnectionString;
	System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex("provider connection string\\s*=\\s*\"([^\"]*)");
	System.Text.RegularExpressions.Match m = regEx.Match(s);
	string connString = s;
	if (m != null && m.Groups.Count > 1)
	{
		connString = m.Groups[1].Value;
	}
	return connString;
}
 
Jun 4, 2012 at 1:25 PM

Thank you. This has been fixed in the source and will be part of the next version.