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.DAL.Observables
{
public class ObservablesContext : DbContext
{
///
/// Initializes a new instance of the class.
///
/// The server file path.
/// if set to true will try to connect to an .mdf file.
public ObservablesContext(String path, bool isFile) : base(ComposeConnectionString(path, isFile))
{
}
///
/// Composes the connection string.
///
/// The source.
/// if set to true [is file].
///
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;
}
}
///
/// Creates a default remote database context by the address specified in .
///
///
public static ObservablesContext CreateDefault()
{
return new ObservablesContext(SettingsManager.Default.DataBase.SQLServerAddress, false);
}
@foreach (var prop in Model.Properties)
{
///
/// Gets or sets the @(prop.Name).
///
public @(prop.Type) @(prop.Name) { get; set; }
}
}
}