markus / ConvertService / ServiceBase / StationControllerService / MarkusEntities.cs @ 037ab674
이력 | 보기 | 이력해설 | 다운로드 (2.17 KB)
1 |
|
---|---|
2 |
namespace StationControllerService |
3 |
{ |
4 |
using System; |
5 |
using System.Data.Entity; |
6 |
using System.Data.Entity.Core.EntityClient; |
7 |
using System.Data.Entity.Infrastructure; |
8 |
using System.Data.SqlClient; |
9 |
|
10 |
public partial class markusEntities : DbContext |
11 |
{ |
12 |
private const string providerName = "System.Data.SqlClient"; |
13 |
private const string MarkusMeta = @"res://*/MarkusModel.csdl|res://*/MarkusModel.ssdl|res://*/MarkusModel.msl"; |
14 |
|
15 |
public markusEntities(string ConnectionString) |
16 |
: base(ConnectionStringBuilder(ConnectionString).ToString()) |
17 |
{ |
18 |
this.Database.CommandTimeout = 60; |
19 |
} |
20 |
|
21 |
private static EntityConnectionStringBuilder ConnectionStringBuilder(string ConnectionString) |
22 |
{ |
23 |
//SqlConnectionStringBuilder _bl = new SqlConnectionStringBuilder(string.Format(Properties.Settings.Default.ProjectCIConnectionString, "DeepView")); |
24 |
SqlConnectionStringBuilder _bl = new SqlConnectionStringBuilder(ConnectionString); |
25 |
return EntityConnectionBuilder(_bl, MarkusMeta); |
26 |
} |
27 |
|
28 |
private static EntityConnectionStringBuilder |
29 |
EntityConnectionBuilder(SqlConnectionStringBuilder SqlStringBuilder, string EntityMetaData) |
30 |
{ |
31 |
string providerString = SqlStringBuilder.ToString(); |
32 |
|
33 |
EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); |
34 |
|
35 |
|
36 |
entityBuilder.Provider = providerName; |
37 |
entityBuilder.ProviderConnectionString = providerString; |
38 |
entityBuilder.Metadata = EntityMetaData; |
39 |
|
40 |
//Console.WriteLine(entityBuilder.ToString()); |
41 |
|
42 |
using (EntityConnection conn = |
43 |
new EntityConnection(entityBuilder.ToString())) |
44 |
{ |
45 |
try |
46 |
{ |
47 |
conn.Open(); |
48 |
//Console.WriteLine("Just testing the connection."); |
49 |
conn.Close(); |
50 |
} |
51 |
catch (Exception ex) |
52 |
{ |
53 |
System.Diagnostics.Debug.WriteLine(ex.ToString()); |
54 |
throw ex; |
55 |
} |
56 |
|
57 |
} |
58 |
|
59 |
return entityBuilder; |
60 |
} |
61 |
|
62 |
} |
63 |
} |