/// <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(); }
/// <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); }
/// <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; }
/// <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(); }
/// <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); }
/// <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; }
/// <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); } }
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; }
public DB2Analyzer( IGentleProvider provider ) : base( provider ) { }
public MySQLAnalyzer(IGentleProvider provider) : base(provider) { }
/// <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 ) { }
/// <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); }
/// <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)); }
/// <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 ) { }
public DB2Factory( IGentleProvider provider ) : base( provider ) { }
public SybaseFactory( IGentleProvider provider ) : base( provider ) { }
public FirebirdFactory( IGentleProvider provider ) : base( provider ) { // TODO schemaName is currently not specifyable! }
public MySQLAnalyzer( IGentleProvider provider ) : base( provider ) { }
public PostgreSQLAnalyzer( IGentleProvider provider ) : base( provider ) { }
public MySQLFactory( IGentleProvider provider ) : base( provider ) { }
public JetFactory(IGentleProvider provider) : base(provider) { }
public GentleRenderer(IGentleProvider provider) { this.provider = provider; }
/// <summary> /// Construct a new GentleSqlFactory instance. /// </summary> protected GentleSqlFactory( IGentleProvider provider ) { this.provider = provider; }
/// <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)); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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(); }
public SybaseASAFactory(IGentleProvider provider) : base(provider) { }
public MySQLFactory(IGentleProvider provider) : base(provider) { }
/// <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); }
public OracleODPAnalyzer(IGentleProvider provider) : base(provider) { }
/// <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) { }
public JetFactory( IGentleProvider provider ) : base( provider ) { }
public FirebirdAnalyzer( IGentleProvider provider ) : base( provider ) { }
/// <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)); }
protected SQL92Analyzer( IGentleProvider provider ) : base( provider ) { }
/// <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)); }
public FirebirdFactory(IGentleProvider provider) : base(provider) { // TODO schemaName is currently not specifyable! }
/// <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 ) { }
public SQLServerFactory(IGentleProvider provider) : base(provider) { }
public OracleAnalyzer( IGentleProvider provider ) : base( provider ) { }
public SQLServerAnalyzer( IGentleProvider provider ) : base( provider ) { }
public OracleFactory( IGentleProvider provider ) : base( provider ) { }
public SQLiteAnalyzer( IGentleProvider provider ) : base( provider ) { }
public GentleRenderer( IGentleProvider provider ) { this.provider = provider; }