MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
EntitiesConnection.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Data.SqlClient;
6using System.Data.Entity.Core.EntityClient;
7using System.Data.Entity;
8using MyCaffe.basecode;
9using System.Data.Entity.SqlServer;
10using System.Data.Entity.Infrastructure;
11using MyCaffe.db.image;
12
13namespace MyCaffe.db.temporal
14{
18 public partial class DNNEntitiesTemporal
19 {
24 public DNNEntitiesTemporal(string strConnectionString)
25 : base(strConnectionString)
26 {
27 }
28 }
29
34 {
35 static Dictionary<int, string> m_rgstrConnections = new Dictionary<int, string>();
36 static Dictionary<int, ConnectInfo> m_rgciConnections = new Dictionary<int, ConnectInfo>();
37
42 {
43 }
44
51 public static new string CreateConnectionString(string strDb)
52 {
53 return CreateConnectionString(new ConnectInfo(null, strDb));
54 }
55
61 public static new string CreateConnectionString(ConnectInfo ci)
62 {
63 if (ci == null)
64 ci = g_connectInfo;
65
66 string strDb = ci.Database;
67 string strServerName = g_connectInfo.Server;
68
69 if (ci.Server != null)
70 strServerName = ci.Server;
71
72 if (strServerName == "NONE" || strServerName == "DEFAULT")
73 strServerName = ".";
74
75 string strKey = strDb + strServerName;
76 int nKey = strKey.GetHashCode();
77
78 if (m_rgstrConnections.ContainsKey(nKey) && m_rgciConnections.ContainsKey(nKey) && m_rgciConnections[nKey].Compare(ci))
79 return m_rgstrConnections[nKey];
80
81 string strProviderName = "System.Data.SqlClient";
82 string strDatabaseName = strDb;
83 SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();
84 EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder();
85
86 sqlBuilder.DataSource = strServerName;
87 sqlBuilder.InitialCatalog = strDatabaseName;
88
89 if (string.IsNullOrEmpty(ci.Password))
90 {
91 sqlBuilder.IntegratedSecurity = true;
92 }
93 else
94 {
95 sqlBuilder.PersistSecurityInfo = false;
96 sqlBuilder.UserID = ci.Username;
97 sqlBuilder.Password = ci.Password;
98 sqlBuilder.MultipleActiveResultSets = false;
99 sqlBuilder.Encrypt = true;
100 sqlBuilder.TrustServerCertificate = true;
101 sqlBuilder.ConnectTimeout = 180;
102 }
103
104 string strProviderString = sqlBuilder.ToString();
105
106 builder.Provider = strProviderName;
107 builder.ProviderConnectionString = strProviderString;
108 builder.Metadata = @"res://*/" + strDb + "ModelTemporal.csdl|" +
109 "res://*/" + strDb + "ModelTemporal.ssdl|" +
110 "res://*/" + strDb + "ModelTemporal.msl";
111
112 string strConnection = builder.ToString();
113
114 if (!m_rgstrConnections.ContainsKey(nKey))
115 m_rgstrConnections.Add(nKey, strConnection);
116 else
117 m_rgstrConnections[nKey] = strConnection;
118
119 if (!m_rgciConnections.ContainsKey(nKey))
120 m_rgciConnections.Add(nKey, ci);
121 else
122 m_rgciConnections[nKey] = ci;
123
124 return strConnection;
125 }
126
132 public static new DNNEntitiesTemporal CreateEntities(ConnectInfo ci = null)
133 {
135 }
136 }
137}
The ConnectInfo class specifies the server, database and username/password used to connect to a datab...
Definition: ConnectInfo.cs:14
string Server
Get/set the server.
Definition: ConnectInfo.cs:127
string Username
Returns the username.
Definition: ConnectInfo.cs:145
string Database
Get/set the database.
Definition: ConnectInfo.cs:136
string Password
Returns the password.
Definition: ConnectInfo.cs:153
The EntitiesConnection class defines how to connect to the database via Entity Frameworks.
static ConnectInfo g_connectInfo
Specifies the default database connection info.
The DNNEntities class defines the entities used to connecto the database via Entity Frameworks.
DNNEntitiesTemporal(string strConnectionString)
The DNNEntities constructor.
The EntitiesConnection class defines how to connect to the database via Entity Frameworks.
static new DNNEntitiesTemporal CreateEntities(ConnectInfo ci=null)
Returns the DNNEntitiesTemporal to use.
static new string CreateConnectionString(ConnectInfo ci)
Creates the connection string used.
EntitiesConnectionTemporal()
The EntitiesConnection constructor.
static new string CreateConnectionString(string strDb)
Creates the connection string used.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.db.image namespace contains all image database related classes.
Definition: Database.cs:18
The MyCaffe.db.temporal namespace contains all classes used to create the MyCaffeTemporalDatabase in-...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12