aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService.Gateway/DB/GatewayDbContext.cs
blob: 9f4a9f0f9da289acfad18ccd2e31baef73b8bef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using Tango.Core;

namespace Tango.MachineService.Gateway.DB
{
    public class GatewayDbContext : DbContext
    {
        public GatewayDbContext(DataSource dataSource) : base(dataSource.ToConnection(), true)
        {

        }

        public static GatewayDbContext CreateDefault()
        {
            return new GatewayDbContext(new DataSource()
            {
                Address = GatewayConfig.DB_ADDRESS,
                IntegratedSecurity = false,
                Catalog = GatewayConfig.DB_CATALOG,
                Type = DataSourceType.SQLServer,
                UserName = GatewayConfig.DB_USER_NAME,
                Password = GatewayConfig.DB_PASSWORD
            });
        }

        /// <summary>
        /// Gets or sets the environments.
        /// </summary>
        public DbSet<Environment> Environments
        {
            get; set;
        }
    }
}