Наследование: System.Data.Linq.DataContext
		private static void ClearDatabase(PluginDatabaseModelDataContext context)
		{
            context.ExecuteCommand("delete from ProfileStorage");
            context.ExecuteCommand("delete from Profile");
            context.ExecuteCommand("delete from Account");
            context.ExecuteCommand("delete from Plugin");
		}
		public void Destroy()
		{
			var configuration = ObjectFactory.GetInstance<IDatabaseConfiguration>();
			using (var context = new PluginDatabaseModelDataContext(configuration.ConnectionString))
			{
				foreach (var plugin in context.Plugins)
				{
					context.Plugins.DeleteOnSubmit(plugin);
				}
				context.SubmitChanges();
			}
		}
		private static void ClearPluginDb(string pluginConnectionString)
		{
			var context = new PluginDatabaseModelDataContext(pluginConnectionString);
			if (!context.DatabaseExists())
			{
				context.CreateDatabase();
				context.SubmitChanges();
			}
			else
			{
				ClearDatabase(context);
			}
		}
		public void CreateIfMissing()
		{
			using(var context = new PluginDatabaseModelDataContext(_configuration.ConnectionString))
			{
				Plugin plugin = context.Plugins.SingleOrDefault(p => p.Name == _pluginName);
				if (plugin != null)
				{
					return;
				}
				plugin = new Plugin { Name = _pluginName };
				context.Plugins.InsertOnSubmit(plugin);
				context.SubmitChanges();
			}
		}
Пример #5
0
 public void CreateIfMissing()
 {
     using (var context = new PluginDatabaseModelDataContext(_configuration.ConnectionString))
     {
         Plugin plugin = context.Plugins.SingleOrDefault(p => p.Name == _pluginName);
         if (plugin != null)
         {
             return;
         }
         plugin = new Plugin {
             Name = _pluginName
         };
         context.Plugins.InsertOnSubmit(plugin);
         context.SubmitChanges();
     }
 }
		public void OnAfterScenario()
		{
			ClearTpDB(_context);
			var context = new PluginDatabaseModelDataContext(Properties.Settings.Default.PluginConnectionString);
			ClearDatabase(context);
		}
		private static void ClearDatabase(PluginDatabaseModelDataContext context)
		{
			var plugins = from plugin in context.Plugins select plugin;
			Array.ForEach(plugins.ToArray(), x => context.Plugins.DeleteOnSubmit(x));
			context.SubmitChanges();
		}
		public void OnAfterScenario()
		{
			ClearTpDB(new TpDatabaseDataContext(Settings.Default.TpConnectionString));
			var context = new PluginDatabaseModelDataContext(Settings.Default.PluginConnectionString);
			ClearDatabase(context);
		}