public void TestManualProviderCreation()
        {
            string name    = Configurator.GetKey(null, "Gentle.Framework/DefaultProvider/@name");
            string connStr = Configurator.GetKey(null, "Gentle.Framework/DefaultProvider/@connectionString");
            string schema  = Configurator.GetKey(null, "Gentle.Framework/DefaultProvider/@schema");
            //connStr = @"Server=(local)\SQLExpress;Database=Gentle;Integrated Security=true";
            PersistenceBroker broker = ProviderFactory.GetProvider("test", name, connStr, schema).Broker;
            IList             list   = broker.RetrieveList(typeof(MailingList));

            Assert.IsNotNull(list, "No result returned.");
            Assert.IsTrue(list.Count > 0, "List was empty.");
            MailingList ml = list[0] as MailingList;

            ml.Persist();
        }
Beispiel #2
0
 public void TestMultiBroker()
 {
     if (GentleSettings.DefaultProviderConnectionString.IndexOf("127.0.0.1") != -1)
     {
         // use modified connection string
         string            connStr = GentleSettings.DefaultProviderConnectionString.Replace("127.0.0.1", "(local)");
         PersistenceBroker pb      = new PersistenceBroker(GentleSettings.DefaultProviderName, connStr);
         // fetch list
         IList pbList = pb.RetrieveList(typeof(MailingList));
         Assert.AreEqual(Broker.RetrieveList(typeof(MailingList)).Count, pbList.Count, "Not same result.");
         // check that connstr remains same when using SqlBuilder with custom broker
         SqlBuilder   sb   = new SqlBuilder(pb, StatementType.Select, typeof(MailingList));
         SqlStatement stmt = sb.GetStatement(true);
         SqlResult    sr   = stmt.Execute();
         Assert.AreEqual(sr.SessionBroker.Provider.ConnectionString, connStr, "ConnStr not preserved.");
     }
 }
Beispiel #3
0
		public void TestMultiBroker()
		{
			if( GentleSettings.DefaultProviderConnectionString.IndexOf( "127.0.0.1" ) != -1 )
			{
				// use modified connection string
				string connStr = GentleSettings.DefaultProviderConnectionString.Replace( "127.0.0.1", "(local)" );
				PersistenceBroker pb = new PersistenceBroker( GentleSettings.DefaultProviderName, connStr );
				// fetch list
				IList pbList = pb.RetrieveList( typeof(MailingList) );
				Assert.AreEqual( Broker.RetrieveList( typeof(MailingList) ).Count, pbList.Count, "Not same result." );
				// check that connstr remains same when using SqlBuilder with custom broker
				SqlBuilder sb = new SqlBuilder( pb, StatementType.Select, typeof(MailingList) );
				SqlStatement stmt = sb.GetStatement( true );
				SqlResult sr = stmt.Execute();
				Assert.AreEqual( sr.SessionBroker.Provider.ConnectionString, connStr, "ConnStr not preserved." );
			}
		}
Beispiel #4
0
		/// <summary>
		/// Retrieve all objects of a certain type (plain select of all rows in a the
		/// table, i.e. a statement without any where-clause).
		/// </summary>
		/// <param name="broker">The PersistenceBroker and associated provider used fetch the data</param>
		/// <param name="type">The type of the Persistent descendant to retrieve</param>
		/// <returns>A collection of objects of the given type</returns>
		public static IList RetrieveList( PersistenceBroker broker, Type type )
		{
			if( broker == null )
			{
				// use default broker instance by use of the Broker class
				return Broker.RetrieveList( type );
			}
			else // use supplied broker instance
			{
				return broker.RetrieveList( type );
			}
		}