blob: 2094c09995d04b42f847edcfdd23c5be2d31de5d (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Settings;
namespace Tango.Integration.Observables
{
public class ObservablesContext : DbContext
{
/// <summary>
/// Initializes a new instance of the <see cref="ObservablesContext" /> class.
/// </summary>
/// <param name="path">The server file path.</param>
/// <param name="isFile">if set to <c>true</c> will try to connect to an .mdf file.</param>
public ObservablesContext(String path, bool isFile) : base(ComposeConnectionString(path, isFile))
{
}
/// <summary>
/// Composes the connection string.
///</summary>
/// <param name="source">The source.</param>
/// <param name="isFile">if set to <c>true</c> [is file].</param>
/// <returns></returns>
private static String ComposeConnectionString(String source, bool isFile)
{
if (!isFile)
{
return String.Format("Data Source={0};Initial Catalog=Tango;Integrated Security=true", source);
}
else
{
return null;
}
}
/// <summary>
/// Creates a default remote database context by the address specified in <see cref="SettingsManager.Default.DataBase.SQLServerAddress" />.
/// </summary>
/// <returns></returns>
public static ObservablesContext CreateDefault()
{
return new ObservablesContext(SettingsManager.Default.DataBase.SQLServerAddress, false);
}
@foreach (var prop in Model.Properties)
{
<div>
/// <summary>
/// Gets or sets the @(prop.Name).
/// </summary>
public @(prop.Type) @(prop.Name) { get; set; }
</div>
}
}
}
|