Example #1
0
        /// <summary>
        /// Process the given type and construct the corresponding ObjectMap instance. If the
        /// map has been created previously a cached instance is returned.
        /// </summary>
        /// <param name="broker">The PersistenceBroker to use for obtaining metadata on the type. If
        /// null is passed the DefaultProvider will be used.</param>
        /// <param name="type">The type to process</param>
        /// <returns>An ObjectMap instance describing the type</returns>
        public static ObjectMap GetMap(PersistenceBroker broker, Type type)
        {
            ObjectMap om = null;

            lock (maps.SyncRoot)
            {
                if (!maps.ContainsKey(type))
                {
                    if (broker == null)
                    {
                        IGentleProvider provider = ProviderFactory.GetProvider(type);
                        broker = provider.Broker;
                    }
                    om         = ConstructMap(broker, type);
                    maps[type] = om;
                }
                else
                {
                    om = (ObjectMap)maps[type];
                }
            }
            // throw an exception for unsupported types
            Check.VerifyNotNull(om, Error.UnsupportedType, type);
            return(om);
        }
 /// <summary>
 /// Construct a TableMap instance to hold information on the given table.
 /// </summary>
 /// <param name="provider">The Gentle provider to which this map relates.</param>
 /// <param name="tableName">The name of the table for which to hold information.</param>
 public TableMap(IGentleProvider provider, string tableName) : base(new PersistenceBroker(provider))
 {
     this.provider = provider;
     // use property accessor to also set quoted name
     if (tableName != null)
     {
         TableName = tableName;
     }
     fields = new FieldList();
 }
Example #3
0
 /// <summary>
 /// This method returns true if a provider was found with the specified name. The matching
 /// provider is returned in the out parameter.
 /// </summary>
 /// <param name="name">The developer assigned name of the provider.</param>
 /// <param name="provider">The matching provider or null if none was found.</param>
 /// <returns>True if a match was found and false otherwise.</returns>
 private static bool GetNamedProvider(string name, out IGentleProvider provider)
 {
     if (name != null && providers.ContainsKey(name))
     {
         provider = providers[name] as IGentleProvider;
         return(true);
     }
     provider = null;
     return(false);
 }
Example #4
0
		/// <summary>
		/// This method returns true if a provider was found with the specified name. The matching
		/// provider is returned in the out parameter.
		/// </summary>
		/// <param name="name">The developer assigned name of the provider.</param>
		/// <param name="provider">The matching provider or null if none was found.</param>
		/// <returns>True if a match was found and false otherwise.</returns>
		private static bool GetNamedProvider( string name, out IGentleProvider provider )
		{
			if( name != null && providers.ContainsKey( name ) )
			{
				provider = providers[ name ] as IGentleProvider;
				return true;
			}
			provider = null;
			return false;
		}
Example #5
0
		/// <summary>
		/// Construct a TableMap instance to hold information on the given table.
		/// </summary>
		/// <param name="provider">The Gentle provider to which this map relates.</param>
		/// <param name="tableName">The name of the table for which to hold information.</param>
		public TableMap( IGentleProvider provider, string tableName ) : base( new PersistenceBroker( provider ) )
		{
			this.provider = provider;
			// use property accessor to also set quoted name
			if( tableName != null )
			{
				TableName = tableName;
			}
			fields = new FieldList();
		}
Example #6
0
		/// <summary>
		/// Construct a TableMap instance to hold information on the given table.
		/// </summary>
		/// <param name="broker">The PersistenceBroker instance used to obtain metadata on the table.
		/// If null is passed the DefaultProvider settings will be used.</param>
		/// <param name="tableName">The name of the table for which to hold information.</param>
		public TableMap( PersistenceBroker broker, string tableName ) : base( broker )
		{
			provider = SessionBroker.Provider;
			// use property accessor to also set quoted name
			if( tableName != null )
			{
				TableName = tableName;
			}
			fields = new FieldList();
		}
 /// <summary>
 /// Construct a TableMap instance to hold information on the given table.
 /// </summary>
 /// <param name="broker">The PersistenceBroker instance used to obtain metadata on the table.
 /// If null is passed the DefaultProvider settings will be used.</param>
 /// <param name="tableName">The name of the table for which to hold information.</param>
 public TableMap(PersistenceBroker broker, string tableName) : base(broker)
 {
     provider = SessionBroker.Provider;
     // use property accessor to also set quoted name
     if (tableName != null)
     {
         TableName = tableName;
     }
     fields = new FieldList();
 }
            private IGentleProvider ValidateProvider(object providerObj, string connectionString)
            {
                Check.VerifyNotNull(providerObj, "An error occurred while creating a provider instance.{0}" +
                                    "Assembly={1}, ConnectionString={2}", Environment.NewLine,
                                    assembly.FullName, connectionString);
                IGentleProvider provider = providerObj as IGentleProvider;

                Check.VerifyNotNull(provider, Error.InvalidProviderLibrary, assembly.FullName);
                return(provider);
            }
