프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.DataBase / MarkusEntities.cs @ 53c9637d

이력 | 보기 | 이력해설 | 다운로드 (2.14 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
        }
19
        private static EntityConnectionStringBuilder ConnectionStringBuilder(string ConnectionString)
20
        {
21
            //SqlConnectionStringBuilder _bl = new SqlConnectionStringBuilder(string.Format(Properties.Settings.Default.ProjectCIConnectionString, "DeepView"));
22
            SqlConnectionStringBuilder _bl = new SqlConnectionStringBuilder(ConnectionString);
23

    
24
            return EntityConnectionBuilder(_bl, MarkusMeta);
25
        }
26

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

    
32
            EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
33

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

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

    
56
            return entityBuilder;
57
        }
58

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