using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core; using Tango.Settings; namespace Tango.DAL.Remote.DB { /// /// Represents an SQL Server database context. /// /// public partial class RemoteDB : 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 RemoteDB(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("metadata=res://*/DB.RemoteADO.csdl|res://*/DB.RemoteADO.ssdl|res://*/DB.RemoteADO.msl;provider=System.Data.SqlClient;provider connection string=\"data source={0};initial catalog=Tango;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework\"", source); } else { return null; } } /// /// Creates a default remote database context by the address specified in . /// /// public static RemoteDB CreateDefault() { return new RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false); } } }