Example #9
0
		/// <summary>
		/// Constructor for the GentleAnalyzer base class.
		/// </summary>
		/// <param name="provider"></param>
		protected GentleAnalyzer( IGentleProvider provider )
		{
			this.provider = provider;
			if( maps == null )
			{
				maps = new Hashtable();
				done = false;
			}
			// make sure we use our own PB to avoid using the DefaultProvider when analyzing the database
			broker = new PersistenceBroker( provider );
			// this.broker = new PersistenceBroker( provider.Name, provider.ConnectionString );
			// set the default analyzer level
			level = GentleSettings.AnalyzerLevel;
		}
Example #10
0
 /// <summary>
 /// Constructor for the GentleAnalyzer base class.
 /// </summary>
 /// <param name="provider"></param>
 protected GentleAnalyzer(IGentleProvider provider)
 {
     this.provider = provider;
     if (maps == null)
     {
         maps = new Hashtable();
         done = false;
     }
     // make sure we use our own PB to avoid using the DefaultProvider when analyzing the database
     broker = new PersistenceBroker(provider);
     // this.broker = new PersistenceBroker( provider.Name, provider.ConnectionString );
     // set the default analyzer level
     level = GentleSettings.AnalyzerLevel;
 }
 public IGentleProvider GetProvider(string providerName, string connectionString, string schemaName)
 {
     if (providerName == null)
     {
         return(GetProvider());                // use default provider
     }
     else
     {
         Check.Verify(providers.ContainsKey(providerName), Error.UnknownProvider, providerName);
         ProviderInfo    pi       = (ProviderInfo)providers[providerName];
         IGentleProvider provider = pi.CreateInstance(connectionString, schemaName);
         return(provider);
     }
 }
Example #12
0
        public virtual void Init(string providerName)
        {
            ObjectFactory.ClearMaps();
            Broker.ClearPersistenceBroker();
            ObjectFactory.ClearMaps();
            IGentleProvider provider = ProviderFactory.GetProvider(providerName, "");

            Assert.AreEqual(provider.Name, providerName, "Wrong provider returned from factory!");
            sf     = provider.GetSqlFactory();
            broker = new PersistenceBroker(provider);
            sb     = new SqlBuilder(provider);
            // make sure analyzer errors are ignored for this test
            origLevel = GentleSettings.AnalyzerLevel;
            GentleSettings.AnalyzerLevel = AnalyzerLevel.None;
        }
Example #13
0
		public DB2Analyzer( IGentleProvider provider ) : base( provider )
		{
		}
Example #14
0
 public MySQLAnalyzer(IGentleProvider provider) : base(provider)
 {
 }
Example #15
0
 /// <summary>
 /// Constructor using the supplied provider (or using DefaultProvider settings if null is passed).
 /// </summary>
 public PersistenceBroker(IGentleProvider provider)
 {
     this.provider = provider != null ? provider : ProviderFactory.GetProvider(null, null);
 }
		public SQLServerCEFactory( IGentleProvider provider ) : base( provider )
		{
		}
Example #17
0
        /// <summary>
        /// Insert an object. This updates the identity property of objects with
        /// autogenerated primary keys.
        /// </summary>
        /// <param name="obj">The object to insert</param>
        public static void Insert(object obj)
        {
            IGentleProvider provider = ProviderFactory.GetProvider(obj.GetType());

            provider.Broker.Insert(obj);
        }
Example #18
0
        /// <summary>
        /// Retrieve a list of objects of a given type, optionally using the key as constraints.
        /// The key must contain column names and values (they will not be translated from
        /// property names to column names).
        /// </summary>
        /// <typeparam name="T">The type of objects to retrieve</typeparam>
        /// <param name="key">The key containing any constraints</param>
        /// <param name="result">An optional existing container in which to store the created objects. If
        /// this parameter is null a new IList instance will be created.</param>
        /// <returns>A collection of object instances</returns>
        public static IList <T> RetrieveList <T>(Key key, IList <T> result)
        {
            IGentleProvider provider = ProviderFactory.GetProvider(typeof(T));

            return(provider.Broker.RetrieveList <T>(key, result));
        }
