2using System.Collections.Generic;
6using System.Data.Entity.Core.EntityClient;
9using System.Data.Entity.SqlServer;
10using System.Data.Entity.Infrastructure;
24 : base(strConnectionString)
42 SetExecutionStrategy(
"System.Data.SqlClient", () =>
new SqlAzureExecutionStrategy());
43 SetDefaultConnectionFactory(
new LocalDbConnectionFactory(
"mssqllocaldb"));
56 static Dictionary<int, string> m_rgstrConnections =
new Dictionary<int, string>();
57 static Dictionary<int, ConnectInfo> m_rgciConnections =
new Dictionary<int, ConnectInfo>();
100 strServerName = ci.
Server;
102 if (strServerName ==
"NONE" || strServerName ==
"DEFAULT")
105 string strKey = strDb + strServerName;
106 int nKey = strKey.GetHashCode();
108 if (m_rgstrConnections.ContainsKey(nKey) && m_rgciConnections.ContainsKey(nKey) && m_rgciConnections[nKey].Compare(ci))
109 return m_rgstrConnections[nKey];
111 string strProviderName =
"System.Data.SqlClient";
112 string strDatabaseName = strDb;
113 SqlConnectionStringBuilder sqlBuilder =
new SqlConnectionStringBuilder();
114 EntityConnectionStringBuilder builder =
new EntityConnectionStringBuilder();
116 sqlBuilder.DataSource = strServerName;
117 sqlBuilder.InitialCatalog = strDatabaseName;
119 if (
string.IsNullOrEmpty(ci.
Password))
121 sqlBuilder.IntegratedSecurity =
true;
125 sqlBuilder.PersistSecurityInfo =
false;
128 sqlBuilder.MultipleActiveResultSets =
false;
129 sqlBuilder.Encrypt =
true;
130 sqlBuilder.TrustServerCertificate =
true;
131 sqlBuilder.ConnectTimeout = 180;
134 string strProviderString = sqlBuilder.ToString();
136 builder.Provider = strProviderName;
137 builder.ProviderConnectionString = strProviderString;
138 builder.Metadata =
@"res://*/" + strDb +
"Model.csdl|" +
139 "res://*/" + strDb +
"Model.ssdl|" +
140 "res://*/" + strDb +
"Model.msl";
142 string strConnection = builder.ToString();
144 if (!m_rgstrConnections.ContainsKey(nKey))
145 m_rgstrConnections.Add(nKey, strConnection);
147 m_rgstrConnections[nKey] = strConnection;
149 if (!m_rgciConnections.ContainsKey(nKey))
150 m_rgciConnections.Add(nKey, ci);
152 m_rgciConnections[nKey] = ci;
154 return strConnection;
The ConnectInfo class specifies the server, database and username/password used to connect to a datab...
string Server
Get/set the server.
string Username
Returns the username.
string Database
Get/set the database.
string Password
Returns the password.
The DNNConfiguration class used to define the connection strategy.
DNNConfiguration()
The DNNConfiguration constructor.
The DNNEntities class defines the entities used to connecto the database via Entity Frameworks.
DNNEntities(string strConnectionString)
The DNNEntities constructor.
The EntitiesConnection class defines how to connect to the database via Entity Frameworks.
static DNNEntities CreateEntities(ConnectInfo ci=null)
Returns the DNNEntities to use.
EntitiesConnection()
The EntitiesConnection constructor.
static string CreateConnectionString(ConnectInfo ci)
Creates the connection string used.
static ConnectInfo GlobalDatabaseConnectInfo
Get/set the global database connection info.
static string CreateConnectionString(string strDb)
Creates the connection string used.
static ConnectInfo g_connectInfo
Specifies the default database connection info.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.db.image namespace contains all image database related classes.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...