개정판 47f89cbb
MarkusEntities.cs 추가
Change-Id: I82d8ce2f796f67457324a819086d9dd145097287
ConvertService/ServiceBase/Markus.Service.StationController/Markus.Service.StationController.csproj | ||
---|---|---|
175 | 175 |
<Compile Include="Extensions\DataExport.cs" /> |
176 | 176 |
<Compile Include="Extensions\GetStatusTypeEnums.cs" /> |
177 | 177 |
<Compile Include="Extensions\VisualTreeHelper.cs" /> |
178 |
<Compile Include="MarkusEntities.cs" /> |
|
178 | 179 |
<Compile Include="MarkusModel.Context.cs"> |
179 | 180 |
<AutoGen>True</AutoGen> |
180 | 181 |
<DesignTime>True</DesignTime> |
ConvertService/ServiceBase/Markus.Service.StationController/MarkusEntities.cs | ||
---|---|---|
1 |
|
|
2 |
namespace Markus.EntityModel |
|
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 MarkusModel : 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 MarkusModel(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 |
} |
내보내기 Unified diff