Example #19
0
		/// <summary> Construct a new SqlBuilder instance for constructing a statement of the 
		/// given type for the specified business class type.
		/// </summary> 
		/// <param name="provider">The IGentleProvider used to obtain an SqlFactory</param>
		/// <param name="stmtType">The type of SQL statement to construct</param>
		/// <param name="type">The object class to work on</param>
		public SqlBuilder( IGentleProvider provider, StatementType stmtType, Type type ) :
			this( provider, stmtType, type, LogicalOperator.And )
		{
		}
		public SybaseASAAnalyzer( IGentleProvider provider ) : base( provider )
		{
		}
Example #21
0
		public DB2Factory( IGentleProvider provider ) : base( provider )
		{
		}
Example #22
0
		public SybaseFactory( IGentleProvider provider ) : base( provider )
		{
		}
Example #23
0
		public FirebirdFactory( IGentleProvider provider ) : base( provider )
		{
			// TODO schemaName is currently not specifyable!
		}
Example #24
0
		public MySQLAnalyzer( IGentleProvider provider ) : base( provider )
		{
		}
		public PostgreSQLAnalyzer( IGentleProvider provider ) : base( provider )
		{
		}
Example #26
0
		public MySQLFactory( IGentleProvider provider ) : base( provider )
		{
		}
 public JetFactory(IGentleProvider provider) : base(provider)
 {
 }
Example #28
0
 public GentleRenderer(IGentleProvider provider)
 {
     this.provider = provider;
 }
Example #29
0
		/// <summary>
		/// Construct a new GentleSqlFactory instance.
		/// </summary>
		protected GentleSqlFactory( IGentleProvider provider )
		{
			this.provider = provider;
		}
Example #30
0
        /// <summary>
        /// Retrieve a list of objects of a given type, optionally using the key as constraints.
        /// The key must contain column names and values (they will not be translated from
        /// property names to column names).
        /// </summary>
        /// <param name="type">The type of objects to retrieve</param>
        /// <param name="key">The key containing any constraints</param>
        /// <param name="result">An optional existing container in which to store the created objects. If
        /// this parameter is null a new IList instance will be created.</param>
        /// <returns>A collection of object instances</returns>
        public static IList RetrieveList(Type type, Key key, IList result)
        {
            IGentleProvider provider = ProviderFactory.GetProvider(type);

            return(provider.Broker.RetrieveList(type, key, result));
        }
Example #31
0
        /// <summary>
        /// Permanently remove an object.
        /// </summary>
        /// <param name="type">The type of object</param>
        /// <param name="key">The key indentifying the object</param>
        public static void Remove(Type type, Key key)
        {
            IGentleProvider provider = ProviderFactory.GetProvider(type);

            provider.Broker.Remove(type, key);
        }
Example #32
0
        /// <summary>
        /// Persist (insert or update) an object.
        /// Updates the Id property of AutoPersistent objects on insert.
        /// </summary>
        /// <param name="entity">The object to persist</param>
        public static void Persist(IEntity entity)
        {
            IGentleProvider provider = ProviderFactory.GetProvider(entity.GetType());

            provider.Broker.Persist(entity);
        }
Example #33
0
 /// <summary>
 /// This method constructs a PersistenceBroker instance. The specified provider (database
 /// engine name) and connection string will be used to instantiate the desired backend
 /// engine used by this broker. The name will be used to uniquely distinguish this instance
 /// from other providers, and can be used to later obtain a reference to the cached instance
 /// by calling <see cref="ProviderFactory.GetNamedProvider"/>.
 /// </summary>
 /// <param name="name">The unique name to associate with this provider/broker pair.</param>
 /// <param name="providerName">The database engine name</param>
 /// <param name="connectionString">The connection string for connecting to the database</param>
 public PersistenceBroker(string name, string providerName, string connectionString)
 {
     provider = ProviderFactory.GetProvider(name, providerName, connectionString);
 }
Example #34
0
        /// <summary>
        /// Permanently remove an object.
        /// </summary>
        /// <param name="obj">The object to persist</param>
        public static void Remove(object obj)
        {
            IGentleProvider provider = ProviderFactory.GetProvider(obj.GetType());

            provider.Broker.Remove(obj);
        }
