프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Service.DataBase / MarkusEntities.cs @ cdfb57ff

이력 | 보기 | 이력해설 | 다운로드 (2.18 KB)

1

2
namespace Markus.Service.DataBase
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 = 300;
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

    
26
            return EntityConnectionBuilder(_bl, MarkusMeta);
27
        }
28

    
29
        private static EntityConnectionStringBuilder
30
          EntityConnectionBuilder(SqlConnectionStringBuilder SqlStringBuilder, string EntityMetaData)
31
        {
32
            string providerString = SqlStringBuilder.ToString();
33

    
34
            EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
35

    
36
            entityBuilder.Provider = providerName;
37
            entityBuilder.ProviderConnectionString = providerString;
38
            entityBuilder.Metadata = EntityMetaData;
39
            //Console.WriteLine(entityBuilder.ToString());
40

    
41
            using (EntityConnection conn =
42
                new EntityConnection(entityBuilder.ToString()))
43
            {
44
                try
45
                {
46
                    conn.Open();
47
                    //Console.WriteLine("Just testing the connection.");
48
                    conn.Close();
49
                }
50
                catch (Exception ex)
51
                {
52
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
53
                    throw ex;
54
                }
55
               
56
            }
57

    
58
            return entityBuilder;
59
        }
60

    
61
    }
62
}
클립보드 이미지 추가 (최대 크기: 500 MB)