public void Load(string connectionString)
{
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
try
{
conn.ConnectionString = connectionString;
conn.Open();
var da = new SqlDataAdapter("select * from sys.tables where name = '__nhydrateschema'", conn);
var ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
da = new SqlDataAdapter("SELECT * FROM __nhydrateschema where [ModelKey] = '" + UpgradeInstaller.MODELKEY + "'", conn);
ds = new DataSet();
da.Fill(ds);
var t = ds.Tables[0];
if (t.Rows.Count > 0)
{
this.dbVersion = (string)t.Rows[0]["dbVersion"];
this.LastUpdate = (DateTime)t.Rows[0]["LastUpdate"];
this.ModelKey = (Guid)t.Rows[0]["ModelKey"];
this.LoadHistory((string)t.Rows[0]["History"]);
this.IsLoaded = true;
}
//There is an nHydrate table so empty or not we are finished
return;
}
this.dbVersion = SqlServers.SelectExtendedProperty(connectionString, "dbVersion", string.Empty, string.Empty, string.Empty);
try
{
this.LastUpdate = DateTime.ParseExact(SqlServers.SelectExtendedProperty(connectionString, "LastUpdate", string.Empty, string.Empty, string.Empty), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
}
catch { }
try
{
this.ModelKey = new Guid(SqlServers.SelectExtendedProperty(connectionString, "ModelKey", string.Empty, string.Empty, string.Empty));
}
catch { }
this.LoadHistory(SqlServers.SelectExtendedProperty(connectionString, "History", string.Empty, string.Empty, string.Empty));
}
catch (Exception ex)
{
throw;
}
finally
{
if (conn != null)
conn.Close();
}
}