Example #35
0
		/// <summary>
		/// Construct a new SqlBuilder instance for constructing a statement of the given type
		/// for the specified business class type.
		/// </summary>
		/// <param name="provider">The IGentleProvider used to obtain an SqlFactory</param>
		/// <param name="stmtType">The type of SQL statement to construct</param>
		/// <param name="type">The object class to work on</param>
		/// <param name="logicalOperator">The logic operator used with constraints (can be either AND or OR)</param>
		public SqlBuilder( IGentleProvider provider, StatementType stmtType, Type type, LogicalOperator logicalOperator ) :
			base( provider != null ? new PersistenceBroker( provider ) : type != null ? new PersistenceBroker( type ) : null )
		{
			this.provider = provider ?? broker.Provider;
			sf = this.provider.GetSqlFactory();
			cmd = sf.GetCommand();
			this.stmtType = stmtType;
			map = type != null ? ObjectFactory.GetMap( SessionBroker, type ) : null;
			this.logicalOperator = logicalOperator == LogicalOperator.Or ? " or " : " and ";
			fields = new ArrayList(); // list of fields 
			quotedFields = new ArrayList(); // list of fields 
			constraints = new ArrayList(); // list of string constraints
			parameterValues = new Hashtable();
			parameterOrder = new ArrayList();
		}
Example #36
0
 public SybaseASAFactory(IGentleProvider provider) : base(provider)
 {
 }
 public MySQLFactory(IGentleProvider provider) : base(provider)
 {
 }
Example #38
0
 /// <summary>
 /// This method constructs a PersistenceBroker instance. The specified provider (database
 /// engine name) and connection string will be used to instantiate the desired backend
 /// engine used by this broker.
 /// </summary>
 /// <param name="providerName">The database engine name</param>
 /// <param name="connectionString">The connection string for connecting to the database</param>
 public PersistenceBroker(string providerName, string connectionString)
 {
     // determine backend engine and instatiate it
     provider = ProviderFactory.GetProvider(null, providerName, connectionString);
 }
Example #39
0
 public OracleODPAnalyzer(IGentleProvider provider) : base(provider)
 {
 }
Example #40
0
 /// <summary>
 /// Constructor selecting the provider based on the namespace of the supplied type.
 /// </summary>
 public PersistenceBroker(Type type)
 {
     provider = ProviderFactory.GetProvider(type);
 }
 public OracleFactory(IGentleProvider provider) : base(provider)
 {
 }
 public SybaseASAAnalyzer(IGentleProvider provider) : base(provider)
 {
 }
Example #43
0
		public JetFactory( IGentleProvider provider ) : base( provider )
		{
		}
Example #44
0
		public FirebirdAnalyzer( IGentleProvider provider ) : base( provider )
		{
		}
Example #45
0
        /// <summary>
        /// Retrieve an object given its type and key. This method returns null if no
        /// record matches the query.
        /// </summary>
        /// <param name="type">The type of object to create</param>
        /// <param name="key">The key of the object to retrieve</param>
        /// <returns>The created object instance or null if no records were retrieved.</returns>
        public static object TryRetrieveInstance(Type type, Key key)
        {
            IGentleProvider provider = ProviderFactory.GetProvider(type);

            return(provider.Broker.TryRetrieveInstance(type, key));
        }
Example #46
0
		protected SQL92Analyzer( IGentleProvider provider ) : base( provider )
		{
		}
Example #47
0
        /// <summary>
        /// Retrieve an object given its type and key. This method returns null if no
        /// record matches the query.
        /// </summary>
        /// <typeparam name="T">The type of objects to retrieve</typeparam>
        /// <param name="key">The key of the object to retrieve</param>
        /// <returns>The created object instance or null if no records were retrieved.</returns>
        public static T TryRetrieveInstance <T>(Key key)
        {
            IGentleProvider provider = ProviderFactory.GetProvider(typeof(T));

            return(provider.Broker.TryRetrieveInstance <T>(key));
        }
Example #48
0
 public FirebirdFactory(IGentleProvider provider) : base(provider)
 {
     // TODO schemaName is currently not specifyable!
 }
Example #49
0
		/// <summary>
		/// Construct a new SqlBuilder instance for constructing a statement of the given type.
		/// </summary>
		/// <param name="provider">The IGentleProvider used to obtain an SqlFactory</param>
		public SqlBuilder( IGentleProvider provider ) : this( provider, StatementType.Unknown, null, LogicalOperator.And )
		{
		}
Example #50
0
 public SQLServerFactory(IGentleProvider provider) : base(provider)
 {
 }
Example #51
0
		public OracleAnalyzer( IGentleProvider provider ) : base( provider )
		{
		}
		public SQLServerAnalyzer( IGentleProvider provider ) : base( provider )
		{
		}
Example #53
0
		public OracleFactory( IGentleProvider provider ) : base( provider )
		{
		}
Example #54
0
		public SQLiteAnalyzer( IGentleProvider provider ) : base( provider )
		{
		}
Example #55
0
		public GentleRenderer( IGentleProvider provider )
		{
			this.provider = provider;
		}